Results 1 to 3 of 3
Thread: Hi, need some urgent help!
- 04-16-2008, 09:39 PM #1
Member
- Join Date
- Apr 2008
- Posts
- 1
- Rep Power
- 0
Hi, need some urgent help!
Hi!
I'm converting an application which was initally text based to one with a GUI.
I'm encountering a few problems and wondered if anyone could help.
I cannot figure out how to create an instance of museum.Java Code:package airshipMuseum; import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; /** * This code was edited or generated using CloudGarden's Jigloo * SWT/Swing GUI Builder, which is free for non-commercial * use. If Jigloo is being used commercially (ie, by a corporation, * company or business for any purpose whatever) then you * should purchase a license for each developer using Jigloo. * Please visit www.cloudgarden.com for details. * Use of Jigloo implies acceptance of these licensing terms. * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. */ /** * Airship museum application - Stores information about airships stored in a * museum * * @author mn * @version 1.0 */ public class AirshipMuseumApplication extends javax.swing.JFrame { /** * Variable to store an instance of Museum */ private Museum museum; private JPanel jPanelButtonContainer; private JButton jButtonAdd; private JButton jButtonSearch; private JButton jButtonList; private JButton jButtonArchive; private JButton jButtonExhibit; private JButton jButtonDelete; // add a reference to this frame private JFrame mainWindow; /** * ID of the airship to be deleted, set to exhibit or to archive */ public int ID; /**public void run() { museum = new Museum(); // create an instance of Museum }*/ /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { new AirshipMuseumApplication(); SwingUtilities.invokeLater(new Runnable() { public void run() { AirshipMuseumApplication inst = new AirshipMuseumApplication(); inst.setLocationRelativeTo(null); inst.setVisible(true); //museum = new Museum(); //TODO fix: create instance of museum - CRITICAL! //TODO load persistent airships (invisible to user) } //new AirshipMuseumApplication().run(); }); } /** * AirshipMuseumApplication constructor * @param none */ public AirshipMuseumApplication() { super(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //TODO save airships from array to file mainWindow = this; initGUI(); } private void initGUI() { try { { this.setTitle("Airship Museum"); } { jPanelButtonContainer = new JPanel(); GridLayout jPanel1Layout = new GridLayout(2, 3); jPanel1Layout.setColumns(2); jPanel1Layout.setRows(3); jPanel1Layout.setHgap(20); jPanel1Layout.setVgap(20); getContentPane() .add(jPanelButtonContainer, BorderLayout.CENTER); jPanelButtonContainer.setLayout(jPanel1Layout); { jButtonAdd = new JButton(); jPanelButtonContainer.add(jButtonAdd); jButtonAdd.setText("Add Airship"); jButtonAdd .setPreferredSize(new java.awt.Dimension(233, 85)); jButtonAdd.setMnemonic(java.awt.event.KeyEvent.VK_A); jButtonAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // TODO add your code for jButtonAdd.actionPerformed AddAirshipDialog dialog = new AddAirshipDialog( mainWindow); } }); } { jButtonDelete = new JButton(); jPanelButtonContainer.add(jButtonDelete); jButtonDelete.setText("Delete Airship"); jButtonDelete.setMnemonic(java.awt.event.KeyEvent.VK_D); jButtonDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ID = Integer.parseInt( JOptionPane.showInputDialog("Enter ID of the airship you would like to delete: ")); int result = JOptionPane.showConfirmDialog(null, "Are you sure?"); switch (result){ case JOptionPane.OK_OPTION : // delete this airship museum.deleteAirship(ID); JOptionPane.showMessageDialog(null, "Airship successfully deleted"); break; case JOptionPane.CANCEL_OPTION : // do nothing break; } } } ); } { jButtonExhibit = new JButton(); jPanelButtonContainer.add(jButtonExhibit); jButtonExhibit.setText("Exhibit Airship"); jButtonExhibit.setMnemonic(java.awt.event.KeyEvent.VK_E); jButtonExhibit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ID = Integer.parseInt( JOptionPane.showInputDialog("Enter ID of the airship you would like to exhibit: ")); int result = JOptionPane.showConfirmDialog(null, "Are you sure?"); switch (result){ case JOptionPane.OK_OPTION : // exhibit this airship museum.exhibitAirship(ID); JOptionPane.showMessageDialog(null, "Airship successfully set to exhibit"); break; case JOptionPane.CANCEL_OPTION : // do nothing break; } } } ); } { jButtonArchive = new JButton(); jPanelButtonContainer.add(jButtonArchive); jButtonArchive.setText("Archive Airship"); jButtonArchive.setMnemonic(java.awt.event.KeyEvent.VK_R); jButtonArchive.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ID = Integer.parseInt( JOptionPane.showInputDialog("Enter ID of the airship you would like to archive: ")); int result = JOptionPane.showConfirmDialog(null, "Are you sure?"); switch (result){ case JOptionPane.OK_OPTION : // archive this airship museum.returnAirship(ID); JOptionPane.showMessageDialog(null, "Airship successfully archived"); break; case JOptionPane.CANCEL_OPTION : // do nothing break; } } } ); } { jButtonList = new JButton(); jPanelButtonContainer.add(jButtonList); jButtonList.setText("List Airships..."); jButtonList.setMnemonic(java.awt.event.KeyEvent.VK_L); jButtonList.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //TODO show list frame ListAirships JFrame = new ListAirships(); JFrame.setVisible(true); } }); } { jButtonSearch = new JButton(); jPanelButtonContainer.add(jButtonSearch); jButtonSearch.setText("Search Airships"); jButtonSearch.setMnemonic(java.awt.event.KeyEvent.VK_S); jButtonSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ID = Integer.parseInt( JOptionPane.showInputDialog("Enter the manufacturer of airship you would like to search: ")); //TODO show how many were found, open list //JOptionPane.showMessageDialog(null, "Airship successfully archived"); } } ); } } setSize(400, 300); } catch (Exception e) { e.printStackTrace(); } } }
Before, when it was text based I had this:
and this:Java Code:public static void main(String [] args) { new MuseumApplication().run(); } }
but now i'm using jigloo it's added all that other stuff which I don't understand!Java Code:public void run() { museum = new Museum(); }
Thankyou for looking
- 04-17-2008, 03:42 AM #2
Why are you invoking the AirshipMuseumApplication() twice?
Outside the Runnable and 1 inside?
And where is your Museum class?
regards,
sukatoa
- 04-18-2008, 06:50 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
Help me ...urgent!
By googgoo in forum New To JavaReplies: 7Last Post: 04-05-2008, 08:46 AM -
please help urgent
By ananas7777 in forum AWT / SwingReplies: 2Last Post: 12-25-2007, 08:30 AM -
NEED urgent help...
By bezdapez in forum New To JavaReplies: 7Last Post: 11-27-2007, 04:40 PM -
need urgent help...
By SCS17 in forum New To JavaReplies: 1Last Post: 11-13-2007, 07:52 AM -
Very Urgent
By Swamipsn in forum New To JavaReplies: 2Last Post: 08-01-2007, 01:56 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks