RCP application contains only swing widget. [message #458537] |
Thu, 14 July 2005 22:09 |
Patrick Tiu Messages: 3 Registered: July 2009 |
Junior Member |
|
|
I am trying to port the simple Java Swing application into the Rich Client
Platform. The Swing widget comes up for a split second and the entire
program exit immediately.
Can I call the Swing widget without using the WorkbenchAdvisor. Here is the
code sniplet in my RCP applicaiton:
package org.eclipse.ui.tutorials.rcp.part1;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.WorkbenchAdvisor;
public class RcpApplication implements IPlatformRunnable {
public Object run(Object args) {
misc();
return null;
/* THIS IS COMMENTED OUT ...
WorkbenchAdvisor workbenchAdvisor = new RcpWorkbenchAdvisor();
Display display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display,
workbenchAdvisor);
if (returnCode == PlatformUI.RETURN_RESTART) {
return IPlatformRunnable.EXIT_RESTART;
} else {
return IPlatformRunnable.EXIT_OK;
}
} finally {
display.dispose();
}
*/
}
public void misc() {
JFrame frame = new JFrame("Texts");
JPanel pane = new JPanel();
pane.setBorder(javax.swing.BorderFactory.createEmptyBorder(3 0, 30, 10,
30));
JLabel label = new JLabel("This is a Label");
pane.setLayout(new java.awt.GridLayout(2, 2));
pane.add(label);
pane.setBounds(20, 30, 10, 30);
frame.getContentPane().add(pane, java.awt.BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
System.out.println("exit");
}
}
|
|
|
Re: RCP application contains only swing widget. [message #458543 is a reply to message #458537] |
Fri, 15 July 2005 11:56 |
Haris Peco Messages: 1072 Registered: July 2009 |
Senior Member |
|
|
I think that you have to create simple perspective (with one view for
example) and in view add swing widget like snippet 154
regards
eclipse news group wrote:
> I am trying to port the simple Java Swing application into the Rich Client
> Platform. The Swing widget comes up for a split second and the entire
> program exit immediately.
> Can I call the Swing widget without using the WorkbenchAdvisor. Here is
> the code sniplet in my RCP applicaiton:
>
> package org.eclipse.ui.tutorials.rcp.part1;
>
> import javax.swing.JFrame;
> import javax.swing.JLabel;
> import javax.swing.JPanel;
>
> import org.eclipse.core.runtime.IPlatformRunnable;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.ui.PlatformUI;
> import org.eclipse.ui.application.WorkbenchAdvisor;
>
> public class RcpApplication implements IPlatformRunnable {
>
> public Object run(Object args) {
> misc();
> return null;
> /* THIS IS COMMENTED OUT ...
> WorkbenchAdvisor workbenchAdvisor = new RcpWorkbenchAdvisor();
> Display display = PlatformUI.createDisplay();
> try {
> int returnCode = PlatformUI.createAndRunWorkbench(display,
> workbenchAdvisor);
> if (returnCode == PlatformUI.RETURN_RESTART) {
> return IPlatformRunnable.EXIT_RESTART;
> } else {
> return IPlatformRunnable.EXIT_OK;
> }
> } finally {
> display.dispose();
> }
> */
> }
>
> public void misc() {
>
> JFrame frame = new JFrame("Texts");
> JPanel pane = new JPanel();
>
> pane.setBorder(javax.swing.BorderFactory.createEmptyBorder(3 0, 30, 10,
> 30));
> JLabel label = new JLabel("This is a Label");
>
>
> pane.setLayout(new java.awt.GridLayout(2, 2));
> pane.add(label);
> pane.setBounds(20, 30, 10, 30);
>
> frame.getContentPane().add(pane, java.awt.BorderLayout.CENTER);
> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> frame.pack();
> frame.setVisible(true);
>
> System.out.println("exit");
> }
> }
|
|
|
Powered by
FUDForum. Page generated in 0.02321 seconds