Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. How do you set the size and location of a JButton in an applet?

How do you set the size and location of a JButton in an applet?

Scheduled Pinned Locked Moved Java
question
4 Posts 3 Posters 18 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I have tried setSize(), setBounds(), setMinimumSize(), setMaximumSize(), setPreferredSize(), and none of them work. The button takes up the entire applet window. Also, my applet shows up fine when I use appletviewer but when I put it in a webpage it doesn't show up. Any ideas? All input is appreciated.

    P M 2 Replies Last reply
    0
    • L Lost User

      I have tried setSize(), setBounds(), setMinimumSize(), setMaximumSize(), setPreferredSize(), and none of them work. The button takes up the entire applet window. Also, my applet shows up fine when I use appletviewer but when I put it in a webpage it doesn't show up. Any ideas? All input is appreciated.

      P Offline
      P Offline
      Peter Weyzen
      wrote on last edited by
      #2

      It's been awhile since my java days -- but my first guess for you is to pick the correct layout manager. The layout manager takes precedence over your sizing.... Is there still an XYLayout?

      L 1 Reply Last reply
      0
      • P Peter Weyzen

        It's been awhile since my java days -- but my first guess for you is to pick the correct layout manager. The layout manager takes precedence over your sizing.... Is there still an XYLayout?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        I am not familiar with layouts. Guess ill have to go reaserching =). Tnks for the reply.

        1 Reply Last reply
        0
        • L Lost User

          I have tried setSize(), setBounds(), setMinimumSize(), setMaximumSize(), setPreferredSize(), and none of them work. The button takes up the entire applet window. Also, my applet shows up fine when I use appletviewer but when I put it in a webpage it doesn't show up. Any ideas? All input is appreciated.

          M Offline
          M Offline
          Malcolm McMahon
          wrote on last edited by
          #4

          Objects in a window are sized dynamically by the layout manager. If you don't specify a particular layout manager the default one is FlowLayout. The layout manager asks the component for it's preffered size, then usually sets it's size to that (if it finds enough space). If you really need to take control over an component's size they you probably need to subclass the component and override the getMinimumSize and getPreferredSize methods.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups