This is a quick tutorial showing how quick and easy it is to start an MDI application project and add one JInternalFrame.
1. Start a 'New Project' and choose 'Java Application'.
2. Give you project a name and a location.
3. From 'Source Packages' create a 'New - MDI Application'.
4. I have added a JToolBar and a JButton.
5. Create a 'New - JInternalFrame Form'.
6. Here you are ready to use the Matisse GUI Builder to design the JInternalFrame.
7. I have added a JToolBar and a JButton, with some sample form elements.
8. On the JDesktopPane I am adding an Event to open the JInternalFrame.
9. I have added the following code to the btnOpenIFrameActionPerformed method of the MDI Frame to open the JInternalFrame.
private void btnOpenIFrameActionPerformed(java.awt.event.ActionEvent evt) { IfrmMyIFrame frm = new IfrmMyIFrame(); int width = 400; int height = 300; frm.setSize(width, height); frm.setVisible(true); desktopPane.add(frm); } |
10. I have added the following to the constructor of the IfrmMyIFrame class.
super("My little JInternalFrame",true,true,true,true); setLocation(50, 50); |
11. I have added the following code to the btnHelloWorldActionPerformed method
private void btHelloWorldActionPerformed(java.awt.event.ActionEvent evt) { JOptionPane.showMessageDialog(null, "Hello World!", "Message", JOptionPane.INFORMATION_MESSAGE); } |
In Summary, you can quickly create an MDI application, use the Matisse GUI Builder to do what you like with the main JDesktopPane, then create individual JInternalFrame which you can in-turn use the Matisse GUI Builder to layout and do what you like with as well. Pretty cool stuff.
Matt
0 comments:
Post a Comment