Results 1 to 3 of 3
Like Tree2Likes
  • 1 Post By JosAH
  • 1 Post By gimbal2

Thread: could I know what are the minimal requirements for a Frame?

  1. #1
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default could I know what are the minimal requirements for a Frame?

    Hi,

    I added JPanel and a JButton to a private class which is a sub class of JFrame,
    and created public class which is a sub class of the private class,
    But the frame is not visible.

    Java Code:
    class inner extends JFrame{
    	 JPanel jpanel=new JPanel();
    	 JButton jbutton = new JButton("button");
    	
    }
    public class Mixed extends inner{
    
    	 public static void main(String[] args)
    	 {
    		 inner Inner = new inner();
    		 Inner.jpanel.add(Inner.jbutton);
    		 Inner.jpanel.setVisible(true);
    	 }
    	
    }
    regards
    dhilip

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default Re: could I know what are the minimal requirements for a Frame?

    Why don't you make 'inner' itself visible and see for yourself ...

    Jos
    noobplus likes this.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,029
    Rep Power
    6

    Default Re: could I know what are the minimal requirements for a Frame?

    its like putting a flashlight in a closed box and then turning on the flashlight - yeah probably the thing is on, but you're not going to see it :)

    note: when you make the container (IE. the JFrame) visible, all its components will also by default be visible. So no need to call setVisible() on the JPanel.
    noobplus likes this.

Similar Threads

  1. Replies: 0
    Last Post: 05-08-2013, 11:46 PM
  2. Replies: 4
    Last Post: 01-18-2011, 08:22 AM
  3. Replies: 7
    Last Post: 01-17-2011, 11:47 AM
  4. Java slave Frame access to its owner main frame problem
    By cagdaseckin in forum New To Java
    Replies: 0
    Last Post: 12-10-2010, 10:40 AM
  5. Minimal single threaded web server?
    By johann_p in forum New To Java
    Replies: 2
    Last Post: 04-24-2008, 04:37 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
  •