|
Re: No tabbed view with SWING [message #1112380 is a reply to message #1107493] |
Thu, 19 September 2013 15:39 |
Ken Lee Messages: 97 Registered: March 2012 |
Member |
|
|
Hi Daniele,
To give you a short answer to your question first, the current implementation does not support multiple tabbed views in Swing. However, I think it should be possible to add such an extension.
Background information:
The Scout desktop is divided into a 3x3 matrix, each cell in the matrix is able to display one (or more in SWT / RAP) view(s). The location of a view can be addressed with a view id like North, South, East, West, Center, North-East, etc.
In your SWT project the views are configured by default to allow multiple instances of a view (see plugin.xml -> extensions -> org.eclipse.ui.views).
In Swing however, the concepts are a bit different: The desktop is divided into a 3x3 matrix, too. If you configure your form to be displayed as a view (DISPLAY_HINT_VIEW), the AbstractSwingEnvironment will create a SwingScoutInternalFrame (cf. method AbstractSwingEnvironment.createInternalFrame) that allocates a JInternalFrame as a UI element. The JInternalFrame is then added to the JDesktopPane (see method SwingScoutInternalFrame.openView).
To be able to have multiple tabbed views, I suggest to introduce a new layer, i.e. instead of adding the JInternalFrame directly to the JDesktopPane, you should create a JTabbedPane first and add the JInternalFrame to the JTabbedPane. The JTabbedPane is then attached to the JDesktopPane.
A simple Swing example:
public class SwingTabbedPaneExample {
public static void main( String[] arg ) {
JDesktopPane desktop = new JDesktopPane();
JInternalFrame internalFrame1 = new JInternalFrame( "Internal Frame 1", true, true, true, true );
internalFrame1.setSize(200, 200);
internalFrame1.setVisible(true);
desktop.add(internalFrame1);
JInternalFrame internalFrame2 = new JInternalFrame( "Internal Frame 2", true, true, true, true );
internalFrame2.setSize(200, 200);
internalFrame2.setVisible(true);
desktop.add(internalFrame2);
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add("First Frame", internalFrame1);
tabbedPane.add("Second Frame", internalFrame2);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(tabbedPane);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
This may only be done if another Scout form is already displayed in the same view / matrix cell. So you probably need keeping track of that.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02593 seconds