Results 1 to 5 of 5
Thread: This shouldn't be too hard.
- 05-10-2013, 04:16 PM #1
This shouldn't be too hard.
so yes, i listened to you guys and read through the whole API documentation for the JOptionPane.
i found how to add components to it, Jrmonkey97 (or something) already told me to do it that way but i didn't listen..
well i made an object like:
Java Code:label4 = new JLabel("Check this out"); label5 = new JLable("I dont know how to add this label"); object[] test = {label4, label5}; JOptionPane.showMessageDialog(null, test[0], "Log in", JOptionPane.INFORMATION_MESSAGE);
Java Code:JOptionPane.showMessageDialog(null, test[0], test[1], "log in" , JOptionPane.INFORMATION_MESSAGE);
The method showMessageDialog(Component, Object, String, int, Icon) in the type JOptionPane is not applicable for the arguments (null, Object, Object, String, int)
so yeah, if anyone would be able to tell me how to add more components from that array in a JOptionpane, that would be amazing! :)
thanks in advance
- 05-10-2013, 04:46 PM #2
Re: This shouldn't be too hard.
What exactly are you trying to do? Are you looking to implement a login, with username and password?
- 05-10-2013, 04:48 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,421
- Blog Entries
- 7
- Rep Power
- 26
Re: This shouldn't be too hard.
Straight from the API documentation:
messageA descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type:
Object[]An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.
ComponentThe Component is displayed in the dialog.
IconThe Icon is wrapped in a JLabel and displayed in the dialog.
othersThe object is converted to a String by calling its toString method. The result is wrapped in a JLabel and displayed.
JosBuild a wall around Donald Trump; I'll pay for it.
- 05-10-2013, 05:13 PM #4
Senior Member
- Join Date
- Nov 2012
- Posts
- 257
- Rep Power
- 6
Re: This shouldn't be too hard.
You dont need to specify and index, just pass the array in and it will recursively go through the array.
Java Code:JOptionPane.showMessageDialog(null, test[0], test[1], "log in" , JOptionPane.INFORMATION_MESSAGE); //becomes: JOptionPane.showMessageDialog(null, test, "log in" , JOptionPane.INFORMATION_MESSAGE);
- 05-10-2013, 05:20 PM #5
Similar Threads
-
This ap course is so hard :(((
By Army in forum New To JavaReplies: 22Last Post: 01-10-2013, 01:27 PM -
Creating a new Shell. The parent Shell shouldn't lose the focus ...
By anouri in forum SWT / JFaceReplies: 1Last Post: 10-10-2011, 04:51 PM -
Final variables shouldn't also be static?
By emilioJazz in forum Advanced JavaReplies: 5Last Post: 11-29-2010, 11:10 AM -
How hard is it.....
By neilp123 in forum New To JavaReplies: 4Last Post: 07-22-2010, 04:21 PM
Bookmarks