I'm tried. But I have not get desired results.
This is my code:
- Code: Select all
package AANDG;
package AANDG;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class mainapp extends JFrame {
public static JDesktopPane desktop;
/**
* Launch the application
*
* @param args
*/
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(527, 476);
shell.setText("SWT Application");
//
shell.open();
final Composite composite = new Composite(shell, SWT.EMBEDDED);
composite.setBounds(0, 0, 520, 445);
final Frame frame_1 = SWT_AWT.new_Frame(composite);
new mainapp();
frame_1.add(desktop);
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
public mainapp() {
super("InternalFrameDemo");
// Make the big window be indented 50 pixels from each edge
// of the screen.
int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(inset, inset, screenSize.width - inset * 2, screenSize.height
- inset * 2);
// Quit this app when the big window closes.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
// Set up the GUI.
desktop = new JDesktopPane(); // a specialized layered pane
createFrame(); // Create first window
setContentPane(desktop);
// Make dragging faster:
desktop.putClientProperty("JDesktopPane.dragMode", "outline");
}
protected void createFrame() {
MyInternalFrame frame = new MyInternalFrame();
frame.setVisible(true); // necessary as of 1.3; OK to use before
desktop.add(frame);
//main_1 main1 = new main_1();
//main1.setVisible(true);
//desktop.add(main1);
try {
frame.setSelected(true);
//main1.setSelected(true);
} catch (java.beans.PropertyVetoException e) {
}
}
}
MyInternalFrame.java
- Code: Select all
package AANDG;
import javax.swing.JInternalFrame;
import java.awt.event.*;
import java.awt.*;
public class MyInternalFrame extends JInternalFrame {
static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30;
public MyInternalFrame() {
super("Document #" + (++openFrameCount),
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(300,300);
//Set the window's location.
setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
}
}
and main_1.java
- Code: Select all
package AANDG;
import javax.swing.JInternalFrame;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class main_1 extends JInternalFrame{
static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30;
/**
* Launch the application
* @param args
*/
public main_1()
{
super("Document #" + (++openFrameCount),
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
try
{
// ...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(300,300);
//Set the window's location.
setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
open();
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* Open the window
*/
public void open() {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
//
shell.open();
shell.layout();
//while (!shell.isDisposed()) {
// if (!display.readAndDispatch())
// display.sleep();
//}
}
}