• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

add Jlabel to Jinternalframe

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,i dont understand why does my Label is not showing up,


currently, i am able to show JInternalframe on my JDesktoppane. i just don't understand why my label is not showing inside Jinternalframe
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cl_Main mainform = new Cl_Main();



What is that code for. Get rid of it.

I gave you a link to the Swing tutorial for a reason. I don't know why you are changing the code so dramatically.

If you want to add a label to the internal frame, then add the label when you create the internal frame.



I also have no idea what all this code is for:



The class already is a JFrame, there is no need to create a new JFrame.

You can't use setContentPane() twice. The desktop pane is the content pane for the JFrame. If you replace the content pane with another panel, then you no longer have a desktop pane to add internal frames to.
 
Chernenko Nencor
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Camick wrote:

Cl_Main mainform = new Cl_Main();



What is that code for. Get rid of it.



on Cl_main there's a desktoppane, i want the internalframe attached inside.

Rob Camick wrote:I gave you a link to the Swing tutorial for a reason. I don't know why you are changing the code so dramatically.

If you want to add a label to the internal frame, then add the label when you create the internal frame.




i've tried your code and still didn't work

Rob Camick wrote: I also have no idea what all this code is for:




i am intended to use the code above as my label to be printed on jpanel inside Jinternalframe

Rob Camick wrote: The class already is a JFrame, there is no need to create a new JFrame.

You can't use setContentPane() twice. The desktop pane is the content pane for the JFrame. If you replace the content pane with another panel, then you no longer have a desktop pane to add internal frames to.



take a look at the following picture,


my internalframe still move exceeding the desktoppane

and here's my current code
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, why are you changing the structure of the demo code if you don't understand what your are doing.

If you run the demo code the JInternalFrame is added to the JDesktopPane of the JFrame. The demo code extends JFrame so there is no need to create a second JFrame. There is no need for the CL_Main class. (Also that is not a proper classs name. Look in the Java API to you see any class names with an "_" in the class name? Follow conventions and don't make up your own.

First understand how the demo works and just add your components to the internal frame. That is you can always modify the demo code to create the JInternalFrame at the same time you add the JDesktop pane to the frame. The problem is you add trying to add the desktop pane to your mainform.desktopnya variable. There is no need for that variable. Keep all the code and variables in one class.

Then once you understand the basic concept you can restructure your code so that the main class does not extend JFrame.
 
reply
    Bookmark Topic Watch Topic
  • New Topic