Results 1 to 6 of 6

Thread: j button

  1. #1
    abby is offline Member
    Join Date
    Apr 2013
    Posts
    10
    Rep Power
    0

    Default j button

    the button I ANGLED have the pleasure to appear as they want!!
    the problems that ther is no error message !
    If this problem occurs during myworck it will not be cool!
    help !!

  2. #2
    Prime624 is offline Member
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    96
    Rep Power
    0

    Default Re: j button

    Can you rewrite the question clearer please? I can't understand you.

  3. #3
    abby is offline Member
    Join Date
    Apr 2013
    Posts
    10
    Rep Power
    0

    Default Re: j button

    Quote Originally Posted by Prime624 View Post
    Can you rewrite the question clearer please? I can't understand you.
    ok my problem is when i run the program the button in it wouldn't appear unless i run it at least 3 time !!

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    2,924
    Rep Power
    4

    Default Re: j button

    We can't even guess what is happening without the code and/or error messages.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    abby is offline Member
    Join Date
    Apr 2013
    Posts
    10
    Rep Power
    0

    Default Re: j button

    ok i apologise for that and here is my code:
    Java Code:
    package p1;
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.JButton;
    
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    
    
    
    public class F11  extends JFrame implements ActionListener {
    
    	/**
    	 * 
    	 */
    	private static final long serialVersionUID = -1795554022873353381L;
    	/**
    	 * @param args
    	 */
    	/** public F11()
    	    {  super("Test");
    	    JButton b1 =new JButton("Ajouter");
    		
    	    
    	    b1.addActionListener ( new ActionListener()
            { public  void   actionPerformed11(ActionEvent e)
            public void actionPerformed1(ActionEvent arg0) {
    			new F21();
    			F21 f =new F21();
                f.setVisible(true);
    			
    		
            }
            {}*/
    	
    	static JPanel panel1 = new JPanel();
    	
    	
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		
    		F1 fenetre = new F1();
    		fenetre.setTitle("welcome");
    		fenetre.setSize(500,300);
    		fenetre.setLocation ( 400,  200);
    		fenetre.setVisible(true);
    		
    		
    		fenetre.setContentPane(buildContentPane());
    		
    		
    		
    		
    		
    		JButton b1 =new JButton("Ajouter");
    		b1.addActionListener( new ActionListener() {
    			
    		
    			public void actionPerformed(ActionEvent arg0) {
    				new F21();
    				//F2 f =new F2();
    	            //f.setVisible(true);
    	            F21 fenetre = new F21();
    	            fenetre.setVisible(true);
    
    				
    			}
    		}) ;
    		
    			 
    		
    
    	
                             
    		JButton b2  =new JButton("Modfier");
    		JButton b3 =new JButton("Supprimer");
    		JButton b4  =new JButton("Quitter");
    		panel1.add(b1);
    		panel1.add(b2);
    		panel1.add(b3);
    		panel1.add(b4);
    		  //ajoute un listener : ici le listener est cette classe
            b1.addActionListener ( new ActionListener()
            { public  void   actionPerformed(ActionEvent e)
            {
    		//fenetre.add(panel1, FlowLayout.CENTER);
            	  //quand on a cliqué sur le bouton ici
               // F2 f =new F2();
                           //f.setVisible(true);
                
             }
             
             } ) ;}
    		
    		
            public F11()
            
            {
            	/** b1.addActionListener ( new ActionListener()
                 { public  void   actionPerformed(ActionEvent e)
                 {
         		//fenetre.add(panel1, FlowLayout.CENTER);
                 	  //quand on a cliqué sur le bouton ici
                     F21 f =new F21();
                     f.setVisible(true);
                     
                  }*/
    	
    		
    		}
    	
    	
    		
    			
    		
    		
    	
    	private static JPanel buildContentPane(){
    		panel1.setLayout(new FlowLayout());
    		JLabel label = new JLabel("Choisssez une action !");
    		panel1.add(label, BorderLayout.NORTH);
    		return panel1;
    	}
    
    
    
    
    
    
    
    	@Override
    	public void actionPerformed(ActionEvent arg0) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	
    	
    
    }
    // i m sorry if it's disappointing ! and thanks for your pacience
    Last edited by JosAH; 04-12-2013 at 12:08 PM. Reason: added [code] ... [/code] tags

  6. #6
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    317
    Rep Power
    4

    Default Re: j button

    When creating a GUI the setVisible(true) method is usually the last thing to be called. Move the code on line 50 to the end of the method.

    Regards.

Similar Threads

  1. GUI - Button to start, button to stop
    By Humphrey Bogart in forum New To Java
    Replies: 2
    Last Post: 10-13-2012, 07:04 PM
  2. Replies: 7
    Last Post: 08-06-2011, 03:39 AM
  3. Make a button class that uses your button image.
    By eLancaster in forum New To Java
    Replies: 1
    Last Post: 04-26-2011, 11:32 AM
  4. Adding a sqrt button and percentage button to a calculator
    By Josie_Taylor in forum New To Java
    Replies: 4
    Last Post: 03-14-2011, 01:16 AM
  5. Button
    By Tb0h in forum New To Java
    Replies: 6
    Last Post: 07-22-2009, 01:28 AM

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
  •