@Test public void testSetContrastColor() { UtilsTest.LOGGER.info("testSetContrastColor"); try { GeneralConfig.loadConfig(GeneralConfig.getConfig()); final Properties config = GeneralConfig.getConfig(); final JComboBox jComboBox = new JComboBox(); final JPasswordField jPasswordField = new JPasswordField(); final JTextField jTextField = new JTextField(); final JTree jTree = new JTree(); final JList jList = new JList(); final JPanel jPanel = new JPanel(); jPanel.setBorder(BorderFactory.createTitledBorder("Test")); final JStatusBar jStatusBar = new JStatusBar(); jStatusBar.setLabelWidth((int) Toolkit.getDefaultToolkit() .getScreenSize().getWidth()); jStatusBar.setStatus("Test"); final JEditorPane jEditorPane = new JEditorPane(); config.setProperty(AccessibilityOptionsPane.MAIN_HIGHT_CONTRAST, "true"); GeneralConfig.loadConfig(config); Assert.assertTrue(this.highContrastJComboBox(jComboBox)); Assert.assertTrue(this.highContrastJPasswordField(jPasswordField)); Assert.assertTrue(this.highContrastJTextField(jTextField)); Assert.assertTrue(this.highContrastJTree(jTree)); Assert.assertTrue(this.highContrastJList(jList)); Assert.assertTrue(this.highContrastJPanel(jPanel)); Assert.assertTrue(this.highContrastJStatusBar(jStatusBar)); Assert.assertTrue(this.highContrastJEditorPane(jEditorPane)); config.setProperty(AccessibilityOptionsPane.MAIN_HIGHT_CONTRAST, "false"); GeneralConfig.loadConfig(config); Assert.assertTrue(this.highContrastJComboBox(jComboBox)); Assert.assertTrue(this.highContrastJPasswordField(jPasswordField)); Assert.assertTrue(this.highContrastJTextField(jTextField)); Assert.assertTrue(this.highContrastJTree(jTree)); Assert.assertTrue(this.highContrastJList(jList)); Assert.assertTrue(this.highContrastJPanel(jPanel)); Assert.assertTrue(this.highContrastJStatusBar(jStatusBar)); Assert.assertTrue(this.highContrastJEditorPane(jEditorPane)); } catch (final java.awt.HeadlessException e) { } }
public static void setContrastColor (final JComponent component){ if (GeneralConfig.isHighContrast()){ if (component instanceof JComboBox || component instanceof JPasswordField || component instanceof JTextField){ component.setBackground(Color.WHITE); } else if(component instanceof JCheckBox) { component.setForeground(Color.WHITE); } else if(component instanceof JTree){ component.setForeground(Color.WHITE); } else if(component instanceof JList){ component.setForeground(Color.BLACK); } else if(component instanceof JPanel){ if (component.getBorder()!=null && component.getBorder().getClass().getName().equals("javax.swing.border.TitledBorder") && (TitledBorder)component.getBorder()!=null){ ((TitledBorder)component.getBorder()).setTitleColor(Color.WHITE); } component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } else if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.WHITE); } else if (component instanceof JEditorPane){ component.setBackground(Color.BLACK); } else { component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } } else { if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.BLACK); } } }
Utils { public static void setContrastColor (final JComponent component){ if (GeneralConfig.isHighContrast()){ if (component instanceof JComboBox || component instanceof JPasswordField || component instanceof JTextField){ component.setBackground(Color.WHITE); } else if(component instanceof JCheckBox) { component.setForeground(Color.WHITE); } else if(component instanceof JTree){ component.setForeground(Color.WHITE); } else if(component instanceof JList){ component.setForeground(Color.BLACK); } else if(component instanceof JPanel){ if (component.getBorder()!=null && component.getBorder().getClass().getName().equals("javax.swing.border.TitledBorder") && (TitledBorder)component.getBorder()!=null){ ((TitledBorder)component.getBorder()).setTitleColor(Color.WHITE); } component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } else if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.WHITE); } else if (component instanceof JEditorPane){ component.setBackground(Color.BLACK); } else { component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } } else { if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.BLACK); } } } }
Utils { public static void setContrastColor (final JComponent component){ if (GeneralConfig.isHighContrast()){ if (component instanceof JComboBox || component instanceof JPasswordField || component instanceof JTextField){ component.setBackground(Color.WHITE); } else if(component instanceof JCheckBox) { component.setForeground(Color.WHITE); } else if(component instanceof JTree){ component.setForeground(Color.WHITE); } else if(component instanceof JList){ component.setForeground(Color.BLACK); } else if(component instanceof JPanel){ if (component.getBorder()!=null && component.getBorder().getClass().getName().equals("javax.swing.border.TitledBorder") && (TitledBorder)component.getBorder()!=null){ ((TitledBorder)component.getBorder()).setTitleColor(Color.WHITE); } component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } else if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.WHITE); } else if (component instanceof JEditorPane){ component.setBackground(Color.BLACK); } else { component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } } else { if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.BLACK); } } } private  Utils(); }
Utils { public static void setContrastColor (final JComponent component){ if (GeneralConfig.isHighContrast()){ if (component instanceof JComboBox || component instanceof JPasswordField || component instanceof JTextField){ component.setBackground(Color.WHITE); } else if(component instanceof JCheckBox) { component.setForeground(Color.WHITE); } else if(component instanceof JTree){ component.setForeground(Color.WHITE); } else if(component instanceof JList){ component.setForeground(Color.BLACK); } else if(component instanceof JPanel){ if (component.getBorder()!=null && component.getBorder().getClass().getName().equals("javax.swing.border.TitledBorder") && (TitledBorder)component.getBorder()!=null){ ((TitledBorder)component.getBorder()).setTitleColor(Color.WHITE); } component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } else if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.WHITE); } else if (component instanceof JEditorPane){ component.setBackground(Color.BLACK); } else { component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } } else { if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.BLACK); } } } 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 setContrastColor (final JComponent component){ if (GeneralConfig.isHighContrast()){ if (component instanceof JComboBox || component instanceof JPasswordField || component instanceof JTextField){ component.setBackground(Color.WHITE); } else if(component instanceof JCheckBox) { component.setForeground(Color.WHITE); } else if(component instanceof JTree){ component.setForeground(Color.WHITE); } else if(component instanceof JList){ component.setForeground(Color.BLACK); } else if(component instanceof JPanel){ if (component.getBorder()!=null && component.getBorder().getClass().getName().equals("javax.swing.border.TitledBorder") && (TitledBorder)component.getBorder()!=null){ ((TitledBorder)component.getBorder()).setTitleColor(Color.WHITE); } component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } else if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.WHITE); } else if (component instanceof JEditorPane){ component.setBackground(Color.BLACK); } else { component.setForeground(Color.WHITE); component.setBackground(Color.BLACK); } } else { if (component instanceof JStatusBar){ ((JLabel)component.getComponent(0)).setForeground(Color.BLACK); } } } 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);  }