Results 1 to 2 of 2
  1. #1
    idkLOL123 is offline Member
    Join Date
    Sep 2015
    Posts
    1
    Rep Power
    0

    Post gui butoon,textbox, and other issueissue

    My gui menu has all of its button, text box in 1 line can some 1 help and tell me whats wrong?


    Java Code:
    package listener_p_2;
    
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
        
    
    
    public class AcrionListener_gui extends JFrame implements ActionListener {
            
            private JLabel enterName;
            private JTextField name;
            private JButton click;
            private String storeName = "";
            
              JMenuBar menubar;
              JMenu file;
              JMenuItem exit;
            public AcrionListener_gui(){
                setLayout(new FlowLayout());
               
                menubar = new JMenuBar();
                setJMenuBar (menubar);
                
                file= new JMenu("File");
                menubar.add(file);
                
                exit = new JMenuItem("Exit");
                file.add(exit);
                
                event e = new event();
                exit.addActionListener(e);
                setSize(600,500);
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                enterName = new JLabel("Enter Your name");
                click = new JButton("Click");
                name = new JTextField();
                enterName.setBounds(60, 100, 130, 40);
                name.setBounds(60, 160, 140, 40);
                click.setBounds(10,0, 60, 30);
                click.addActionListener(this);
                add(click);
                add(name);
                add(enterName);        
                        
            }
            @Override
            public void actionPerformed(ActionEvent e){
                if (e.getSource() == click){
                    storeName = name.getText();
                    JOptionPane.showMessageDialog(null, "Hello " + storeName);
                    System.exit(0);
                }
            }
    public class event implements ActionListener {
            public void actionPerformed(ActionEvent e){
                    System.exit(0);      
            }
    }
    
    public static void main(String[] args) {
        AcrionListener_gui gui= new AcrionListener_gui();
        gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gui.setSize(200, 200);
        gui.setVisible(true);
            }   
    }
    gui butoon,textbox, and other issueissue-idk.png

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: gui butoon,textbox, and other issueissue

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. JSP autofill textbox
    By _Nikkiz_ in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-11-2013, 09:14 PM
  2. Making a textbox
    By meesterpickles in forum New To Java
    Replies: 6
    Last Post: 07-19-2011, 12:40 AM
  3. How I can draw on textbox
    By iraqy2010 in forum CLDC and MIDP
    Replies: 0
    Last Post: 06-19-2011, 05:48 PM
  4. How to set value to a TextBox
    By kishan in forum JavaServer Faces (JSF)
    Replies: 3
    Last Post: 06-29-2010, 02:46 PM

Tags for this Thread

Posting Permissions

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