Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: 1 JFrame, more JPanels

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 1 JFrame, more JPanels

    lang.Object
    awt.Component
    awt.Container
    swing.JComponent
    swing.JPanel

    I changed from C++ to Java and may use C++ terms instead of java's. art.Component is super - super of JPanel, so JPanel can call all but the private functions of Component. I need more JPanels in my JFrame, since the panels need different Layoutmanagers.

    I tried to do so:

    JPanel Area1 = new JPanel();
    Area1.setBounds(int,int,int,int)

    and expected to run:


    java/awt/Component.java::2111: public void SetBounds(int x,int y,int w,int h){
    reshape (x,y,w,h);,

    but reshape() is flagged as deprecated and replaced by setBounds() !!! Absolute nonsense!

    JPanel Display = new Panel();
    Display.setBounds(12,12,288,208)
    gives:
    line xxx: <identifier> expected
    Display.setBounds(12,12,288,208)
    ^


    WHAT IS WRONG HERE?
    ??????

    >>>>>>>>>>>>


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    42
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: 1 JFrame, more JPanels

    Can you post the full code?

    java exception
    Last edited by hns1984; January 11th, 2012 at 06:51 PM.

  3. #3
    Member
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    69
    My Mood
    Bored
    Thanks
    11
    Thanked 7 Times in 6 Posts

    Default Re: 1 JFrame, more JPanels

    Quote Originally Posted by jknwhz View Post

    JPanel Display = new Panel();
    Display.setBounds(12,12,288,208)
    gives:
    line xxx: <identifier> expected
    Display.setBounds(12,12,288,208)
    ^


    WHAT IS WRONG HERE?
    ??????

    >>>>>>>>>>>>
    I am thinking you need a Dimension there for you need setMinuminSize(new Dimension(width, height)) ; //semi colon...
    setMaximumSize(new Dimension(width,height);
    setPreferedSize(new Dimension(width,height);
    your looking a JPanel this may help what is going on... setBounds



    Just a helper with building gui's use the gui builder in netbeans or a gui builder in your platform. Then use the properties to help you out.

    I use gui's all the time but I dont have a platform on this computer.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: 1 JFrame, more JPanels

    Quote Originally Posted by william
    Just a helper with building gui's use the gui builder in netbeans or a gui builder in your platform
    For what its worth, in my opinion Gui builder's are not for novices. More often than not cause many more problems than they are worth, as they skip over the fine grain details and when a problem arises, fixing said problem becomes extremely difficult due to the lack of knowledge of the underlying details. In other words, a gui builder will not fix the underlying problem of the original post.

    To the original poster: use an appropriate layout manager (see A Visual Guide to Layout Managers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container) ) and become familiar with the API of the classes you use - deprecated methods should be avoided. If you wish to set sizes of a Component, use the appropriate method (setPreferredSize, setMinimumSize, setMaximumSize). In most cases, the appropriate layout manager and call to the appropriate method mentioned should be enough. If not, post an SSCCE of the problem

Similar Threads

  1. displaying multiple jpanels in a jframe
    By tooktook22 in forum AWT / Java Swing
    Replies: 1
    Last Post: January 19th, 2011, 01:46 PM
  2. Resizing JPanels in JScrollPanes
    By aussiemcgr in forum AWT / Java Swing
    Replies: 4
    Last Post: November 29th, 2010, 02:13 PM
  3. swing - switching JPanels
    By bbr201 in forum Java Theory & Questions
    Replies: 2
    Last Post: August 5th, 2010, 09:18 AM
  4. [SOLVED] Dynamic numbber of JPanels
    By nasi in forum AWT / Java Swing
    Replies: 2
    Last Post: May 14th, 2010, 02:44 AM
  5. repainting a jframe containing two jpanels
    By musasabi in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 11th, 2010, 10:31 PM