View Single Post
Join Date: Mar 2008
Posts: 6
Reputation: hrlygrl923 is an unknown quantity at this point 
Solved Threads: 0
hrlygrl923 hrlygrl923 is offline Offline
Newbie Poster

Re: need help with jbutton and new jframe

 
0
  #5
Mar 12th, 2008
It compliles and runs but does not do anything when i click on the button




import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.text.DecimalFormat;
import java.io.*;
import javax.swing.JOptionPane;
import java.lang.*;
import java.math.*;

public class last_try implements ActionListener
{

public static void main(String[] args)
{

JFrame f = new JFrame("What would you like to do");
f.setSize(400, 150);
Container content = f.getContentPane();
content.setBackground(Color.white);
content.setLayout(new FlowLayout());


JButton button1 = new JButton("Button 1");
JButton button2 = new JButton("Button 2");
JButton button3 = new JButton("Button 3");

Container contentPane = f.getContentPane();
contentPane.setLayout(new FlowLayout());
contentPane.add(button1);
contentPane.add(button2);
contentPane.add(button3);


f.addWindowListener(new ExitListener());
f.setVisible(true);
}

public void popUp()
{
JFrame frame = new JFrame("aName");
frame.setSize(500, 500);
frame.setVisible(true);

}


public void actionPerformed(ActionEvent event)
{

if (event.getSource() == "Button 1")
{
JOptionPane.showMessageDialog(null, "Your entry was not in the proper format.");
}

}
}
Reply With Quote