Is it possible for someone to launch a JFrame from a java program, but instead of the JFrame creating its own window, the java program launches it into an existing window? I thought of trying a classloader, something like this:
Class framed = WhateverClassThisIs.class.getClassLoader().loadClass("foo.class");
JFrame launch = (JFrame) framed.newInstance();
WhatEverJFrameBeingUsed.add(launch);
and then just simply add it to the container i'm using currently. But what if the class references another JFrame, like a main class, how do i get that JFrame and contain it in the same existing JFrame? Is it possible to get a Graphics object from a PID, or some other reference to the program?
EDIT: I'm doing this in Linux, on XOrg, preferably on Debian Squeeze
yes it's possible but see this:
JFrame frame1 = new JFrame("First Window");
JPanel panel = new JPanel("Second Window");
frame1.add(panel,BordeLayout.CENTER);
frame1.setSize(300,300);
frame1.setVisible(true);
JPanel is a component that's be contained in a JFrame ,it's not illegal to have a main Window into another main Window!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.