JDialog from JFrame button (GUI)
Hi
So I aim to make a GUI with 9 buttons, each one opening up a new window (JDialog) with input fields/tickboxes etc...
My code so far opens up a new Jdialog but does not display my added components (JTextFields) I cannot see why. My JDialog is just blank.
Any ideas?
Code :
public void actionPerformed(ActionEvent e) {
Object s = e.getSource();
if (s == addHose) {
// JDIalog
JTextArea addOwner, addNumberOfSections, addBore, addUsage, addLength;
JRadioButton addHasTapAttachment, addHasJet, addIsOnDisplay;
// buttons
JButton btnOK, btnCancel;
// variables representing user input
String owner, numberOfSections, bore, usage, length;
AccessibleContext hasTapAttachment;
AccessibleContext hasJet;
AccessibleContext isOnDisplay;
JPanel main, addHosePanel;
JDialog addHoseD = new JDialog();
addHoseD.setLayout(new FlowLayout());
addOwner = new JTextArea();
addHoseD.add(addOwner);
owner = addOwner.getText();
addNumberOfSections = new JTextArea();
addHoseD.add(addNumberOfSections);
numberOfSections = addNumberOfSections.getText();
addBore = new JTextArea();
addHoseD.add(addBore);
bore = addBore.getText();
addUsage = new JTextArea();
addHoseD.add(addUsage);
usage = addUsage.getText();
addLength = new JTextArea();
addHoseD.add(addLength);
length = addLength.getText();
addHoseD.setTitle("Add Hose");
addHoseD.setModal(true);
addHoseD.setSize(250, 300);
addHoseD.setVisible(true);
Re: JDialog from JFrame button (GUI)
To see what is happening change this line:
addNumberOfSections = new JTextArea("nbr of Sect");
or add this line:
addHoseD.add(new JButton("Press me")); //<<<<<<
Re: JDialog from JFrame button (GUI)
Right, ok.
I've added that code and it looks like this:
http://i39.tinypic.com/do6gox.png
The text areas will just be attributes to my object (the hose) that the user will fill in.