[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform] Re: Where is my JFrame? (was Strange behavior when trying to debug my application within eclipse)
|
This makes sense, and I can understand why the "main window created" is not
diaplayed, however, it doesn't explain where is the JFrame and why I can see
the JFrame only when running outside Eclipse
Any idea?
Thanks
/Yaron
"laurent Goubet" <laurent.goubet@xxxxxxx> wrote in message
news:fhse8b$cb6$1@xxxxxxxxxxxxxxxxxxxx
> Yaron,
>
> I don't really know how eclipse handles calls to System.out and
> System.in, but I guess both of them are redirected to the console view.
> This is no more than a wild guess, but since you're calling thread.start
> (which in turns will take the consoleView over with a call to
> System.in.read()) before creating and displaying your window, I think
> the call to System.out.println("main window created") will wait for the
> consoleView to be released before continuing execution.
>
> Cheers,
> Laurent Goubet
> Obeo
>
> Yaron Reinharts a écrit :
>> Hi,
>>
>> Thanks but I don't see how it can prevents the creation of a JFrame
>>
>> /Yaron
>> "Tom Schindl" <tom.schindl@xxxxxxxxxxxxxxx> wrote in message
>> news:fhs2mh$5r5$1@xxxxxxxxxxxxxxxxxxxx
>>> Maybe because the streams in Eclipse are redirected to the ConsoleView?
>>>
>>> Tom
>>>
>>> Yaron Reinharts schrieb:
>>>> Hi,
>>>>
>>>> I was able to isolate the problem.to the following program, it runs
>>>> well
>>>> from the command line but fail to show the frame when running within
>>>> Eclipse
>>>> Why does System.in.read(buffer); prevent the frame creation within
>>>> Eclipse?
>>>>
>>>> Thanks in advance
>>>> /Yaron
>>>>
>>>> import java.io.IOException;
>>>>
>>>>
>>>> import javax.swing.JFrame;
>>>>
>>>>
>>>>
>>>> public class WhereIsMyJFrame
>>>>
>>>> {
>>>>
>>>> public static void main(String[] args)
>>>>
>>>> {
>>>>
>>>> new WhereIsMyJFrame();
>>>>
>>>> }
>>>>
>>>>
>>>> private WhereIsMyJFrame()
>>>>
>>>> {
>>>>
>>>> Thread thread = new Thread()
>>>>
>>>> {
>>>>
>>>> public void run()
>>>>
>>>> {
>>>>
>>>> System.out.println("run");
>>>>
>>>> WhereIsMyJFrame.loop();
>>>>
>>>> }
>>>>
>>>> };
>>>>
>>>>
>>>> System.out.println("starting the thread");
>>>>
>>>> thread.start();
>>>>
>>>>
>>>> System.out.println("creating the main window");
>>>>
>>>> JFrame frame = new JFrame("WhereIsMyJFrame");
>>>>
>>>> System.out.println("main window created");
>>>>
>>>> frame.setVisible(true);
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>> private static void loop()
>>>>
>>>> {
>>>>
>>>> try
>>>>
>>>> {
>>>>
>>>> byte buffer[] = { 0 };
>>>>
>>>> do
>>>>
>>>> System.in.read(buffer);
>>>>
>>>> while ((char) buffer[0] != 'x');
>>>>
>>>> }
>>>>
>>>> catch (IOException ioexception)
>>>>
>>>> {
>>>>
>>>> ioexception.printStackTrace();
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>
>>> --
>>> B e s t S o l u t i o n . at
>>> --------------------------------------------------------------------
>>> Tom Schindl JFace-Committer
>>> --------------------------------------------------------------------
>>
>>
>
>