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. Using NetBeans IDE

Using NetBeans IDE

Scheduled Pinned Locked Moved Java
visual-studiodesignquestion
4 Posts 2 Posters 4 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.
  • R Offline
    R Offline
    Reagan Conservative
    wrote on last edited by
    #1

    I have a class JPanel that I want to add other JPanels onto during run-time. I can add a JPanel using the NetBeans IDE for "design", but the IDE will not let me dynamically add a new JPanel and let me position it on the main JPanel . When I look at the documentation, it appears that there are inherited methods that would allow this type of operation, such as setLocation(int, int). The IDE complains about this method, and the list of available methods that appears when editing the code, has a very limited set. Is there a way around this using the IDE? Thanks for your time.

    AF Pilot

    F 1 Reply Last reply
    0
    • R Reagan Conservative

      I have a class JPanel that I want to add other JPanels onto during run-time. I can add a JPanel using the NetBeans IDE for "design", but the IDE will not let me dynamically add a new JPanel and let me position it on the main JPanel . When I look at the documentation, it appears that there are inherited methods that would allow this type of operation, such as setLocation(int, int). The IDE complains about this method, and the list of available methods that appears when editing the code, has a very limited set. Is there a way around this using the IDE? Thanks for your time.

      AF Pilot

      F Offline
      F Offline
      fly904
      wrote on last edited by
      #2

      Reagan Conservative wrote:

      I have a class JPanel

      I would rename your class to something more appropriate if I were you. If you have a look at the code Netbeans generates with the designer, then you will see something which looks like this.

      JPanel jp = new JPanel();

      //Set jp properties

      [InsertParentControlHere].add(jp);

      Add that in the code where you need it.

      My failometer has shot off the end of the scale! I seem to have misplaced my ban button.. no wait... found it!

      R 1 Reply Last reply
      0
      • F fly904

        Reagan Conservative wrote:

        I have a class JPanel

        I would rename your class to something more appropriate if I were you. If you have a look at the code Netbeans generates with the designer, then you will see something which looks like this.

        JPanel jp = new JPanel();

        //Set jp properties

        [InsertParentControlHere].add(jp);

        Add that in the code where you need it.

        My failometer has shot off the end of the scale! I seem to have misplaced my ban button.. no wait... found it!

        R Offline
        R Offline
        Reagan Conservative
        wrote on last edited by
        #3

        I was just using this as a generic example. The actual name is not JPanel. I was going to try and use this "JPanel" to draw graphics on and place it on another "JPanel". I think that the better approach is just to draw directly to the "JPanel" without adding a whole bunch of smaller "JPanel"s. Thanks for replying.

        AF Pilot

        F 1 Reply Last reply
        0
        • R Reagan Conservative

          I was just using this as a generic example. The actual name is not JPanel. I was going to try and use this "JPanel" to draw graphics on and place it on another "JPanel". I think that the better approach is just to draw directly to the "JPanel" without adding a whole bunch of smaller "JPanel"s. Thanks for replying.

          AF Pilot

          F Offline
          F Offline
          fly904
          wrote on last edited by
          #4

          Apologies, I misunderstood.

          Reagan Conservative wrote:

          I think that the better approach is just to draw directly to the "JPanel" without adding a whole bunch of smaller "JPanel"s.

          Agreed, I see what you mean about inheritence now. Overriding the paintComponant method should do the trick. Have a look at this[^], it may help.

          My failometer has shot off the end of the scale! I seem to have misplaced my ban button.. no wait... found it!

          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