I have no idea how to do this and have spent 2 days researching the Java APIs and on these forums and I have found nothing, if someone could please tell me how to use action listener to do so that would be great, most everything I have found has been for JUST a button and not with a bunch of other stuff. Here is my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Skeleton extends JFrame implements ActionListener{
public static void addComponentsToPane(Container pane) {
pane.setLayout(null);
JButton b1 = new JButton("Login");
JTextField field2 = new JTextField(2);
JTextField field = new JTextField(1);
pane.add(field);
pane.add(field2);
pane.add(b1);
Insets insets = pane.getInsets();
Dimension size = field.getMaximumSize();
field.setBounds(25 + insets.left, 5 + insets.top,
200, 20);
size = field2.getPreferredSize();
field2.setBounds(25 + insets.left, 40 + insets.top,
200, 20);
size = b1.getPreferredSize();
b1.setBounds(75 + insets.left, 75 + insets.top, 100, 40);
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("User Login"); // GUI gui = new GUI() as well
// default value JFrame.HIDE_ON_CLOSE
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
addComponentsToPane(frame.getContentPane());
//Create the menu bar. Make it have a Blue background.
JMenuBar blueMenuBar = new JMenuBar();
blueMenuBar.setOpaque(true);
blueMenuBar.setBackground(new Color(211, 221, 222));
blueMenuBar.setPreferredSize(new Dimension(300, 20));
//Create a grey label to put in the content pane.
JLabel greyLabel = new JLabel();
greyLabel.setOpaque(true);
greyLabel.setBackground(new Color(205, 209, 209));
greyLabel.setPreferredSize(new Dimension(300, 400));
//Adding a custom BorderLayout
JPanel panel = new JPanel(new BorderLayout());
Container contentPane = frame.getContentPane();
//Set the menu bar and add the label to the content pane.
frame.setJMenuBar(blueMenuBar);
frame.getContentPane().add(greyLabel, BorderLayout.CENTER);
//Display the window.
frame.setSize(300, 200);
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}