Results 1 to 7 of 7

Thread: no display

  1. #1
    Kyle227's Avatar
    Kyle227 is offline Member
    Join Date
    Apr 2010
    Location
    Mass
    Posts
    47
    Rep Power
    0

    Question no display

    i not that good with applets and this is my second one. i am trying to add components to different Jpanels. then i put those Jpanels in the JPanel panel. but when i run the applet it shows nothing.

    note: panel is the main JPanel

    Java Code:
    public void init(){
    		//button groups
    		ButtonGroup skill = new ButtonGroup();
    		skill.add(noob);
    		skill.add(good);
    		skill.add(r_good);
    		skill.add(beast);
    		
    		ButtonGroup y_n = new ButtonGroup();
    		y_n.add(yes);
    		y_n.add(no);
    		
    		//panels
    		id_panel.add(ID);
    		id_panel.add(your_ID);
    		
    		rank_panel.add(rank);
    		rank_panel.add(your_rank);
    		
    		BoxLayout box = new BoxLayout(WAR_panel, BoxLayout.Y_AXIS);
    		WAR_panel.setLayout(box);
    		WAR_panel.add(rifle);
    		WAR_panel.add(sniper);
    		WAR_panel.add(knife);
    		WAR_panel.add(flame);
    		WAR_panel.add(RPG);
    		WAR_panel.add(grenade);
    		
    		
    		BoxLayout box2 = new BoxLayout(skill_panel, BoxLayout.Y_AXIS);
    		skill_panel.setLayout(box2);
    		skill_panel.add(noob);
    		skill_panel.add(good);
    		skill_panel.add(r_good);
    		skill_panel.add(beast);
    		
    		
    		BoxLayout box3 = new BoxLayout(yn_panel, BoxLayout.Y_AXIS);
    		yn_panel.setLayout(box3);
    		yn_panel.add(yes);
    		yn_panel.add(no);
    		
    		//displaying the components
    		
    		
    		panel.add(id_panel);
    		panel.add(rank_panel);
    		panel.add(what_r_u);
    		panel.add(add_info);
    		panel.add(yn_panel);
    		
    	}
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default

    Quote Originally Posted by Kyle227 View Post
    note: panel is the main JPanel
    And what exactly does that mean? I don't see where you add this "main panel" to the JApplet or set it as the JApplet's contentPane.

    db
    Last edited by DarrylBurke; 07-15-2010 at 12:39 PM.

  3. #3
    Kyle227's Avatar
    Kyle227 is offline Member
    Join Date
    Apr 2010
    Location
    Mass
    Posts
    47
    Rep Power
    0

    Default

    what i meant was a made a Jpanel and named it panel. that is the panel where all of the components are going. then i made other Jpanels like WAR_panel,skill_panel and added them to the Jpanel panel too.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Then what did you do with this panel named panel so that you could see it? JPanels are containers not windows.

  5. #5
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default

    Have you read the section from the Swing tutorial on How to Make Applets for a working example?

  6. #6
    Kyle227's Avatar
    Kyle227 is offline Member
    Join Date
    Apr 2010
    Location
    Mass
    Posts
    47
    Rep Power
    0

    Default

    never mind i found out my problem. i didn't add the panel

    Java Code:
    panel.add(skill_panel);
    		panel.add(yn_panel);
    		panel.add(blank);
    		panel.add(send);
    		
    		[COLOR="Red"]add(panel);[/COLOR]

  7. #7
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by Kyle227 View Post
    never mind i found out my problem. i didn't add the panel

    very well. watch out, all panels and also the applet has a flowlayout and i think for placing all your panels a borderlayout is more appropriate. let me know.

Similar Threads

  1. Replies: 1
    Last Post: 05-31-2010, 08:46 AM
  2. Cannot display in JPanel
    By atch in forum New To Java
    Replies: 2
    Last Post: 02-05-2010, 02:21 PM
  3. Display tag help
    By kirtichopra2003 in forum Advanced Java
    Replies: 0
    Last Post: 11-12-2009, 09:10 AM
  4. Replies: 8
    Last Post: 12-29-2008, 07:12 AM
  5. Replies: 0
    Last Post: 06-28-2008, 09:26 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
  •