Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: button doesnt shows up on the screen

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default button doesnt shows up on the screen

    Why is that my button doesnt show to the screen BTW I am using a fullscreen instead of JFrame

    public class optionButton extends JPanel{
     
    public JButton shop;
    public JButton exit;
    public Image leftButtonIcon;
    public optionButton(Window w){
     
    	ImageIcon leftButtonIcon = new ImageIcon(getClass().getResource("troll.png"));
    	shop = new JButton("Option");
    	exit = new JButton("Rod");	
    	shop.setBounds(100, 100, leftButtonIcon.getIconWidth(), leftButtonIcon.getIconHeight());
    	w.add(shop);
     
    }
     
    }

    AND im my draw method with Window class almost with ScreenManager for the full screen

    public void draw(Graphics g){
    		if (running){
    			Window w = s.getFullScreenWindow();	
     
    		g.drawImage( bg , 0, 0, null);
     
    		ArrayList f = sprite.getFire();	
     
    		for(int i = 0 ; i < f.size() ; i++){
    			Laser l = (Laser) f.get(i) ;
     
    			g.drawImage(l.getLaser(), l.getX(), l.getY(), null);	
    		}
     
     
    		g.drawImage(sprite.getImage(), Math.round(sprite.getX()), Math.round(sprite.getY()), null);
     
    		////////////////////TARGET///////////////////////////////////////////////////	
    		for(int i = 0; i< h.size(); i++){
    			eHearts eh = (eHearts) h.get(i);
    			if(eh.getVisible()){
    				g.drawImage(eh.getEnemy(), eh.getX(), eh.getY(), null);
    			}
    			else{
    				h.remove(i);
    				h.add(new eHearts(xANDy[i][0], xANDy[i][1]));
    				g.drawImage(eh.getEnemy(), eh.getX(), eh.getY(), null);	
    			}	
    		}
    		////////////////////TARGET///////////////////////////////////////////////////
     
    		////////////////////FOR BOOM////////////////////////////////////////////////
     
    		 ArrayList b = sprite.getExplode();  
    		 for(int i = 0; i < b.size(); i++){
    			 Explosion explode = (Explosion) b.get(i);
    			 if(explode.getVisible() == false){
    				g.drawImage(explode.getExplosion(), explode.getX(), explode.getY(), null); 
    		 }	 
    		}	
    		////////////////////FOR BOOM////////////////////////////////////////////////
     
    		g.setColor(w.getForeground());
    		g.drawString(mess, 30, 30);
    		g.drawString(mess1, 30, 50);
    		g.drawString(mess3, 30, 70);
    		mess = "Score: " + score;
     
    		////////////////////FOR BUTTON////////////////////////////////////////////////
     
    		if(pause == false){
    			g.drawImage(p, 800 , 200, null);
    			new optionButton(w);
    			return;
    			}
    		////////////////////FOR BUTTON///////////////////////////////////////////////
     
     
    		Toolkit.getDefaultToolkit().sync();
            g.dispose();
    		}
    	}


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: button doesnt shows up on the screen

    Please post a small complete program that compiles, executes and shows the problem.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Trying to add a button to my Title Screen...
    By Jnk1296 in forum AWT / Java Swing
    Replies: 5
    Last Post: January 25th, 2013, 11:51 AM
  2. Mutiple classfile, JPanel nothing shows up
    By Lorack in forum AWT / Java Swing
    Replies: 71
    Last Post: June 25th, 2012, 02:58 PM
  3. Radio button .. display empty screen ?? plz Help
    By smasm in forum AWT / Java Swing
    Replies: 4
    Last Post: April 7th, 2012, 07:21 PM
  4. Replies: 9
    Last Post: December 31st, 2011, 01:22 AM
  5. Table with CustomModel when clicked shows old entry
    By Nesh108 in forum AWT / Java Swing
    Replies: 6
    Last Post: November 9th, 2011, 06:38 AM