Java Code Examples for javax.swing.JPanel#setFocusable()

The following examples show how to use javax.swing.JPanel#setFocusable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphInterpolator.java    From GIFKR with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void initializeComponents() {
	
	graphPanel = new JPanel() {
		private static final long serialVersionUID = -1105560304467720245L;
		
		@Override 
		public Dimension getPreferredSize() {
			return getGraphSize();
		}
		
		@Override 
		public void paintComponent(Graphics g) {
			super.paintComponent(g);
			paintGraph((Graphics2D) g, graphPanel.getWidth(), graphPanel.getHeight());
		}
	};
	graphPanel.setFocusable(true);
}
 
Example 2
Source File: JPanelRenderer.java    From Spark with Apache License 2.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list,
                                                 Object value,
                                                 int index,
                                                 boolean isSelected,
                                                 boolean cellHasFocus) {
       JPanel panel = (JPanel)value;
       panel.setFocusable(false);

       if (isSelected) {
           panel.setForeground((Color)UIManager.get("List.selectionForeground"));
           panel.setBackground((Color)UIManager.get("List.selectionBackground"));
           panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.selectionBorder")));
       }
       else {
           panel.setBackground(list.getBackground());
           panel.setForeground(list.getForeground());
           panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("ContactItem.background")));
       }

       list.setBackground((Color)UIManager.get("ContactItem.background"));


       return panel;
   }
 
Example 3
Source File: HistoryItemRenderer.java    From Spark with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
    JPanel panel = (JPanel)value;
    panel.setFocusable(false);

    if (isSelected) {
        panel.setForeground(Color.black);
        panel.setBackground(new Color(217, 232, 250));
        panel.setBorder(BorderFactory.createLineBorder(new Color(187, 195, 215)));
    }
    else {
        panel.setBackground(list.getBackground());
        panel.setForeground(list.getForeground());
        panel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));

    }

    return panel;
}
 
Example 4
Source File: FastpathPanelRenderer.java    From Spark with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
    JPanel panel = (JPanel)value;
    panel.setFocusable(false);

    if (isSelected) {
        panel.setForeground((Color)UIManager.get("List.selectionForeground"));
        panel.setBackground((Color)UIManager.get("List.selectionBackground"));
        panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.selectionBorder")));
    }
    else {
        panel.setBackground(list.getBackground());
        panel.setForeground(list.getForeground());
        panel.setBorder(BorderFactory.createMatteBorder(0,0,1,0, Color.lightGray));
    }

    list.setBackground((Color)UIManager.get("List.background"));


    return panel;
}
 
Example 5
Source File: PopupManager.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public PopupManager(String title) {
  main = new JPanel();
  main.setBorder(new javax.swing.border.TitledBorder(title));
  info = new JLabel();
  main.add(info);
  main.setFocusable(false);
}
 
Example 6
Source File: ParameterTupelCellEditor.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private void constructPanel(String[] values) {
	// constructing editors
	editors = new PropertyValueCellEditor[types.length];
	for (int i = 0; i < types.length; i++) {
		editors[i] = PropertyPanel.instantiateValueCellEditor(types[i], operator);
	}

	// building panel
	panel = new JPanel();
	panel.setFocusable(true);
	panel.setLayout(new GridLayout(1, editors.length));
	for (int i = 0; i < types.length; i++) {
		Component editorComponent = editors[i].getTableCellEditorComponent(null, values[i], false, 0, 0);

		if (editorComponent instanceof JComboBox) {
			if (((JComboBox<?>) editorComponent).isEditable()) {
				ComboBoxEditor editor = ((JComboBox<?>) editorComponent).getEditor();
				if (editor instanceof BasicComboBoxEditor) {
					editor.getEditorComponent().addFocusListener(focusListener);
				}
			} else {
				editorComponent.addFocusListener(focusListener);
			}
		} else if (editorComponent instanceof JPanel) {
			JPanel editorPanel = (JPanel) editorComponent;
			Component[] components = editorPanel.getComponents();
			for (Component comp : components) {
				comp.addFocusListener(focusListener);
			}
		} else {

			editorComponent.addFocusListener(focusListener);
		}
		panel.add(editorComponent);
		panel.addFocusListener(focusListener);
	}
}
 
Example 7
Source File: BinaryPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public BinaryPanel(final MainPanel mainPanel) {
    super(new BorderLayout());
    this.mainPanel = mainPanel;

    add(new JScrollPane(hexEditor), BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel(new BorderLayout());
    JPanel buttonsPanel = new JPanel(new FlowLayout());
    bottomPanel.add(buttonsPanel, BorderLayout.EAST);
    add(bottomPanel, BorderLayout.SOUTH);

    // todo: honfika: dynamically resize the hex data
    /*addComponentListener(new ComponentAdapter() {

     @Override
     public void componentResized(ComponentEvent e) {
     setBinaryData(binaryDataTag);
     }
     });*/
    swfInsidePanel = new JPanel();
    swfInsidePanel.setBackground(new Color(253, 205, 137));
    swfInsidePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    swfInsidePanel.add(new JLabel(AppStrings.translate("binarydata.swfInside")));
    swfInsidePanel.setFocusable(true);
    swfInsidePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    swfInsidePanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            mainPanel.loadFromBinaryTag(binaryDataTag);
            swfInsidePanel.setVisible(false);
        }

    });
    add(swfInsidePanel, BorderLayout.NORTH);
    swfInsidePanel.setVisible(false);
}
 
Example 8
Source File: VirtualCursor.java    From haxademic with MIT License 5 votes vote down vote up
public void setup() {
	super.setup();
	// set special window properties
	jframe = (JFrame)((PSurfaceAWT.SmoothCanvas) getSurface().getNative()).getFrame();
	jframe.removeNotify();
	jframe.setUndecorated(true);
	jframe.setLayout(null);
	jframe.addNotify();
	jframe.setAlwaysOnTop(true);

	pg = createGraphics(width, height);
	cursor = Base64Image.decodePImageFromBase64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t+WN4Bt5UiEANU/kR41tTiKEKBySpJkkT4QIbmn3qxR4zuSCM9taYYIZUBjFs0WPFIxGr8EpEciTuMHKMN7pvci1KQwBmsUOI1IhKOtCKUFiSdCgArxyxrU+O1QeGV8EVIUPPNEhJ2rCKUFCYgQTEAAhct1PVEZbvwQhe6IsQjxBARQaQJQSIR4AjKgfKjmRHInIJ82KBS+CA/SNnAm7gS0+YSEE3MnoP3XJ6SAdGPjX8NwFTbx7USYCGawCOnsFzIQQISg3nmZGRMQCEOEw71/nl3jCYgf68bPT8KcgHDsRQgaP4iLCDVo/CBuIgQTEIiLCDUUoUP4ExCOXePXmi9C/gT0UREu94ow/zoRKnAFPytC3SoV3CNCPAFlNeHgW2Ve4+/Ihnhywo2/bAiIJww8AeVPHND2mSLsKhOI6oIvQpx0ETclxKB5FbdlAxx57OLORO9AsSduzmTeUAS6L1uEJH6YfPDfEJEMi/hQEskvBYd6T28tBWCnaBUfT+j/LIVNWOY7PppBCtOtd0oAAAAASUVORK5CYII=");

	JPanel panel = new JPanel() {
		private static final long serialVersionUID = 1L;

		@Override
		protected void paintComponent(Graphics graphics) {
			if (graphics instanceof Graphics2D) {
				Graphics2D g2d = (Graphics2D) graphics;
				g2d.drawImage(pg.image, 0, 0, null);
			}
		}
	};

	jframe.setContentPane(panel);
	panel.setFocusable(true);
	panel.setFocusTraversalKeysEnabled(false);
	panel.requestFocus();
	panel.requestFocusInWindow();
}
 
Example 9
Source File: CallHistoryRenderer.java    From Spark with Apache License 2.0 5 votes vote down vote up
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
    JPanel panel = (JPanel)value;
    panel.setFocusable(false);

    if (isSelected) {
        panel.setForeground(Color.white);
        panel.setBackground(new Color(51, 136, 238));
        panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.selectionBorder")));
    }
    else {
        if (index % 2 == 0) {
            panel.setBackground((Color)UIManager.get("List.selectionBackground"));
        }
        else {
            panel.setBackground(list.getBackground());
        }
        panel.setForeground(list.getForeground());
        panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.background")));
    }

    list.setBackground((Color)UIManager.get("List.background"));


    return panel;
}