• Post Reply Bookmark Topic Watch Topic
  • New Topic

Designing JFrame with JInternalFrame in NetBeans IDE  RSS feed

 
Ashutosh M Kulkarni
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I am trying to design a JFrame with multiple JInternalFrame included therein.
I am using NetBeans IDE for the same, and for ease of designing and maintenance I have put them at different locations on the main JFrame.
However, I want all of them to pop up at the same location. I tried to use setLocation() method for that, but that doesn't help. The internal frames will pop up exactly where I have put them in Design mode. Also, I haven't tried what happens if I open up all the frames at the same time in execution - whether that will resize the main JFrame?

I am certain there is a better way of doing it, I am just unaware of it. Has anyone worked on this kind of a project?
Is there a better way to do it?

Any help is greatly appreciated.

Thanks,
Ashutosh.
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is exactly why I prefer to program my user interfaces myself, without any IDE. The automatically generated code probably moves your internal frames after your own calls to setLocation. Check out the source for any other calls to either setLocation or setBounds called on the internal frames.
 
Ashutosh M Kulkarni
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Err...
There is a big problem with NetBeans (I am not sure if everyone feels this way).
When I am designing a frame, it's great that the source code gets generated automatically, but in NetBeans, the code is frozen and I can't edit in any way. It freezes so that the code may not be used to manipulate and distort/disrupt the appearance of the frame.
However this kills the exact point Rob just made. I can't eliminate other (auto-generated) calls to these methods and that puts me in a spot.
Guess I could try a little more and see if I can find other ways.

Thanks for pointing it out, Rob
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just make a fresh start and code it all yourself. However much it may appear to be that way, the visual designer is categorically not a beginners' tool. The only way someone making more than a very rudimentary GUI can improve their productivity by using the visual designer is if they already understand Swing coding in depth.
 
Ashutosh M Kulkarni
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A prime reason for me to go for the visual editor is because I need it for a better-looking GUI.
I have previously worked on NetBeans visual editor for Swing and know how the stuff works. The reason I am facing problems is just because the code is frozen and I am unable to make changes only as needed.
Never mind, I will try your way as the last option

For now, I have to wait until I get home from work.
 
Ashutosh M Kulkarni
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have another question in the same matter.

How can I successfully call a JInternalFrame from my main JFrame class. I mean, I KNOW the syntax but it isn't working. Not sure if I need to set any specific attributes for the same.
The frames that I designed inside the main JFrame form are executed when called, but the one I tried to write in a separate java file isn't working when called from main class.

Any help?

Thanks,
Ashutosh
 
Arun Chidam
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashutosh M Kulkarni wrote:I have another question in the same matter.

How can I successfully call a JInternalFrame from my main JFrame class. I mean, I KNOW the syntax but it isn't working. Not sure if I need to set any specific attributes for the same.

Check the link which explains why and where you need to use Internal JFrame Internal JFrame




The frames that I designed inside the main JFrame form are executed when called, but the one I tried to write in a separate java file isn't working when called from main class.



what you mean by seperate Java class?...if you follow the below steps it doesn;t matter wether it is a seperate class or from same class you should be able to display Internal Frame

desktop = new JDesktopPane(); //Create a dektop pane
createInternalFrame(); //where you instantiate internal frame and add it to dekstop pane and set visibile true.
setContentPane(desktop); //sets the current content pane to desktop pane

Also if you share your code, we can analyze and respond more accurately.


 
Ashutosh M Kulkarni
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arun,
Thanks for the reply.

Although I was late to mention it, I found the solution to my problem. I know in what situation JFrame/JInternalFrame should or should not be used, and I think I am using both the types quite appropriately for my requirement.
Anyway, earlier when I tried

it didn't work...
(mainPanel is a JPanel object here)

But now somehow it is working so my problem's solved. :-)

But the problem is that InternalFrame is not selected when it is visible. I tried setSelected(true) and toFront() methods but to no use... :-(
Any ideas?
 
Stephan van Hulst
Saloon Keeper
Posts: 6984
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a JDesktopPane.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!