Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] Eclipse view plugin: swing problem

Thank you Boris,

I will take your advice and post to the eclipse.plateform group. But just in case someone here would have a quick answer for me, I will post more details.

Running
Windows Vista 32bit
Java 1.6
Eclipse 3.4.0

You are absolutly correct, my setFocus() method was empty. I started off with a sample project and stripped off all of the useless stuff out of it (apparently I took too much off). I tryed to set the focus. But i dont seem to be able to know to what. I will include a complete code snippet if it may help.

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);
    }
}



On Mon, Nov 17, 2008 at 2:45 AM, Boris Bokowski <bokowski@xxxxxxxxx> wrote:
The best place for questions like this is the eclipse.platform
newsgroup or the eclipse.platform.swt newsgroup, see
http://www.eclipse.org/newsgroups

The second best place would be a bug report.

My guess would be that you did not implement your part's setFocus()
method, but it is hard to tell without a complete code snippet, and
without knowing the platform (Windows? GTK? Mac/Carbon?) and the
Eclipse version (3.3? 3.4?).

Boris

2008/11/16 Benoit LeBel <ben.lebel@xxxxxxxxx>:
> Hi,
>
> Thanks in advance for any help that could be provided.
>
> First of all, I am unaware if this mailgroup is even the good place to post
> this, if not, could someone please recomment me to a good site/forum where i
> could get help.
>
> 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).
>
> For any help someone could bring, I would greatly appreciate it.
> Thank you
> Ben
>
>
>
> package ftie.views;
>
>
> import javax.swing.*;
>
> public class Ftie_ui extends JPanel{
>     Authentification auth;
>
>     JLabel labelUser;
>     JLabel labelPass;
>     JTextField txtUser;
>     JPasswordField txtPass;
>     JButton btnLogin;
>
>
>     public Ftie_ui()
>     {
>         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);
>     }
> }
>
>
>
>
>
> _______________________________________________
> platform-ui-dev mailing list
> platform-ui-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/platform-ui-dev
>
>
_______________________________________________
platform-ui-dev mailing list
platform-ui-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-ui-dev


Back to the top