0

I'm new to Java and is trying to run a Java awt/javax.swing application in Netbeans. Here is the github link.

After I pressed run, nothing really happens even though Netbeans keeps displaying running in its window and a dot appeared under Java application icon (without actually opening a Java application window, I know this is the case because when I click the Java application icon with mouse, nothing happens).

What might be the cause of such problem?

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Thor
  • 9,638
  • 15
  • 62
  • 137
  • 3
    *"Could someone please give me some suggestions on some of the **common cause** of such problem?"* The **code.** For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Jun 27 '16 at 13:24
  • 1
    did you call `setVisible(true)`? – Madhawa Priyashantha Jun 27 '16 at 13:25
  • @FastSnail yes I did :( but thanks for the suggestion! really appreciate it! – Thor Jun 27 '16 at 13:28
  • 1
    @TonyStark how did you run it ?right click and run file?and we don't know how did you set visible.so plz add the source code. – Madhawa Priyashantha Jun 27 '16 at 13:32
  • @FastSnail I'm having trouble uploading my project to github and stackoverflow only allow less than 30000 characters :( – Thor Jun 27 '16 at 13:43
  • 1
    @TonyStark you can use pastebin.but create simple example and try to reproduce the problem then it's easy to test – Madhawa Priyashantha Jun 27 '16 at 13:45
  • Finally uploaded to github. Here is the github link: https://github.com/dzjustinli2/Tetris Thanks again for your help! – Thor Jun 27 '16 at 13:51
  • 2
    *"stackoverflow only allow less than 30000 characters"* Yes. There is a reason for that. An MCVE should be **much** shorter than 30,000 chars! And as an aside, I hope this problem gives you the hint that such trivial problems should be sorted long before the code reaches that length. – Andrew Thompson Jun 27 '16 at 14:04
  • 1
    when you close your application, it will be hidden and not fully closed that's why netBeans shows running, so if you are using swing frame use `setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)` for your main frame, and if you are using javafx see this [link](http://stackoverflow.com/a/12154135/4101906) – Rahmat Waisi Jun 27 '16 at 14:04
  • 1
    Your github does not contain any Swing related code. – explv Jun 27 '16 at 14:07
  • 1
    @rahmatwaisi Calling `setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)` is the optimal approach. If there are no other threads runnning, and no other windows open, the JRE will end. OTOH if there **are** other threads running or windows opened, they should be stopped and shut down gracefully. Using `EXIT_ON_CLOSE` is like using a sledgehammer to crack a peanut shell. – Andrew Thompson Jun 27 '16 at 14:37

1 Answers1

1

Please try

1: shift + F6 to run only that file only.

2: setVisible(true)

Maybe it will help you...

Usman Nawaz
  • 82
  • 1
  • 4
  • 21