Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » RCP application contains only swing widget.
RCP application contains only swing widget. [message #458537] Thu, 14 July 2005 22:09 Go to next message
Patrick Tiu is currently offline Patrick TiuFriend
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 Go to previous message
Haris Peco is currently offline Haris PecoFriend
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");
> }
> }
Previous Topic:Please help with Browser Scrollbars
Next Topic:Typeahead in combo and list
Goto Forum:
  


Current Time: Thu Nov 26 12:43:38 GMT 2020

Powered by FUDForum. Page generated in 0.02307 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top