Swing problems in Eclipse. [message #496654] |
Tue, 10 November 2009 14:36  |
Eclipse User |
|
|
|
Hi,
I have a Swing JPanel, inside which I have a JTextField. The panel is added to an Eclipse view. If I run the Swing application, I can easily enter text into the JText field.
But when inside the Eclipse view, I cannot even click inside the text field.
Does anyone know what is the solution to this.
Thanks in advance,
Irum.
|
|
|
|
Re: Swing problems in Eclipse. [message #496867 is a reply to message #496654] |
Wed, 11 November 2009 10:26   |
Eclipse User |
|
|
|
I haven't heard of this before, and the basic snippet below works for me on
Windows, so it must be somewhat dependent on your context. Which platform
do you see this on? Which version of SWT are you using? Can you change the
snippet below to show the failure? Or if not, can you provide a basic
plug-in with a view that shows the problem?
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
Button button = new Button(shell, SWT.PUSH);
button.setBounds(10,10,150,30);
button.setText("SWT Button");
Composite composite = new Composite(shell, SWT.EMBEDDED);
composite.setBounds(10,50,150,100);
java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(composite);
java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());
fileTableFrame.add(panel);
JTextField textField = new JTextField("JTextField");
panel.add(textField);
shell.open();
while(!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
"Irum Godil" <irum@ca.ibm.com> wrote in message
news:hdcfbm$vjn$1@build.eclipse.org...
> Hi,
>
> I have a Swing JPanel, inside which I have a JTextField. The panel is
added to an Eclipse view. If I run the Swing application, I can easily enter
text into the JText field.
>
> But when inside the Eclipse view, I cannot even click inside the text
field.
>
> Does anyone know what is the solution to this.
>
> Thanks in advance,
> Irum.
|
|
|
|
|
Re: Swing problems in Eclipse. [message #498832 is a reply to message #498429] |
Wed, 18 November 2009 13:10  |
Eclipse User |
|
|
|
This appears to be an swt bug so I've logged
https://bugs.eclipse.org/bugs/show_bug.cgi?id=295493 . Giving focus to the
JTextField always failed for me both as an eclipse view and as a stand-alone
app run from main().
I don't know what precisely is triggering the problem, but you may be able
to work around it by changing your awt/swing code (are you able to change
it?). For instance, I could make the snippet work with swt by changing its
populate() method to the body below. I know that the snippet now does not
resemble your app too closely, but perhaps sticking to awt rather than swing
as much as possible could help you work around it.
java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());
JTextField repeatIndex = new JTextField();
repeatIndex.setText(" ");
panel.add(repeatIndex);
f.add(panel);
HTH,
Grant
"Irum Godil" <irum@ca.ibm.com> wrote in message
news:hdsg8d$30e$1@build.eclipse.org...
> Hi,
>
> Thanks for your replies. I have created a basic Eclipse view and added the
Text field called: "repeatIndex". If I run the application as it is through
the "main" API everything is fine. But inside the Eclipse view, I cannot
type in the text box.
>
> Please let me know if you need anything else.
>
> Thanks.
> Irum.
|
|
|
Powered by
FUDForum. Page generated in 0.14635 seconds