tags:

views:

51

answers:

2

Hi I want to have a frame that it has 9 planes with red and blue and green color and I set the frame as a borderlayout manager but it doesn't show anything.please help me.thanks (the LightsNPlanesApp is correct and can be run correctly but the MainFrame is not correct because it doesn't show anything)

The MainFrame:(just the main method)

public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            MainFrame frame = new MainFrame();

            addComponentsToPane(frame.getContentPane());

            frame.pack();
            frame.setVisible(true);
        }

        private void addComponentsToPane(Container pane) {

            pane.add(new LightsNPlanesApp(), BorderLayout.PAGE_START);
            pane.add(new LightsNPlanesApp(), BorderLayout.CENTER);
            pane.add(new LightsNPlanesApp(), BorderLayout.PAGE_END);

        }
    });
}
+1  A: 
add("Center", canvas3D);

... is obsolete / wrong and should be replaced with:

add(canvas3D, BorderLayout.CENTER);
Adamski
the frame doesn't show anything yet[:-(]thanks
Johanna
A: 

How does the code you posted compile? Did you bother to listen to my suggestion about starting with simple code? Is the problem with your custom JPanel or all JPanel'?

Why don't you try adding 3 JPanels each with a different background color and see if that works first. Of course if won't work, but once you figure out that problem, then maybe you can use the same solution on your other class.

Of course because you haven't posted a proper SSCCE, I'm just guessing which is why I'm not giving your what I think the solution is outright. If you are going to make use guess what the code thats causing the problem is like, then you will need to guess the solution as well given the hints provided. And again a SSCCE does not mean you include the full code from your custom panel, it means you post simple code that simulates the problem.

camickr