• Post Reply Bookmark Topic Watch Topic
  • New Topic

Display two Frames In One Window?

 
john mcintyre
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm preety new to programing and i'm havin a bit of a problem Can anyone tell me how to diplay the below in one frame, at the moment when i run this code two pages only, how can i get it to display in one page,

thank you



public static void main(String a[])
{
ApplicationFrame frame = new ApplicationFrame();
frame.setVisible(true);
String tmp[] = a;
int l = a.length;
if (l == 0)
{
tmp = params;
l = tmp.length;
}
String jpegFile = tmp[0];
String shapeFiles[] = new String[l - 1];
for (int i = 1; i < l; i++)
shapeFiles[i - 1] = tmp[i];
final ApplicationFrame lf = new ApplicationFrame(jpegFile, shapeFiles);
//lf.add(frame);
lf.setVisible(true);
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
lf.pack();
lf.fit();
}
});
}
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a Frame *is* a window, you can't display two frames *in* a window.

What is the first frame good for?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at JDesktopPane and JInternalFrame.
 
john mcintyre
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think i explained what i want to do properly. i have a map frame, and i want to add a frame ontop of this frame which shows roads, so the 2 frames are dispalyed ontop of eachother, so one of the frames is like a glassframe if theres a such thing
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the 'The Glass Pane' section on the How to Use Root Panes page in the tutorial. It has an example app and good discussion. One difficulty with the glass pane approach is that it covers the entire root pane so mouse event translation can get to be a burden. An alternative is to use an OverlayLayout to position a graphic, non–opaque component over the component on which your map is rendered. This may cut down on the event re–routing and otherwise works the same as the glass pane with the exception of the visibility: it's always visible. It's a bit of a dance to get started: first instantiate the base component, then the OverlayLayout which takes the componet as an argument, then set the layout for the component. Then you can add the map and the on–top component, I never can remember the order of the last two.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!