Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-2008, 10:39 PM
Member
 
Join Date: Apr 2008
Posts: 1
jdark is on a distinguished road
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.

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:

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

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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-17-2008, 04:42 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 508
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Why are you invoking the AirshipMuseumApplication() twice?
Outside the Runnable and 1 inside?

And where is your Museum class?

regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 07:50 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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. What are the things you can't understand?

Did you think twice about what sukatoa says in the previous post.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me ...urgent! googgoo New To Java 7 04-05-2008 09:46 AM
please help urgent ananas7777 AWT / Swing 2 12-25-2007 09:30 AM
NEED urgent help... bezdapez New To Java 7 11-27-2007 05:40 PM
need urgent help... SCS17 New To Java 1 11-13-2007 08:52 AM
Very Urgent Swamipsn New To Java 2 08-01-2007 02:56 PM


All times are GMT +3. The time now is 11:32 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org