-
Stacking JPanels
Attempting to stack JPanels to make many layers.
The problem is the JPanels print out right each other, and will not stack.
Code:
package core;
import java.awt.*;
import javax.swing.*;
public class Client extends JApplet{
Container contentPane = this.getContentPane();
JComponent GraphicsControl = new GraphicsHandler();
public void init(){
try{
javax.swing.SwingUtilities.invokeAndWait(new Runnable(){
public void run(){
createGUI();
}});
}catch (Exception e){}
}
public void start(){
}
public void stop(){
}
public void destroy(){
}
private void createGUI(){
this.getContentPane().add(GraphicsControl);
}
}
Code:
package core;
import java.awt.*;
import javax.swing.*;
import interfaces.*;
import layers.*;
public class GraphicsHandler extends JPanel{
Main MainInterface = new Main();
Status StatusInterface = new Status();
public GraphicsHandler(){
this.add(MainInterface);
this.add(StatusInterface);
this.setBackground(Color.black);
}
}
Code:
package interfaces;
import java.awt.*;
import javax.swing.*;
public class Main extends JPanel{
public Main(){
this.setBackground(Color.red);
this.setPreferredSize(new Dimension(100,100));
}
}
-
Re: Stacking JPanels
-
Re: Stacking JPanels
Z stacking would be better.
-
Re: Stacking JPanels
Read up on JLayeredPane and/or JTabbedPane.
db
-
Re: Stacking JPanels
Got it to work instead of JLayeredPane I put JLayerPane, would of had it done a couple days ago.