Help me.....i'm tryin to figure out how to link to another java class using a button but i falied to do so...kindly assist me....thanks
public Login() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,400);
java.awt.Container contents = getContentPane();
contents.setLayout(null);
setTitle("Air-Malaysia");
contents.setLayout(null );
contents.setBackground(Color.black);
contents.setForeground(Color.orange);
am.setFont(f1);
usrnm.setFont(f2);
clk.setFont(f2);
clk.setBackground(Color.black);
clk.setForeground(Color.orange);
btnOk.setBackground(Color.black);
btnOk.setForeground(Color.orange);
btnCancel.setBackground(Color.black);
btnCancel.setForeground(Color.orange);
usrnm.setForeground(Color.orange);
pswrd.setForeground(Color.orange);
nwm.setForeground(Color.orange);
am.setForeground(Color.orange);
am.setLocation(100,0);
am.setSize(150,150);
contents.add(am);
usrnm.setLocation(20,100);
usrnm.setSize(120,25);
add(usrnm);
txtname.setLocation(100,100);
txtname.setSize(120,25);
add(txtname);
pswrd.setLocation(20,150);
pswrd.setSize(120,25);
add(pswrd);
txtpswrd.setLocation(100,150);
txtpswrd.setSize(120,25);
add(txtpswrd);
nwm.setLocation(20,200);
nwm.setSize(120,25);
add(nwm);
clk.setLocation(200,200);
clk.setSize(120,25);
add(clk);
btnOk.setLocation(20,250);
btnOk.setSize(120,25);
add(btnOk);
btnCancel.setLocation(200,250);
btnCancel.setSize(120,25);
add(btnCancel);
btnOk.addActionListener(this);
btnCancel.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==btnOk)
{
JOptionPane.showMessageDialog(null, "Welcome Mr/Ms " + txtname.getText());
OptionWindow option = new OptionWindow();
setPreferredSize(new Dimension(400,400));
add(option);
}
if(e.getSource()==btnCancel)
JOptionPane.showMessageDialog(null, "Thank You for using Air-Malaysia Online");
System.exit(0);
}
package oopassignment;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.awt.*;
import java.lang.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class OptionWindow extends JFrame implements ActionListener {
JButton btnexit = new JButton("Logout");
JButton b1 = new JButton("Customer Profile");
JButton b2 = new JButton("Flight Information");
JButton b3 = new JButton("Reservation");
public OptionWindow() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,400);
java.awt.Container contents = getContentPane();
contents.setLayout(null);
setTitle("Air-Malaysia");
contents.setLayout(null );
contents.setBackground(Color.black);
contents.setForeground(Color.orange);
b1.setBackground(Color.black);
b1.setForeground(Color.orange);
b2.setBackground(Color.black);
b2.setForeground(Color.orange);
b3.setBackground(Color.black);
b3.setForeground(Color.orange);
btnexit.setBackground(Color.red);
btnexit.setForeground(Color.white);
btnexit.setLocation(280,0);
btnexit.setSize(80,25);
add(btnexit);
b1.setLocation(110,170);
b1.setSize(170,25);
add(b1);
b2.setLocation(110,220);
b2.setSize(170,25);
add(b2);
b3.setLocation(110,270);
b3.setSize(170,25);
add(b3);
}
public void actionPerformed(ActionEvent e){
}
public static void main(String[] args) {
new OptionWindow();
}// TODO overwrite start(), stop() and destroy() methods
}