Results 1 to 10 of 10

Thread: Jpanel In Jfram

  1. #1
    hicham mouddi is offline Member
    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

    Default Jpanel In Jfram

    Hello everybody,

    I am new in Java and I would like to make visible a Jpanel when i click on a button in the Jframe .
    i am working on netbeans, so i have created an event on that button and written the following code :

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEve nt evt) {
    Corrective c = new Corrective();
    this.add(c);
    c.setVisible(true);
    }

    Indeed, my Jpanel class is called Corrective .

    But when i run the API, and click on the button, nothing happen.

    Could someone help me please,

    Thank you for your support ;)

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

    Default Re: Jpanel In Jfram

    Thread moved from New to Java.

    Whenever you add/remove components to/from an already shown container you need to call revalidate() and repaint(). However, in this case I think you would be better off using a CardLayout.

    Can you describe the requirement? Note: the requirement, not any solution you may have envisaged.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

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

    Default Re: Jpanel In Jfram

    hicham mouddi, please ask your questions in the forum and not by PM.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    hicham mouddi is offline Member
    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

    Default Re: Jpanel In Jfram

    Ok sorry. I told you what do you mean by requirement ?
    thanks

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

    Default Re: Jpanel In Jfram

    If you don't know your requirements, you can't convert them into code.

    What are you tasked to do?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    hicham mouddi is offline Member
    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

    Default Re: Jpanel In Jfram

    I am tasked to create a CMMS ( computerized maintenance managment system).
    I already have the data base containing the information of a intervention done on a machine (date, begining of intervention, end of intervention, name of the technician , the machine's code...) . The goal is to create a tool in which I will have to complete the intervention form (in a panel) and that I will be able to see in a table (in an other panel).
    So i have to create a menu which is my frame (called MenuPrincipal) and through the different tabs that the frame provides me, I can chose which panel I want to open, either to fill the form or to see my (table intervention database) in a table.

    I already created my frame, and my panel to fill the form of the intervention.

    But I don't know how to link them .

    thanks db ,

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

    Default Re: Jpanel In Jfram

    Are you adding the JPanel to the JFrame before or after the JFrame is made visible?

    through the different tabs that the frame provides me
    Does that mean that you are using a JTabbedPane?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    hicham mouddi is offline Member
    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

    Default Re: Jpanel In Jfram

    i am adding a Jpanel after the JFrame is set visible,

    No I am using a Jframe form in which i add a menu bar .

    HM,

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

    Default Re: Jpanel In Jfram

    Quote Originally Posted by hicham mouddi View Post
    i am adding a Jpanel after the JFrame is set visible,
    See my first response at #2. But I still think you should be using either a CardLayout or a modal JDialog / JOptionPane.

    Quote Originally Posted by hicham mouddi View Post
    No I am using a Jframe form in which i add a menu bar.
    If you're using a visual designer, scrap it and learn to code a Swing GUI by hand. A visual designer is categorically not a beginners' tool.
    Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials) (Ignore the second section, it's the most difficult way to begin in swing, whatever Oracle may say.)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    hicham mouddi is offline Member
    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

Similar Threads

  1. Replies: 0
    Last Post: 02-17-2013, 09:21 PM
  2. jinternal frame in a jfram query
    By rahul.r4 in forum AWT / Swing
    Replies: 21
    Last Post: 05-05-2012, 01:53 PM
  3. switch data between jfram and jdialog
    By javastuden in forum New To Java
    Replies: 3
    Last Post: 05-18-2011, 04:50 AM
  4. Replies: 1
    Last Post: 03-28-2011, 06:19 AM
  5. how to make Broswe button in jfram form to attache file
    By ibrahimyoussof in forum AWT / Swing
    Replies: 3
    Last Post: 04-12-2010, 08:40 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
  •