Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010
    Posts
    80
    Rep Power
    0

    Default Make the Button Work

    Hi

    I wrote this code to design the inteface

    The only thing that I would like to know how I can make the button works

    I have searched many times but I found a diffecult codes

    Can anyone help me

    Java Code:
    package swingPro;
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.event.*;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    
    public class Swing2 {
    	public static void main(String[]ags){
    		
    		JFrame frame = new JFrame();
    		FlowLayout lut = new FlowLayout();
    		
    		
    		frame.setVisible(true);
    		frame.setSize(500, 200);
    		frame.setTitle("Hello");
    		frame.setLayout(lut);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		
    		JLabel label = new JLabel();
    		frame.add(label);
    		label.setText("Enter the first number");
    		
    		
    		JTextField text = new JTextField(10);
    		frame.add(text,BorderLayout.CENTER);
    				
    		JButton button = new JButton("Press Here");
    		frame.add(button,BorderLayout.AFTER_LINE_ENDS);
    		button.setSize(60, 40);
    		
    		
    	}
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    The Sun tutorial on adding actionlisteners to buttons is pretty good, and I doubt that any of us can write a chapter here that would be better. So my main recommendation is for you to read (re-read?) it. If you still don't understand, please come back with a specific question on just what you don't understand and what code isn't working.

Similar Threads

  1. Replies: 3
    Last Post: 01-29-2012, 10:44 AM
  2. mysql connect button doesnt work quite right
    By 711groove in forum New To Java
    Replies: 0
    Last Post: 12-13-2009, 07:01 AM
  3. Cannot make Java6 update10 work
    By Sphacelaria in forum New To Java
    Replies: 5
    Last Post: 12-01-2008, 03:48 AM
  4. Can't make JTable work -- please help!!
    By cagalli83 in forum Advanced Java
    Replies: 0
    Last Post: 02-13-2008, 09:31 AM
  5. To make work DLL from webservices
    By Felissa in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 07:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •