Hello everyone,
As you can see this is my first post and i was just wondering how you set up a JFrame with contained components.
Basically i want to have them in this order:
Canvas BELONGS TO: DesktopFrame (JInternalFrame).
JInternalFrame (ifrmTools) BELONGS TO: DesktopFrame (JInternalFrame).
DesktopFrame (JInternalFrame) BELONGS TO: dpDesktop (DesktopPane).
dpDesktop (DesktopPane) BELONGS TO: frmMain (JFrame).
But if you didnt understand that then i will try to break it down.
Basically i want to have a JFrame, that on it, has a canvas and an internal frame called ifrmTools. I want the Tools frame (internal frame) to float over the canvas so they can pick a tool to draw on the canvas with. Like a simple PAINT program.
Here is my issue, i have code, but it wont show the InternalFrame that is called 'ifrmTools' however it shows the Canvas.
Below is my code:
And obviously the main class calls this with a simple:Code:import java.awt.Canvas;
import java.awt.Color;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
public class Create {
private double currentVersion = 1.0;
public JFrame frmMain = new JFrame("Welcome " + currentVersion);
public JDesktopPane dpDesktop = new JDesktopPane();
public JInternalFrame ifrmDesktop = new JInternalFrame();
public JInternalFrame ifrmTools = new JInternalFrame("Tools");
public Canvas cCanvas = new Canvas();
public void createAll() {
createAndAddCanvas();
createAndAddToolsFrame();
createAndAddDesktopFrame();
createAndAddDesktopPane();
createAndAddMainFrame();
}
public void createAndAddCanvas() {
cCanvas.setBackground(Color.WHITE);
ifrmDesktop.add(cCanvas);
}
public void createAndAddToolsFrame() {
ifrmTools.setResizable(false);
ifrmTools.setBounds(10, 10, 105, 250);
ifrmTools.setVisible(true);
ifrmDesktop.add(ifrmTools);
}
public void createAndAddDesktopFrame() {
ifrmDesktop.setResizable(false);
ifrmDesktop.setBorder(null);
ifrmDesktop.setClosable(false);
ifrmDesktop.setMaximizable(true);
ifrmDesktop.setVisible(true);
dpDesktop.add(ifrmDesktop);
}
public void createAndAddDesktopPane() {
dpDesktop.setVisible(true);
frmMain.add(dpDesktop);
}
public void createAndAddMainFrame() {
frmMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmMain.setSize(800, 600);
frmMain.setLocation(100, 100);
frmMain.setVisible(true);
}
}
Thanks in advance,Code:public class Main {
public static void main(String[] args) {
Create c = new Create();
c.createAll();
}
}
Pencil.

