...
> Imagine you have a frame called F1 with only one JButton.
> ...
> > Imagine you have a frame called F1 with only one JButton.
[quoted text clipped - 19 lines]
> --
> Andrew Thompson
Hi my professor ;o)
Is it possible to add a JComboBox with a JDialog ? Because in reality in my
app, the frame contains a JComboBox and the user select a Item and then
click on the button wich send me the value.
Thx for your answer :o) (I didn't post anywhere else this time :o) )
Andrew Thompson - 24 Feb 2004 01:28 GMT
>> ...
>>> Imagine you have a frame called F1 with only one JButton.
>>
>> Sounds like a job for a JDialog
...
> Is it possible to add a JComboBox with a JDialog ?
JDialog.getContentPane().add( Component c )
Since JComboBoxes and JPanels, JButtons..
are sub-classed from Component, any one,
or combination of them, can be added.
If you needed to, you could have a textfield,
two combo boxes, a list and a handful of
buttons all in a single panel that you add
to the dialog.
You can either return a single value when
the dialog is closed, or hand it a combination
of controls (like above) that you can examine
after it is closed.
>..(I didn't post anywhere else this time :o) )
Nice work. :-)
--
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
Adam - 24 Feb 2004 07:33 GMT
> > > Imagine you have a frame called F1 with only one JButton.
> >
[quoted text clipped - 7 lines]
> > > System.out.println(res);
> > > }
[cut]
> Is it possible to add a JComboBox with a JDialog ? Because in reality in my
> app, the frame contains a JComboBox and the user select a Item and then
> click on the button wich send me the value.
If you don't need anything more than a combo box, use JOptionPane:
<code>
import javax.swing.*;
public class Input
{
public static void main(String[] args)
{
Integer[] possibleValues = new Integer[]{new Integer(1), new
Integer(2), new Integer(3)};
Object selectedValue = JOptionPane.showInputDialog(null,
"Choose a number",
"Input",
JOptionPane.INFORMATION_MESSAGE,
null,
possibleValues,
possibleValues[0]);
System.out.println("You have selected "+selectedValue);
}
}
</code>
Adam
Jean-Philippe Martin - 29 Feb 2004 17:40 GMT
> <code>
> import javax.swing.*;
[quoted text clipped - 17 lines]
>
> Adam
Thx Adam, I've found a solution but yours is easier. Its was perfectly what
I was searching for.
ps: It's my first "middle" software with GUI, I didn't know all the main
class yet.