Results 1 to 3 of 3
  1. #1
    jdark is offline Member
    Join Date
    Apr 2008
    Posts
    1
    Rep Power
    0

    Default 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.

    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();
    		}
    	}
    
    }
    I cannot figure out how to create an instance of museum.

    Before, when it was text based I had this:

    Java Code:
      public static void main(String [] args) {
        new MuseumApplication().run();
      }
    }
    and this:

    Java Code:
    public void run() {
        museum = new Museum();
    }
    but now i'm using jigloo it's added all that other stuff which I don't understand!


    Thankyou for looking

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Why are you invoking the AirshipMuseumApplication() twice?
    Outside the Runnable and 1 inside?

    And where is your Museum class?

    regards,
    sukatoa

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by jdark View Post
    but now i'm using jigloo it's added all that other stuff which I don't understand!
    What ever you use, the way you have to work with Java is not changed. :p What are the things you can't understand?

    Did you think twice about what sukatoa says in the previous post.

Similar Threads

  1. Help me ...urgent!
    By googgoo in forum New To Java
    Replies: 7
    Last Post: 04-05-2008, 08:46 AM
  2. please help urgent
    By ananas7777 in forum AWT / Swing
    Replies: 2
    Last Post: 12-25-2007, 08:30 AM
  3. NEED urgent help...
    By bezdapez in forum New To Java
    Replies: 7
    Last Post: 11-27-2007, 04:40 PM
  4. need urgent help...
    By SCS17 in forum New To Java
    Replies: 1
    Last Post: 11-13-2007, 07:52 AM
  5. Very Urgent
    By Swamipsn in forum New To Java
    Replies: 2
    Last Post: 08-01-2007, 01:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •