help with GUI
I'm new to java and i have to create a GUI.
So far i have created a GUI with 2 buttons on it. one which opens a file (which works fine) and the other called parameters (which doesn't)
When the user presses the parameter button i want a screen to pop up which will allow the user to enter some parameters and when pressed ok these parameters are saved for use later on.
i really don't know where to start with this.
my code so far is:
public class RunPanel extends JPanel implements ActionListener
{
JButton openButton, setParametersButton;
static private final String newline = "\n";
JTextArea log;
JFileChooser fc;
public RunPanel()
{
super(new BorderLayout());
log = new JTextArea(5,20);
log.setMargin(new Insets(5,5,5,5));
log.setEditable(false);
JScrollPane logScrollPane = new JScrollPane(log);
fc = new JFileChooser();
openButton = new JButton("Open a File...",
createImageIcon("images/Open16.gif"));
openButton.addActionListener(this);
setParametersButton = new JButton("Set User Parameters");
setParametersButton.addActionListener(this);
JPanel buttonPanel = new JPanel(); //use FlowLayout
buttonPanel.add(openButton);
buttonPanel.add(setParametersButton);
add(buttonPanel, BorderLayout.PAGE_START);
add(logScrollPane, BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == openButton) {
int returnVal = fc.showOpenDialog(RunPanel.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
log.append("Opening: " + file.getName() + "." + newline);
} else {
log.append("Open command cancelled by user." + newline);
}
log.setCaretPosition(log.getDocument().getLength());
}
else
{
if (e.getSource() == setParametersButton)
{
//this is where i want a new panel to pop up with options for user to input parameters
}
}
}
private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("AIRS");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent newContentPane = new RunPanel();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
Can anybody suggest a way for me to do this?
Thankyou

