I'm creating a JFrame that allows the user to change the font and font size of a piece of text by using 2 JCheckBoxes. The first JCheckBox gives the user every font available and it works fine. The second JCheckBox is where I'm having problems. It should have an array of numbers 1-100 so the user can change the size of font. I have posted the error I am getting below:
Error:
SetFont.java:32: cannot find symbol
symbol : method add(int[])
location: class javax.swing.JComboBox
jcbFonts.add(sizes);
^
1 error
import javax.swing.*; import java.awt.*; import java.awt.GraphicsEnvironment; public class SetFont extends JFrame { private JPanel p1, p2; private JLabel jlblFontName, jlblFontSize; private JComboBox jcbFonts, jcbSizes; private JTextArea jtxtWelcome; private JCheckBox jckbBold, jckbItalic; public SetFont() // Default Constructor { p1 = new JPanel(); jlblFontName = new JLabel("Font Name"); GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); // create instance of java.awt.GraphicsEnvironment() String[] fontNames = e.getAvailableFontFamilyNames(); // get all available fonts for user jcbFonts = new JComboBox(fontNames); jlblFontSize = new JLabel("Font Size"); int[] sizes = new int[100]; // populate array with font sizes 1-100 for(int i = 1; i < 100; i ++) { jcbFonts.add(sizes); } p1.add(jlblFontName); // add all 4 components to p1 p1.add(jcbFonts); p1.add(jlblFontSize); p1.add(jcbSizes); add(p1,BorderLayout.NORTH); add(jtxtWelcome = new JTextArea("Welcome to Java")); jtxtWelcome.setSize(3, 20); p2 = new JPanel(); p2.add(jckbBold = new JCheckBox("Bold")); jckbBold.setMnemonic('B'); p2.add(jckbItalic = new JCheckBox("Italic")); jckbItalic.setMnemonic('I'); add(p2,BorderLayout.SOUTH); } public static void main(String[] args) { SetFont frame = new SetFont(); frame.setTitle("Set Font Details"); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } }