• Post Reply Bookmark Topic Watch Topic
  • New Topic

Combining two JFrames into one JFrame  RSS feed

 
Ryan Daguman
Ranch Hand
Posts: 33
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am really having a hard time designing the interface of this program. All I need to do is show in just one JFrame the two combined JFrames. One JFrame namely leftPanel will appear to the left or west and the other namely rightPanel to the right or east using BorderLayout. I already did creating them first as JPanels or as internal classes and subsetted them in one JFrame but that didn't work because it looked messy. And now I've created them as two separate JFrames, compiled separately, and tried to subset them as one in the JFrame. I didn't add any functionality to this program because all I intend to do is to show those two JFrames together in one JFrame. Here's the code:


What am I missing or did I code anything wrong here? Or should I use NetBeans IDE for anything as complicated as this? Please help me. Thank you so much.
 
Carey Brown
Saloon Keeper
Posts: 2538
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan Daguman wrote:I am really having a hard time designing the interface of this program. All I need to do is show in just one JFrame the two combined JFrames. One JFrame namely leftPanel will appear to the left or west and the other namely rightPanel to the right or east using BorderLayout. I already did creating them first as JPanels or as internal classes and subsetted them in one JFrame but that didn't work because it looked messy. And now I've created them as two separate JFrames, compiled separately, and tried to subset them as one in the JFrame. I didn't add any functionality to this program because all I intend to do is to show those two JFrames together in one JFrame. Here's the code:


What am I missing or did I code anything wrong here? Or should I use NetBeans IDE for anything as complicated as this? Please help me. Thank you so much.


What do you mean when you say it 'looked messy'?
You should be adding JPanels to a JFrame not JFrames to a JFrame.
Class names should begin with an uppercase letter.
Your example is incomplete so that we can't compile it to see what you see.
 
Ryan Daguman
Ranch Hand
Posts: 33
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I already tried combining two JPanels into the JFrame but they still looked messy. I mean "looked messy" because the components like the labels, buttons, checkboxes, choice, textfields, and textarea just keep on running through each other. They don't display properly as I expected them to do even though I already set the JFrame into a layout manager. I already tried borderlayout, gridlayout, and also gridbaglayout but it's still no good. As much as possible I'll try to manually code the interface without NetBeans or Eclipse but, I think, with the degree of complexity of the interface, I'll stick to the recommendation by Oracle, use NetBeans. How can I insert an image here in Coderanch using the Img tags from my computer's hard drive so that I can show you a picture of what I want to achieve?
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Carey, Why would you quote the entire question? We know what the question is and we don't need to scroll through the question twice to find any suggestions.

I mean "looked messy" because the components like the labels, buttons, checkboxes, choice, textfields, and textarea just keep on running through each other.


That is because by default a JPanel uses a FlowLayout so the components are display on a single line. If you want a different layout, then use different layout managers.

Read the Swing tutorial on Layout Managers for examples of how to use them. Every panel can have a different layout and you can nest panels as well.
 
Ryan Daguman
Ranch Hand
Posts: 33
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for inputs. NetBeans did the trick. Today I started using NetBeans and I find it very useful. I am overwhelmed with it because of the convenience it offered. I, therefore, will utilize a code editor when it comes to simple GUI designs and programs without any user interface, but with very complex ones, I'll use NetBeans.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!