java - JFrame does not show up in Eclipse -


i tried execute following code within eclipse (osx):

public static void main(string[] args) {             jframe frame = new jframe("test");             frame.setsize(new dimension(400, 30));             frame.add(new jbutton("hello"));             frame.setdefaultcloseoperation(jframe.exit_on_close);             frame.setvisible(true);         } 

the frame not show following console messages:

2014-05-16 14:45:35.230 java[8685:903] [java cocoacomponent compatibility mode]: enabled 2014-05-16 14:45:35.232 java[8685:903] [java cocoacomponent compatibility mode]: setting timeout swt 0.100000 2014-05-16 14:45:35.546 java[8685:903] *** __nsautoreleasenopool(): object 0x100612800 of class nsconcretemaptablevalueenumerator autoreleased no pool in place - leaking 2014-05-16 14:45:35.547 java[8685:903] *** __nsautoreleasenopool(): object 0x100613f40 of class __nscfdate autoreleased no pool in place - leaking 2014-05-16 14:45:35.547 java[8685:903] *** __nsautoreleasenopool(): object 0x100616e60 of class nscftimer autoreleased no pool in place - leaking 2014-05-16 14:45:35.550 java[8685:903] *** __nsautoreleasenopool(): object 0x10061d7c0 of class __nscfdate autoreleased no pool in place - leaking 2014-05-16 14:45:35.550 java[8685:903] *** __nsautoreleasenopool(): object 0x10061e610 of class nscftimer autoreleased no pool in place - leaking 

while, if put code java file outside of eclipse project , compile , run via command line, fine , frame shows up. can me troubleshooting?

update

the code looks this:

import javax.swing.*;  public class testframe {      public static void main(string[] args) {          javax.swing.swingutilities.invokelater(new runnable() {             public void run() {                 createandshowgui();             }              private void createandshowgui() {                 jframe frame = new jframe("test");                 system.out.println(swingutilities.iseventdispatchthread());                 frame.getcontentpane().add(new jbutton("hello"));                 frame.setdefaultcloseoperation(jframe.exit_on_close);                 frame.pack();                 frame.setvisible(true);             }         });      } } 

this not solve problem (as mentioned user dsquare). figured out seems problem specific eclipse project. if create new eclipse project (same eclipse), code runs without error message , frame shows up. still don't have clue project cnfigurations may cause it. don't have swt.jar in classpath (though org.eclipse.swt , org.eclipse.swt.cocoa.macosx.x86_64 in plugin-dependencies).

your code right , working in own eclipse.

may eclipse not working perfectly. in opinion change eclipse version , try again.

by way make sure jdk version same in eclipse , console.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -