I am creating an om law application. Please keep in mind that this is my first program (without tutorials), so please be kind =) Here is what it looks like at startup:

The combo box has options for calculating volts, calculating Ohms, etc.
The central panel is set to invisible until you make a choice from the drop-down list. Here's what it should look like when you make a choice:

The problem I am facing is that the first time that I do is only one of the JLabel / JTextArea combines (each pair is on its own panel inside a vertical window):

If I click on comboBox and make the same selection again, it will display correctly. I cannot understand why it does not work correctly on the first click. Maybe I'm using the wrong approach when building a GUI. Here's the code for now:
private JFrame frame; private String[] choiceList = {"", "Calculate Volts", "Calculate Amps", "Calculate Ohms", "Calculate Watts"}; private JTextField textField_2; private JPanel centerPanel; private String volts = "Volts"; private String amps = "Amps"; private String ohms = "Ohms"; private String watts = "Watts"; private JLabel var1Label; private JLabel var2Label; private JLabel var3Label; private JFormattedTextField var1TextField; private JFormattedTextField var2TextField; private JFormattedTextField var3TextField; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { GUI window = new GUI(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public GUI() { initialize(); } private void initialize() { frame = new JFrame(); frame.setTitle("BotsOne ElectriCalc"); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel northPanel = new JPanel(); northPanel.setIgnoreRepaint(true); northPanel.setBorder(new LineBorder(Color.GRAY)); frame.getContentPane().add(northPanel, BorderLayout.NORTH); JLabel choiceLabel = new JLabel("Please make a selection:"); northPanel.add(choiceLabel); JComboBox choiceCombo = new JComboBox(choiceList); northPanel.add(choiceCombo); choiceCombo.addActionListener(new ChoiceComboListener()); JPanel southPanel = new JPanel(); southPanel.setIgnoreRepaint(true); southPanel.setBorder(new LineBorder(Color.GRAY)); frame.getContentPane().add(southPanel, BorderLayout.SOUTH); JLabel label = new JLabel("Answer:"); southPanel.add(label); textField_2 = new JTextField(); textField_2.setColumns(10); southPanel.add(textField_2); centerPanel = new JPanel(); centerPanel.setVisible(false); centerPanel.setBorder(new LineBorder(Color.GRAY)); frame.getContentPane().add(centerPanel, BorderLayout.CENTER); Box centerPanelVertBox = Box.createVerticalBox(); centerPanelVertBox.setAlignmentX(Component.CENTER_ALIGNMENT); centerPanel.add(centerPanelVertBox); centerPanelVertBox.setVisible(true); centerPanelVertBox.setBorder(null); JLabel pleaseEnterLabel = new JLabel("Please enter 2 of 3 values:"); pleaseEnterLabel.setBorder(new EmptyBorder(15, 0, 10, 0)); pleaseEnterLabel.setAlignmentX(Component.CENTER_ALIGNMENT); centerPanelVertBox.add(pleaseEnterLabel); JPanel var1Panel = new JPanel(); centerPanelVertBox.add(var1Panel); var1Label = new JLabel("xxx"); var1Label.setAlignmentX(Component.CENTER_ALIGNMENT); var1Panel.add(var1Label); var1TextField = new JFormattedTextField(NumberFormat.getInstance()); var1TextField.setColumns(10); var1Panel.add(var1TextField); Panel var2Panel = new Panel(); centerPanelVertBox.add(var2Panel); var2Label = new JLabel("xxx"); var2Label.setAlignmentX(Component.CENTER_ALIGNMENT); var2Panel.add(var2Label); var2TextField = new JFormattedTextField(NumberFormat.getInstance()); var2TextField.setColumns(10); var2Panel.add(var2TextField); Panel var3Panel = new Panel(); centerPanelVertBox.add(var3Panel); var3Label = new JLabel("xxx"); var3Label.setAlignmentX(Component.CENTER_ALIGNMENT); var3Panel.add(var3Label); var3TextField = new JFormattedTextField(NumberFormat.getInstance()); var3TextField.setColumns(10); var3Panel.add(var3TextField); Panel calculatePanel = new Panel(); centerPanelVertBox.add(calculatePanel); JButton calculateButton = new JButton("Calculate"); calculatePanel.add(calculateButton); } public class ChoiceComboListener implements ActionListener {
If you look at the bottom, there is an inner class ChoiceComboListener, it is a comboBox listener, I tried to play with repaint () and other things, but I can not think of anything. Any help, guidance or criticism is appreciated.