0

Everything else seems to be working fine so far besides the pesky JLabel classes. What do you guys and girls suggest I change for this program to work because I can't seem to understand the problem. By the way, the programming project is: Modify the intropanel class of the layoutdemo program so that it uses a box layout manager. Use invisible components to put space before and between the two labels on the panel.

import java.awt.*;
import javax.swing.*;

    @SuppressWarnings("serial")
    public class IntroPanel extends JPanel 
{
// ------------------------------------------------------------------------------ 
------------
// Sets up this panel with two labels 
// ------------------------------------------------------------------------------ 
------------
public IntroPanel() 
{
   setBackground(Color.green);

   JLabel 11 = new JLabel("Box Layout Manager Demonstration");
   JLabel 12 = new JLabel("This is an example of a box layout manager.");

   Component asinineProgramContainer1 = new JLabel("");
   Component asinineProgramContainer2 = new JLabel("");

   asinineProgramContainer1.setVisible(false);
   asinineProgramContainer2.setVisible(false);

   Box mainVerticleBox = Box.createVerticalBox();
   Box labelBox = Box.createHorizontalBox();
   Box invisibleContentBoxTop = Box.createHorizontalBox();
   Box invisibleContentBoxBottom = Box.createHorizontalBox();

   invisibleContentBoxTop.add(asinineProgramContainer1);
   labelBox.add(11);
   labelBox.add(Box.createRigidArea(new Dimension(100,100)));
   labelBox.add(12);
   invisibleContentBoxBottom.add(asinineProgramContainer2);

   mainVerticalBox.add(invisibleContentBoxTop);
   mainVerticalBox.add(Box.createGlue());
   mainVerticalBox.add(labelBox);
   mainVerticalBox.add(Box.createGlue);
   mainVerticalBox.add(invisibleContentBoxBottom);

   add(mainVerticalBox);
}
}
Alexandru Somai
  • 1,395
  • 1
  • 7
  • 16
Near013
  • 1
  • 1
  • which part of your code throws an error? what is the exact error? the code you show now won't even compile, how does that first method look like? – Stultuske Feb 27 '20 at 08:45
  • The error says, "JLabel is not a statement" for all of the JLabel classes. – Near013 Feb 27 '20 at 08:59

1 Answers1

3

It's not about the JLabel class. It is about the variable names. In java variable names can't start with numbers. That is why your code fails.

Source:

EDIT:

And definitly check that you are writing the variable names correct when reusing variables.

XtremeBaumer
  • 6,275
  • 3
  • 19
  • 65