Java Code Examples for javax.swing.JLabel#setFocusable()
The following examples show how to use
javax.swing.JLabel#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: ChatPanel.java From freecol with GNU General Public License v2.0 | 6 votes |
/** * The constructor that will add the items to this panel. * * @param freeColClient The {@code FreeColClient} for the game. */ public ChatPanel(FreeColClient freeColClient) { super(freeColClient, null, new BorderLayout(10, 10)); JLabel label = Utility.localizedLabel("chatPanel.message"); field = new JTextField("", 40); field.setActionCommand(String.valueOf(CHAT)); field.addActionListener(this); add(label); add(field); //setFocusable(false); label.setFocusable(false); field.setFocusable(true); setSize(getPreferredSize()); }
Example 2
Source File: SwingTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates a helpLabel and adds it to the labelPanel. The helpLabel shows a help icon. * * @param labelPanel * the panel which will be used to add the label. The panel needs to have a * {@link BorderLayout} as layout manager as the label will be added with the * constraint {@link BorderLayout#EAST}. * @return the helpLabel for further use * @since 7.0.0 */ public static JLabel initializeHelpLabel(JPanel labelPanel) { JPanel helpPanel = new JPanel(); helpPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTH; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 3, 0, 0); final JLabel helpLabel = new JLabel(); helpLabel.setIcon(createIcon(HELP_ICON_PATH)); helpLabel.setFocusable(false); gbc.anchor = GridBagConstraints.CENTER; helpPanel.add(helpLabel, gbc); gbc.gridy += 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weighty = 1.0; gbc.insets = new Insets(0, 0, 0, 0); helpPanel.add(new JLabel(), gbc); labelPanel.add(helpPanel, BorderLayout.EAST); return helpLabel; }
Example 3
Source File: PaletteToolBarBorder.java From openAGV with Apache License 2.0 | 5 votes |
@Override public void paintBorder(Component component, Graphics gr, int x, int y, int w, int h) { Graphics2D g = (Graphics2D) gr; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); if ((component instanceof JToolBar) /* && ((((JToolBar) component).getUI()) instanceof PaletteToolBarUI) */) { JToolBar c = (JToolBar) component; if (c.isFloatable()) { int borderColor = 0x80ff0000; float[] stops = ENABLED_STOPS; Color[] stopColors = ENABLED_STOP_COLORS; g.setColor(new Color(borderColor, true)); LinearGradientPaint lgp = new LinearGradientPaint( new Point2D.Float(1, 1), new Point2D.Float(19, 1), stops, stopColors, MultipleGradientPaint.CycleMethod.REPEAT); g.setPaint(lgp); g.fillRect(1, 1, 7 - 2, h - 2); ImageIcon icon = new ImageIcon(getClass().getResource("/org/opentcs/guing/res/symbols/toolbar/border.jpg")); if (c.getComponentCount() != 0 && !(c.getComponents()[0] instanceof JLabel)) { JLabel label = new JLabel(icon); label.setFocusable(false); c.add(label, 0); label.getParent().setBackground(label.getBackground()); label.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } } } }
Example 4
Source File: RunConvertPanel.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void setupDisplay(JPanel panel, CDOMObject pc) { panel.setLayout(new GridBagLayout()); JLabel introLabel = new JLabel("Conversion in progress"); GridBagConstraints gbc = new GridBagConstraints(); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 10, 5, 10); panel.add(introLabel, gbc); JLabel explainLabel = new JLabel("<html>The LST data is being converted. In the log, " + "LSTERROR rows are errors that need to be manually corrected in the source data. " + "LSTWARN rows indicate changes the converter is making. " + "See " + changeLogFile.getAbsolutePath() + " for a log of all data changes.</html>"); explainLabel.setFocusable(true); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 10, 5, 10); panel.add(explainLabel, gbc); progressBar = getProgressBar(); Dimension d = progressBar.getPreferredSize(); d.width = 400; progressBar.setPreferredSize(d); progressBar.setStringPainted(true); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0); gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(progressBar, gbc); Component messageAreaContainer = new JScrollPane(getMessageArea()); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0); gbc.fill = GridBagConstraints.BOTH; panel.add(messageAreaContainer, gbc); panel.setPreferredSize(new Dimension(800, 500)); }
Example 5
Source File: RunConvertPanel.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void setupDisplay(JPanel panel, CDOMObject pc) { panel.setLayout(new GridBagLayout()); JLabel introLabel = new JLabel("Conversion in progress"); GridBagConstraints gbc = new GridBagConstraints(); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 10, 5, 10); panel.add(introLabel, gbc); JLabel explainLabel = new JLabel("<html>The LST data is being converted. In the log, " + "LSTERROR rows are errors that need to be manually corrected in the source data. " + "LSTWARN rows indicate changes the converter is making. " + "See " + changeLogFile.getAbsolutePath() + " for a log of all data changes.</html>"); explainLabel.setFocusable(true); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 10, 5, 10); panel.add(explainLabel, gbc); progressBar = getProgressBar(); Dimension d = progressBar.getPreferredSize(); d.width = 400; progressBar.setPreferredSize(d); progressBar.setStringPainted(true); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0); gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(progressBar, gbc); Component messageAreaContainer = new JScrollPane(getMessageArea()); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0); gbc.fill = GridBagConstraints.BOTH; panel.add(messageAreaContainer, gbc); panel.setPreferredSize(new Dimension(800, 500)); }
Example 6
Source File: PropertyPanel.java From opt4j with MIT License | 4 votes |
protected void updatePropertyPanel() { panel.removeAll(); for (final Property property : module.getProperties()) { if (property.isActive()) { String name = property.getName(); int i = getIndent(property); String s = ""; for (int j = 0; j < i; j++) { s += " "; } if (i > 0) { s = s.substring(2) + "\u21aa "; } JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JLabel label = new JLabel(s + name); label.setFocusable(false); String tooltip = format.getTooltip(property); if (tooltip != null) { label.setToolTipText(tooltip); } labelPanel.add(label); File file = property.getAnnotation(File.class); if (file != null) { JButton browse = new JButton(Icons.getIcon(Icons.FOLDER)); browse.setFocusable(false); browse.setBorderPainted(false); browse.setContentAreaFilled(false); browse.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); browse.addActionListener((ActionEvent e) -> selectFile(property)); browse.setCursor(new Cursor(Cursor.HAND_CURSOR)); browse.setToolTipText("Browse ..."); labelPanel.add(browse); } panel.add(labelPanel); Component component = components.get(property); panel.add(component); } } if (module.getModule().getClass().isAnnotationPresent(Citation.class)) { Citation citation = module.getModule().getClass().getAnnotation(Citation.class); addReferenceRow(citation); } }