@Test @Ignore public void testRemarcar() { UtilsTest.LOGGER.info("testRemarcar"); try { GeneralConfig.loadConfig(GeneralConfig.getConfig()); final Properties config = GeneralConfig.getConfig(); config.setProperty(AccessibilityOptionsPane.MAIN_FOCUS_VISIBLE, "true"); GeneralConfig.loadConfig(config); final JFrame frame = new JFrame(); frame.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); final JTextField jTF = new JTextField(); Utils.remarcar(jTF); frame.add(jTF, c); frame.setBounds(200, 200, 500, 500); frame.setVisible(true); c.gridy = c.gridy + 1; final JComboBox jCB = new JComboBox(); Utils.remarcar(jCB); frame.add(jCB, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JLabel jL = new JLabel(); Utils.remarcar(jL); frame.add(jL, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JPanel panelJChB = new JPanel(); final JCheckBox jChB = new JCheckBox(); panelJChB.add(jChB); Utils.remarcar(jChB); frame.add(panelJChB, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JPanel panelJB = new JPanel(); final JButton jB = new JButton(); panelJB.add(jB); Utils.remarcar(jB); frame.add(panelJB, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JPanel panelJTB = new JPanel(); final JToggleButton jTB = new JToggleButton(); panelJTB.add(jTB); Utils.remarcar(jTB); frame.add(panelJTB, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JPanel panelJRB = new JPanel(); final JRadioButton jRB = new JRadioButton(); panelJRB.add(jRB); Utils.remarcar(jRB); frame.add(panelJRB, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JTextPane jTP = new JTextPane(); Utils.remarcar(jTP); frame.add(jTP, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JEditorPane jEP = new JEditorPane(); Utils.remarcar(jEP); frame.add(jEP, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JTree jT = new JTree(); Utils.remarcar(jT); frame.add(jT, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JList jLi = new JList(); Utils.remarcar(jLi); frame.add(jLi, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JScrollPane jSP = new JScrollPane(); Utils.remarcar(jSP); frame.add(jSP, c); frame.setVisible(true); c.gridy = c.gridy + 1; final JMenu jM = new JMenu(); Utils.remarcar(jM); frame.add(jM, c); frame.setVisible(true); final int fontSize = jM.getFont().getSize(); jTF.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJTextField(jTF)); jCB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJComboBox(jCB, jTF)); jL.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJLabel(jL, jCB)); jChB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJCheckBox(jChB, jL)); jB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJButton(jB, jChB)); jTB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJToggleButton(jTB, jB)); jRB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJRadioButton(jRB, jTB)); jTP.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJTextPane(jTP, jRB)); jEP.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJEditorPane(jEP, jTP)); jT.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJTree(jT, jEP)); jLi.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJList(jLi, jT)); jSP.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJSrollPane(jSP, jLi)); config.setProperty(AccessibilityOptionsPane.MAIN_HIGHT_CONTRAST, "true"); GeneralConfig.loadConfig(config); jTF.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJTextField(jTF)); jCB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJComboBox(jCB, jTF)); jL.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJLabel(jL, jCB)); jChB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJCheckBox(jChB, jL)); jB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJButton(jB, jChB)); jTB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJToggleButton(jTB, jB)); jRB.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJRadioButton(jRB, jTB)); jTP.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJTextPane(jTP, jRB)); jEP.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJEditorPane(jEP, jTP)); jT.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJTree(jT, jEP)); jLi.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJList(jLi, jT)); jSP.requestFocusInWindow(); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJSrollPane(jSP, jLi)); jM.setSelected(true); try { Thread.sleep(500); } catch (final InterruptedException e) { e.printStackTrace(); } Assert.assertTrue(this.remarcarJMenu(jM, jLi, fontSize)); } catch (final java.awt.HeadlessException e) { } }
public static void remarcar(final JComponent component){ if (GeneralConfig.isRemarked()){ if (component instanceof JButton){ final JButton button = (JButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JToggleButton){ final JToggleButton button = (JToggleButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar) { button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JTextField){ final JTextField textField = (JTextField) component; textField.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textField.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textField.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JComboBox){ final JComboBox comboBox = (JComboBox) component; comboBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { comboBox.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ comboBox.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { comboBox.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JRadioButton){ final JRadioButton radioButton = (JRadioButton) component; radioButton.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JLabel){ final JLabel label = (JLabel) component; label.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { label.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ label.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JCheckBox){ final JCheckBox checkBox = (JCheckBox) component; checkBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTextPane){ final JTextPane textPane = (JTextPane) component; textPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JEditorPane){ final JEditorPane editorPane = (JEditorPane) component; editorPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { editorPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ editorPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { editorPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTree){ final JTree tree = (JTree) component; tree.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { tree.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ tree.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { tree.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JList){ final JList list = (JList) component; list.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { list.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ list.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { list.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JMenu){ final JMenu menu = (JMenu) component; menu.addMenuListener(new MenuListener() { @Override public void menuSelected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()+5)); } @Override public void menuDeselected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()-5)); } @Override public void menuCanceled(final MenuEvent e) { } }); } if (component instanceof JScrollPane){ final JScrollPane scrollPane = (JScrollPane) component; scrollPane.addFocusListener( new FocusListener() { @Override public void focusLost(final FocusEvent e) { scrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ scrollPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { scrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } } }
Utils { public static void remarcar(final JComponent component){ if (GeneralConfig.isRemarked()){ if (component instanceof JButton){ final JButton button = (JButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JToggleButton){ final JToggleButton button = (JToggleButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar) { button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JTextField){ final JTextField textField = (JTextField) component; textField.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textField.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textField.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JComboBox){ final JComboBox comboBox = (JComboBox) component; comboBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { comboBox.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ comboBox.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { comboBox.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JRadioButton){ final JRadioButton radioButton = (JRadioButton) component; radioButton.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JLabel){ final JLabel label = (JLabel) component; label.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { label.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ label.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JCheckBox){ final JCheckBox checkBox = (JCheckBox) component; checkBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTextPane){ final JTextPane textPane = (JTextPane) component; textPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JEditorPane){ final JEditorPane editorPane = (JEditorPane) component; editorPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { editorPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ editorPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { editorPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTree){ final JTree tree = (JTree) component; tree.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { tree.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ tree.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { tree.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JList){ final JList list = (JList) component; list.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { list.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ list.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { list.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JMenu){ final JMenu menu = (JMenu) component; menu.addMenuListener(new MenuListener() { @Override public void menuSelected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()+5)); } @Override public void menuDeselected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()-5)); } @Override public void menuCanceled(final MenuEvent e) { } }); } if (component instanceof JScrollPane){ final JScrollPane scrollPane = (JScrollPane) component; scrollPane.addFocusListener( new FocusListener() { @Override public void focusLost(final FocusEvent e) { scrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ scrollPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { scrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } } } }
Utils { public static void remarcar(final JComponent component){ if (GeneralConfig.isRemarked()){ if (component instanceof JButton){ final JButton button = (JButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JToggleButton){ final JToggleButton button = (JToggleButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar) { button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JTextField){ final JTextField textField = (JTextField) component; textField.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textField.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textField.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JComboBox){ final JComboBox comboBox = (JComboBox) component; comboBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { comboBox.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ comboBox.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { comboBox.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JRadioButton){ final JRadioButton radioButton = (JRadioButton) component; radioButton.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JLabel){ final JLabel label = (JLabel) component; label.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { label.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ label.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JCheckBox){ final JCheckBox checkBox = (JCheckBox) component; checkBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTextPane){ final JTextPane textPane = (JTextPane) component; textPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JEditorPane){ final JEditorPane editorPane = (JEditorPane) component; editorPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { editorPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ editorPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { editorPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTree){ final JTree tree = (JTree) component; tree.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { tree.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ tree.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { tree.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JList){ final JList list = (JList) component; list.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { list.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ list.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { list.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JMenu){ final JMenu menu = (JMenu) component; menu.addMenuListener(new MenuListener() { @Override public void menuSelected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()+5)); } @Override public void menuDeselected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()-5)); } @Override public void menuCanceled(final MenuEvent e) { } }); } if (component instanceof JScrollPane){ final JScrollPane scrollPane = (JScrollPane) component; scrollPane.addFocusListener( new FocusListener() { @Override public void focusLost(final FocusEvent e) { scrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ scrollPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { scrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } } } private  Utils(); }
Utils { public static void remarcar(final JComponent component){ if (GeneralConfig.isRemarked()){ if (component instanceof JButton){ final JButton button = (JButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JToggleButton){ final JToggleButton button = (JToggleButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar) { button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JTextField){ final JTextField textField = (JTextField) component; textField.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textField.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textField.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JComboBox){ final JComboBox comboBox = (JComboBox) component; comboBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { comboBox.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ comboBox.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { comboBox.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JRadioButton){ final JRadioButton radioButton = (JRadioButton) component; radioButton.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JLabel){ final JLabel label = (JLabel) component; label.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { label.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ label.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JCheckBox){ final JCheckBox checkBox = (JCheckBox) component; checkBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTextPane){ final JTextPane textPane = (JTextPane) component; textPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JEditorPane){ final JEditorPane editorPane = (JEditorPane) component; editorPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { editorPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ editorPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { editorPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTree){ final JTree tree = (JTree) component; tree.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { tree.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ tree.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { tree.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JList){ final JList list = (JList) component; list.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { list.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ list.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { list.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JMenu){ final JMenu menu = (JMenu) component; menu.addMenuListener(new MenuListener() { @Override public void menuSelected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()+5)); } @Override public void menuDeselected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()-5)); } @Override public void menuCanceled(final MenuEvent e) { } }); } if (component instanceof JScrollPane){ final JScrollPane scrollPane = (JScrollPane) component; scrollPane.addFocusListener( new FocusListener() { @Override public void focusLost(final FocusEvent e) { scrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ scrollPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { scrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } } } private  Utils(); static void openFile(final String filepath); static void openFile(final File file); static char getLanguageMnemonic(final List<Character> mnemonicList, final String actualLanguage); static void remarcar(final JComponent component); static void setContrastColor(final JComponent component); static void setFontBold(final JComponent component); static String remarkMnemonic( final String text, final int key); static FileFilter getRepositoryFileFilterPkcs12(); static FileFilter getRepositoryFileFilterPkcs11(); static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText); }
Utils { public static void remarcar(final JComponent component){ if (GeneralConfig.isRemarked()){ if (component instanceof JButton){ final JButton button = (JButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JToggleButton){ final JToggleButton button = (JToggleButton) component; button.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createEmptyBorder()); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createEmptyBorder()); } } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else if (button.getParent() instanceof JToolBar){ button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } } else { if (button.getParent() instanceof JPanel){ ((JPanel)button.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } else if (button.getParent() instanceof JToolBar) { button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } } }); } if (component instanceof JTextField){ final JTextField textField = (JTextField) component; textField.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textField.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textField.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JComboBox){ final JComboBox comboBox = (JComboBox) component; comboBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { comboBox.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ comboBox.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { comboBox.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JRadioButton){ final JRadioButton radioButton = (JRadioButton) component; radioButton.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)radioButton.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JLabel){ final JLabel label = (JLabel) component; label.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { label.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ label.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JCheckBox){ final JCheckBox checkBox = (JCheckBox) component; checkBox.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { ((JPanel)checkBox.getParent()).setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTextPane){ final JTextPane textPane = (JTextPane) component; textPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { textPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ textPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { textPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JEditorPane){ final JEditorPane editorPane = (JEditorPane) component; editorPane.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { editorPane.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ editorPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { editorPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JTree){ final JTree tree = (JTree) component; tree.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { tree.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast()|| Main.isOSHighContrast()){ tree.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { tree.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JList){ final JList list = (JList) component; list.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { list.setBorder(BorderFactory.createEmptyBorder()); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ list.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { list.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } if (component instanceof JMenu){ final JMenu menu = (JMenu) component; menu.addMenuListener(new MenuListener() { @Override public void menuSelected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()+5)); } @Override public void menuDeselected(final MenuEvent e) { menu.setFont(new Font(menu.getFont().getName(), menu.getFont().getStyle(), menu.getFont().getSize()-5)); } @Override public void menuCanceled(final MenuEvent e) { } }); } if (component instanceof JScrollPane){ final JScrollPane scrollPane = (JScrollPane) component; scrollPane.addFocusListener( new FocusListener() { @Override public void focusLost(final FocusEvent e) { scrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); } @Override public void focusGained(final FocusEvent e) { if (GeneralConfig.isHighContrast() || Main.isOSHighContrast()){ scrollPane.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); } else { scrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); } } }); } } } private  Utils(); static void openFile(final String filepath); static void openFile(final File file); static char getLanguageMnemonic(final List<Character> mnemonicList, final String actualLanguage); static void remarcar(final JComponent component); static void setContrastColor(final JComponent component); static void setFontBold(final JComponent component); static String remarkMnemonic( final String text, final int key); static FileFilter getRepositoryFileFilterPkcs12(); static FileFilter getRepositoryFileFilterPkcs11(); static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText);  }