Go Back   nV News Forums > Software Forums > Software Development

Newegg Daily Deals

Reply
 
Thread Tools
Old 01-25-07, 11:31 PM   #13
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Quote:
Originally Posted by Tuork
I can actually hold my ground pretty well in Java.

What's your problem with JOptionPane?
Well this is my first time using it and I'm basically self teaching myself. I'm required to use it over the Scanner class and so far I'm coming along. However right now I have an ArrayList with bank customers that I want to print but no luck so far.

Is there like an easy method or something in JOption that allows this?
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-25-07, 11:42 PM   #14
rhink
Registered User
 
Join Date: Jul 2005
Posts: 434
Default Re: Sigh, Java HW Help

JOptionPane.showMessageDialog(null,"stuff!");

replace "stuff" with a string object, or an object that has overriden object.toString(), so it actually prints something useful.
rhink is offline   Reply With Quote
Old 01-25-07, 11:54 PM   #15
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Gah, my head is a bowl of mush right now. I keep reading the same lines over and over. I'm going to leave that part for the morning since this isn't due till tomorrow midnight.

Thanks for the responses. I'll try those suggestions and let you guys know how it goes.
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-26-07, 09:16 AM   #16
Tuork
Official pain in the ass
 
Tuork's Avatar
 
Join Date: May 2003
Location: 127.0.0.1
Posts: 1,197
Send a message via MSN to Tuork
Default Re: Sigh, Java HW Help

Go over to the API and check out the different variations on how to use JOptionPane.

the .showMessageDialogue(...) methos mentioned by rhink is the obvious choice.

You can also print out the info as an actual table, but that's a little more complicated as far as I remember.
__________________
My avatar: "An obscure and non sensical pattern made to get people to post what they think it is" - Vamp

Dimitri:
Dell XPS M1530
Core2Duo T5550 1.86Ghz | 3GB DDR2 | 8600M GT 256MB | 250GB Hdd | BenQ FP202W 20" LCD | MX1000 mouse | Inspire T5400 5.1
Tuork is offline   Reply With Quote
Old 01-26-07, 11:25 AM   #17
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Okay so I created toString methods for my Name, Address and BankAccount classes that hold the various info pertaining their respective classes.

I'm thinking I should create another one in the Customer class that calls the toString from those three so when I need to display it in the test class I only call the toString from class Customer. If any one sees a problem with that speak up, please.

How would I display all the info for each object on the list now?
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-26-07, 06:07 PM   #18
rhink
Registered User
 
Join Date: Jul 2005
Posts: 434
Default Re: Sigh, Java HW Help

Quote:
Originally Posted by Tuork
Go over to the API and check out the different variations on how to use JOptionPane.

the .showMessageDialogue(...) methos mentioned by rhink is the obvious choice.

You can also print out the info as an actual table, but that's a little more complicated as far as I remember.
Heh JTables can be a real pain in the ass, though this would be a relatively simple application of them. Swing is the worst part of working with java, imo. Extremely flexible, can do a lot with it, but it's also very complex if you do more than scratch the surface, and can be slow.

Marvel, you could certainly create a toString in your customer class that concatenated everything in the objects contained within.

As far as displaying them all.... well, you could pop up a new dialog using joptionpane for every single one, but that would require the user to click through each and every one. If you don't have a requirement to use a GUI, it's very straightforward just to iterate through a loop and do a System.out for each record you want to print. JTables would be a nice, neat way to list them, but they can be difficult to work with. Could also use a JTextArea. It really depends on what you're most familiar with, and exactly what the requirements for this project are.
rhink is offline   Reply With Quote
Old 01-26-07, 06:23 PM   #19
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Quote:
Originally Posted by rhink
Heh JTables can be a real pain in the ass, though this would be a relatively simple application of them. Swing is the worst part of working with java, imo. Extremely flexible, can do a lot with it, but it's also very complex if you do more than scratch the surface, and can be slow.

Marvel, you could certainly create a toString in your customer class that concatenated everything in the objects contained within.

As far as displaying them all.... well, you could pop up a new dialog using joptionpane for every single one, but that would require the user to click through each and every one. If you don't have a requirement to use a GUI, it's very straightforward just to iterate through a loop and do a System.out for each record you want to print. JTables would be a nice, neat way to list them, but they can be difficult to work with. Could also use a JTextArea. It really depends on what you're most familiar with, and exactly what the requirements for this project are.
I've got the toString methods and right now it's currently looping through the items on the list but like you said the user has to click through every item. There's nothing in my assignment objective that doesn't allow that but I think it sucks to have to click through.

How would you recommend displaying everything at once using a scroll window with joptionpane?
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-26-07, 07:03 PM   #20
rhink
Registered User
 
Join Date: Jul 2005
Posts: 434
Default Re: Sigh, Java HW Help

JOptionPanes just make dialogs. I suppose you could insert line breaks and put everything in one big frickin string and output it all into a single window, but I don't think there's a way to make it scrollable. You'd need another control for that, which means you'd have to create a window for your application and learn how to use a little bit of swing or awt.
rhink is offline   Reply With Quote

Old 01-26-07, 07:20 PM   #21
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Is that like the Jtextarea and jscrollpane?
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-26-07, 07:34 PM   #22
rhink
Registered User
 
Join Date: Jul 2005
Posts: 434
Default Re: Sigh, Java HW Help

Yup.
rhink is offline   Reply With Quote
Old 01-26-07, 08:00 PM   #23
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Quote:
Originally Posted by rhink
Yup.
Ah cool, I somewhat know how to use those.

This is the method I created for the Bank database class which basically runs through the list and creates a display for every object. However this method creates a display for every object and requires the user to click through. Can't figure out how to just join everything up though.

Quote:
public void DisplayList()
{
for(int i = 0; i < accounts.size(); i++)
{
Customer c = accounts.get( i ) ;

String s = c.toStringCustomer() ;

JTextArea text = new JTextArea(s, 40, 40);
JScrollPane pane = new JScrollPane(text);


JOptionPane.showMessageDialog(null, pane, "Account Information",
JOptionPane.INFORMATION_MESSAGE);
}

}
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-26-07, 08:17 PM   #24
rhink
Registered User
 
Join Date: Jul 2005
Posts: 434
Default Re: Sigh, Java HW Help

If you want to display everything at once, just concatenate the customer strings into one long one before creating the JOptionPane.
rhink is offline   Reply With Quote
Reply


Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Diablo 3 hotfix removes monster damage boost in co-op, Inferno teams breathe sigh of News Archived News Items 0 06-11-12 01:20 PM
Google (partially) loses suit to Oracle over use of Java API's ViN86 Mobile Devices And Smartphones 3 05-17-12 10:25 AM
Judge Declines To Rule That Google Pillaged Java News Archived News Items 0 05-10-12 07:00 AM
BAH! I'm being driven insane by Java Virtual Machine Kruno General Software 9 09-01-02 09:59 PM

All times are GMT -5. The time now is 11:50 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.