I have one Actionlistener that can change my text to Italic... And I have one action listener that can change my text to bold.. But I just wrote up these IF ELSE statements and they do NOT work... How can I get the textarea to know that BOTH check boxes have been selected and not just one?
jcBold.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(jcBold.isSelected()){ Font font1 = new Font("Serif", Font.BOLD, 14); jtaOutput.setFont(font1); }else if (jcBold.isSelected() && jcItalic.isSelected()){ Font font2 = new Font("Serif", Font.BOLD + Font.ITALIC, 14); jtaOutput.setFont(font2); }else { Font font1 = new Font("Times Roman", Font.PLAIN, 12); jtaOutput.setFont(font1); } } }); panel_1.add(jcBold); jcItalic = new JCheckBox("Italic"); jcItalic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(jcItalic.isSelected()){ Font font1 = new Font("Serif", Font.ITALIC, 14); jtaOutput.setFont(font1); }else if (jcBold.isSelected() && jcItalic.isSelected()){ System.out.println("1"); Font font2 = new Font("Serif", Font.BOLD + Font.ITALIC, 14); jtaOutput.setFont(font2); }else { Font font1 = new Font("Times Roman", Font.PLAIN, 12); jtaOutput.setFont(font1); } } });