Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By doWhile

Thread: how to make the check button get user input and display it

  1. #1
    ashraf is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default how to make the check button get user input and display it

    import javax.swing.*;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    public class MyFrame extends JFrame
    {
    private JLabel text1,text2,text3;
    private JTextField tf,tf2;
    private JButton btn;
    private JPanel p1,p2,p3;

    public static void main (String[]args)
    {
    MyFrame fr=new MyFrame("Check Your DOB");
    fr.setSize(300,200);
    fr.setVisible(true);
    fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
    public MyFrame(String t)
    {
    setTitle(t);
    setLayout(new FlowLayout(FlowLayout.CENTER));

    text1=new JLabel("Name:");
    tf=new JTextField(15);
    text2=new JLabel("\nEnter First 6 Digit of Your IC Number:");
    tf2=new JTextField(15);
    btn=new JButton("Check");
    btn.addActionListener(new ButtonListener());
    text3=new JLabel("Click the button");


    p1=new JPanel();
    p1.add(text1);
    p1.add(tf);


    p2=new JPanel();
    p2.add(text2);
    p2.add(tf2);

    p3=new JPanel();
    p3.add(btn);
    p3.add(text3);


    add(p1);
    add(p2);
    add(p3);

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: how to make the check button get user input and display it

    I encourage you to write a more thorough and precise question as to what you want, as well as wrap your code in code tags. I for one have no clue what you are asking (and presume I'm not the only one, but you never know).
    Fubarable likes this.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: how to make the check button get user input and display it

    This was suggested to you in your other thread -- that you learn how to ask answerable questions -- advice that you've seemed to have ignored.

Similar Threads

  1. Replies: 3
    Last Post: 09-14-2011, 09:07 PM
  2. Replies: 14
    Last Post: 09-13-2011, 12:54 AM
  3. How do I check if user clicks on an image?
    By rajkobie in forum New To Java
    Replies: 10
    Last Post: 05-04-2011, 05:45 AM
  4. Make a button class that uses your button image.
    By eLancaster in forum New To Java
    Replies: 1
    Last Post: 04-26-2011, 12:32 PM
  5. Replies: 1
    Last Post: 10-18-2010, 08:14 AM

Posting Permissions

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