Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Albireo » Re: Eclipse view plugin: swing problem
Re: Eclipse view plugin: swing problem [message #8819] Mon, 17 November 2008 10:15 Go to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5294
Registered: July 2009
Senior Member
Hi Ben,

I don't know how to solve but I've included the albireo newsgroup which
deals with Swing/SWT.

The problem looks like the Swing event loop is not working appropiately
hence no events are delivered to the Swing components.

Tom

Ben schrieb:
> Hi,
>
> Thanks in advance for any help that could be provided.
>
> I am new to the Eclipse plugin world. I have a very short amount of time
> to complete my project and do not have time to learn the SWT library. I
> am very familiar with the Swing library and i have found a way to wrap
> Swing into the view by doing the following.
>
> public void createPartControl(Composite parent) {
> try{
>
> UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel ");
>
> }catch (Exception e){
> //TODO: manage exception
> }
> Composite swtAwtComponent = new Composite(parent,
> SWT.EMBEDDED);
> java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
> Ftie_ui ui = new Ftie_ui();
> frame.add(ui);
> }
>
> The Ftie_ui class extends JPanel. Normally, with access to a JPanel, I
> figured it would be easy to develop my project with Swing. I added 2
> JLabels, 1 JTextField, 1 JPasswordField and 1 JButton. When i ran
> Eclipse with my plugin, Everything got loaded in my JPanel, but i could
> not access the JTextField and the JPasswordField. I have tryed
> setEnabled(true) and setEditable(true) on the fields, but with no
> success, I could not manage to put a cursor is the fields. The Ftie_ui
> class looks like the following (I know, theres no layout yet).
>
> I am running, windows vista 32bit, java 1.6, Eclipse 3.4.0
> I will supply a complete code snippet in case it would help.
>
> For any help someone could bring, I would greatly appreciate it.
> Thank you
> Ben
>
>
> package ftie.views;
>
> import javax.swing.*;
>
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.ui.part.*;
> import org.eclipse.swt.awt.SWT_AWT;
> import org.eclipse.ui.*;
> import org.eclipse.swt.SWT;
>
>
> public class FtieView extends ViewPart {
>
> Composite swtAwtComponent;
> java.awt.Frame frame;
> Ftie_ui ui;
>
> public FtieView() {
>
> }
>
> public void createPartControl(Composite parent) {
> try{
>
> UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel ");
>
> }catch (Exception e){
> //TODO: manage exception
> }
> swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
> frame = SWT_AWT.new_Frame( swtAwtComponent );
> ui = new Ftie_ui();
> frame.add(ui);
>
> }
>
>
> public void setFocus() {
>
>
> }
> }
>
>
>
> package ftie.views;
>
> import javax.swing.*;
>
> public class Ftie_ui extends JPanel{
>
> JLabel labelUser;
> JLabel labelPass;
> JTextField txtUser;
> JPasswordField txtPass;
> JButton btnLogin;
> public Ftie_ui()
> {
> //TODO: add layout
>
> labelUser = new JLabel();
> labelUser.setText("Username:");
> labelPass = new JLabel();
> labelPass.setText("Password:");
> txtUser = new JTextField(20);
> txtUser.setEditable(true);
> txtUser.setEnabled(true);
> txtPass = new JPasswordField(20);
>
> btnLogin = new JButton("Login");
> add(labelUser);
> add(labelPass);
> add(txtUser);
> add(txtPass);
> add(btnLogin);
> }
> }
>
>
>
>
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Eclipse view plugin: swing problem [message #10847 is a reply to message #8819] Tue, 18 November 2008 05:33 Go to previous message
Rahul Kamdar is currently offline Rahul Kamdar
Messages: 63
Registered: July 2009
Member
Hi Ben,

I make use of SWT_AWT bridge successfully to bring panels from Swing
application into SWT/Eclipse. First thing, if it's possible use Albireo
since SWT_AWT has some bugs and issues and the workarounds could be tricky
depending on your requirements.

Try the following to see if it works:

Hold the composite object > parent in a global variable at your FtieView
class level. Then override the "setFocus" method of "ViewPart" and in this
createPartControl with the global parent object. This is not the best way
but if it works then we could try the workaround.

Thanks,
Rahul

"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:gfs1pu$chn$1@build.eclipse.org...
> Hi Ben,
>
> I don't know how to solve but I've included the albireo newsgroup which
> deals with Swing/SWT.
>
> The problem looks like the Swing event loop is not working appropiately
> hence no events are delivered to the Swing components.
>
> Tom
>
> Ben schrieb:
>> Hi,
>>
>> Thanks in advance for any help that could be provided.
>>
>> I am new to the Eclipse plugin world. I have a very short amount of time
>> to complete my project and do not have time to learn the SWT library. I
>> am very familiar with the Swing library and i have found a way to wrap
>> Swing into the view by doing the following.
>>
>> public void createPartControl(Composite parent) {
>> try{
>>
>> UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel ");
>>
>> }catch (Exception e){
>> //TODO: manage exception
>> }
>> Composite swtAwtComponent = new Composite(parent,
>> SWT.EMBEDDED);
>> java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
>> Ftie_ui ui = new Ftie_ui();
>> frame.add(ui);
>> }
>>
>> The Ftie_ui class extends JPanel. Normally, with access to a JPanel, I
>> figured it would be easy to develop my project with Swing. I added 2
>> JLabels, 1 JTextField, 1 JPasswordField and 1 JButton. When i ran
>> Eclipse with my plugin, Everything got loaded in my JPanel, but i could
>> not access the JTextField and the JPasswordField. I have tryed
>> setEnabled(true) and setEditable(true) on the fields, but with no
>> success, I could not manage to put a cursor is the fields. The Ftie_ui
>> class looks like the following (I know, theres no layout yet).
>>
>> I am running, windows vista 32bit, java 1.6, Eclipse 3.4.0
>> I will supply a complete code snippet in case it would help.
>>
>> For any help someone could bring, I would greatly appreciate it.
>> Thank you
>> Ben
>>
>>
>> package ftie.views;
>>
>> import javax.swing.*;
>>
>> import org.eclipse.swt.widgets.Composite;
>> import org.eclipse.ui.part.*;
>> import org.eclipse.swt.awt.SWT_AWT;
>> import org.eclipse.ui.*;
>> import org.eclipse.swt.SWT;
>>
>>
>> public class FtieView extends ViewPart {
>>
>> Composite swtAwtComponent;
>> java.awt.Frame frame;
>> Ftie_ui ui;
>>
>> public FtieView() {
>>
>> }
>>
>> public void createPartControl(Composite parent) {
>> try{
>>
>> UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel ");
>>
>> }catch (Exception e){
>> //TODO: manage exception
>> }
>> swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
>> frame = SWT_AWT.new_Frame( swtAwtComponent );
>> ui = new Ftie_ui();
>> frame.add(ui);
>>
>> }
>>
>>
>> public void setFocus() {
>>
>>
>> }
>> }
>>
>>
>>
>> package ftie.views;
>>
>> import javax.swing.*;
>>
>> public class Ftie_ui extends JPanel{
>>
>> JLabel labelUser;
>> JLabel labelPass;
>> JTextField txtUser;
>> JPasswordField txtPass;
>> JButton btnLogin;
>> public Ftie_ui()
>> {
>> //TODO: add layout
>>
>> labelUser = new JLabel();
>> labelUser.setText("Username:");
>> labelPass = new JLabel();
>> labelPass.setText("Password:");
>> txtUser = new JTextField(20);
>> txtUser.setEditable(true);
>> txtUser.setEnabled(true);
>> txtPass = new JPasswordField(20);
>>
>> btnLogin = new JButton("Login");
>> add(labelUser);
>> add(labelPass);
>> add(txtUser);
>> add(txtPass);
>> add(btnLogin);
>> }
>> }
>>
>>
>>
>>
>>
>>
>>
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
Re: Eclipse view plugin: swing problem [message #574832 is a reply to message #8819] Tue, 18 November 2008 05:33 Go to previous message
Rahul Kamdar is currently offline Rahul Kamdar
Messages: 63
Registered: July 2009
Member
Hi Ben,

I make use of SWT_AWT bridge successfully to bring panels from Swing
application into SWT/Eclipse. First thing, if it's possible use Albireo
since SWT_AWT has some bugs and issues and the workarounds could be tricky
depending on your requirements.

Try the following to see if it works:

Hold the composite object > parent in a global variable at your FtieView
class level. Then override the "setFocus" method of "ViewPart" and in this
createPartControl with the global parent object. This is not the best way
but if it works then we could try the workaround.

Thanks,
Rahul

"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:gfs1pu$chn$1@build.eclipse.org...
> Hi Ben,
>
> I don't know how to solve but I've included the albireo newsgroup which
> deals with Swing/SWT.
>
> The problem looks like the Swing event loop is not working appropiately
> hence no events are delivered to the Swing components.
>
> Tom
>
> Ben schrieb:
>> Hi,
>>
>> Thanks in advance for any help that could be provided.
>>
>> I am new to the Eclipse plugin world. I have a very short amount of time
>> to complete my project and do not have time to learn the SWT library. I
>> am very familiar with the Swing library and i have found a way to wrap
>> Swing into the view by doing the following.
>>
>> public void createPartControl(Composite parent) {
>> try{
>>
>> UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel ");
>>
>> }catch (Exception e){
>> //TODO: manage exception
>> }
>> Composite swtAwtComponent = new Composite(parent,
>> SWT.EMBEDDED);
>> java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
>> Ftie_ui ui = new Ftie_ui();
>> frame.add(ui);
>> }
>>
>> The Ftie_ui class extends JPanel. Normally, with access to a JPanel, I
>> figured it would be easy to develop my project with Swing. I added 2
>> JLabels, 1 JTextField, 1 JPasswordField and 1 JButton. When i ran
>> Eclipse with my plugin, Everything got loaded in my JPanel, but i could
>> not access the JTextField and the JPasswordField. I have tryed
>> setEnabled(true) and setEditable(true) on the fields, but with no
>> success, I could not manage to put a cursor is the fields. The Ftie_ui
>> class looks like the following (I know, theres no layout yet).
>>
>> I am running, windows vista 32bit, java 1.6, Eclipse 3.4.0
>> I will supply a complete code snippet in case it would help.
>>
>> For any help someone could bring, I would greatly appreciate it.
>> Thank you
>> Ben
>>
>>
>> package ftie.views;
>>
>> import javax.swing.*;
>>
>> import org.eclipse.swt.widgets.Composite;
>> import org.eclipse.ui.part.*;
>> import org.eclipse.swt.awt.SWT_AWT;
>> import org.eclipse.ui.*;
>> import org.eclipse.swt.SWT;
>>
>>
>> public class FtieView extends ViewPart {
>>
>> Composite swtAwtComponent;
>> java.awt.Frame frame;
>> Ftie_ui ui;
>>
>> public FtieView() {
>>
>> }
>>
>> public void createPartControl(Composite parent) {
>> try{
>>
>> UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel ");
>>
>> }catch (Exception e){
>> //TODO: manage exception
>> }
>> swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
>> frame = SWT_AWT.new_Frame( swtAwtComponent );
>> ui = new Ftie_ui();
>> frame.add(ui);
>>
>> }
>>
>>
>> public void setFocus() {
>>
>>
>> }
>> }
>>
>>
>>
>> package ftie.views;
>>
>> import javax.swing.*;
>>
>> public class Ftie_ui extends JPanel{
>>
>> JLabel labelUser;
>> JLabel labelPass;
>> JTextField txtUser;
>> JPasswordField txtPass;
>> JButton btnLogin;
>> public Ftie_ui()
>> {
>> //TODO: add layout
>>
>> labelUser = new JLabel();
>> labelUser.setText("Username:");
>> labelPass = new JLabel();
>> labelPass.setText("Password:");
>> txtUser = new JTextField(20);
>> txtUser.setEditable(true);
>> txtUser.setEnabled(true);
>> txtPass = new JPasswordField(20);
>>
>> btnLogin = new JButton("Login");
>> add(labelUser);
>> add(labelPass);
>> add(txtUser);
>> add(txtPass);
>> add(btnLogin);
>> }
>> }
>>
>>
>>
>>
>>
>>
>>
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
Previous Topic:Re: Eclipse view plugin: swing problem
Next Topic:How to update a SwingControl
Goto Forum:
  


Current Time: Fri Aug 29 01:45:00 EDT 2014

Powered by FUDForum. Page generated in 0.02314 seconds