panes, frames and ddm's :|
Hey,
So here is something i put together a long time ago, i'm sure a few may recognise some of the code being from java sun no doubt.
A little background, basically having been into R/C modeling heavily for many years in the past (R/C helis) and having a million different bits here and there I figured a program to keep track of all the bits would be a fun project.
Quiet simply everything would be inputted into an sql database (still have to make that bit) and then it can be displayed and browsed via this browser thing i'm trying to put together!
My main question is how would i get this window to bring up an interface relevant to the selection from the drop down menu, within the empty frame below the menu?
My thinking is an action listener would catch the selection which would then alter a variable which would determine the table in sql data would be brought up from but how, and here's were i need some direction, would i get the user interface to pop up?
There are only likely to be a few different configurations to display the information (4-6) so i would only need a few different windows to bring up, eveything else would be dependant on the data brought up.
Code:
package Program;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.ButtonGroup;
import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JFrame;
public class main
{
static String where;
JTextArea output;
JScrollPane scrollPane;
public JMenuBar createMenuBar() {
JMenuBar menuBar;
JMenu menu, submenu;
JMenuItem menuItem;
JRadioButtonMenuItem rbMenuItem;
JCheckBoxMenuItem cbMenuItem;
//Create the menu bar.
menuBar = new JMenuBar();
//Build the first menu.
menu = new JMenu("Airframes");
menu.setMnemonic(KeyEvent.VK_A);
menuBar.add(menu);
//a group of JMenuItems
menuItem = new JMenuItem("Helicopters");
menu.add(menuItem);
menuItem = new JMenuItem("Aeroplanes");
menu.add(menuItem);
//Build second menu in the menu bar.
menu = new JMenu("Engines");
menuBar.add(menu);
//a group of JMenuItems
menuItem = new JMenuItem("Helicopters");
menu.add(menuItem);
menuItem = new JMenuItem("Aeroplanes");
menu.add(menuItem);
//Build second menu in the menu bar.
menu = new JMenu("Electronics");
menuBar.add(menu);
//a group of JMenuItems
menuItem = new JMenuItem("Recivers");
menu.add(menuItem);
menuItem = new JMenuItem("Servos");
menu.add(menuItem);
menuItem = new JMenuItem("Gyros");
menu.add(menuItem);
menuItem = new JMenuItem("Govners");
menu.add(menuItem);
menuItem = new JMenuItem("Misc");
menu.add(menuItem);
return menuBar;
}
public Container createContentPane() {
//Create the content-pane-to-be.
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setOpaque(true);
//Create a scrolled text area.
output = new JTextArea(5, 30);
output.setEditable(false);
scrollPane = new JScrollPane(output);
//Add the text area to the content pane.
contentPane.add(scrollPane, BorderLayout.CENTER);
return contentPane;
}
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
static void createAndShowGUI() {
//Create and set up the window.
where = location.where;
JFrame frame = new JFrame("Thingys in " + where);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
main myMain = new main();
frame.setJMenuBar(myMain.createMenuBar());
frame.setContentPane(myMain.createContentPane());
//Display the window.
frame.setSize(450, 260);
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
Any thoughts, criticism, advice and guidence would be much appreciated :)
Best regards
-Chris Jvr