Results 1 to 4 of 4
  1. #1
    .paul. is offline Member
    Join Date
    Jun 2012
    Posts
    73
    Blog Entries
    1
    Rep Power
    0

    Default JButton in JApplet

    i'm trying to add a JButton to my JApplet.
    the JButton should be set to an absolute position, but it doesn't appear on the JApplet.

    here's my code:

    Java Code:
    this.setSize(740,780);
    this.setLayout(null);
    
    JButton button = new JButton("New Game");
    this.add(button);
    button.move(720-button.getSize().width, 760);
    how can i fix this?

  2. #2
    .paul. is offline Member
    Join Date
    Jun 2012
    Posts
    73
    Blog Entries
    1
    Rep Power
    0

    Default Re: JButton in JApplet

    ok. i did some research + it looks like i could use GridBagLayout.
    can anyone show an example of this?

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JButton in JApplet

    Your research should also point you to the layout manager tutorials which will be able to show you GridBagLayout and the other layouts far better than we possibly can. Why not give this a look and then come on back if you're still stuck.

  4. #4
    .paul. is offline Member
    Join Date
    Jun 2012
    Posts
    73
    Blog Entries
    1
    Rep Power
    0

    Default Re: JButton in JApplet

    i used an absolute position. i'd forgotten setSize + setVisible

Similar Threads

  1. ActionListener for JButton after changing Button to JButton
    By ravi.joshi53 in forum Java Applets
    Replies: 2
    Last Post: 10-07-2011, 07:35 AM
  2. JApplet on MAC
    By ld_pvl in forum Java Applets
    Replies: 0
    Last Post: 08-23-2009, 01:40 PM
  3. JFrame to JApplet or JApplet to JApplet
    By ramesh.8189 in forum AWT / Swing
    Replies: 13
    Last Post: 02-08-2009, 06:14 AM
  4. JApplet problems
    By Rgfirefly24 in forum New To Java
    Replies: 2
    Last Post: 04-24-2008, 07:36 PM
  5. Database to JApplet
    By Preethi in forum New To Java
    Replies: 0
    Last Post: 03-26-2008, 05:18 AM

Posting Permissions

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