Sunday, 15 April 2012

swing - Running a java application in a windows frame -



swing - Running a java application in a windows frame -

i'm trying larn java creating simple text-based "game". it's going pretty far, want run game in window instead of console (netbeans 8.0 in case).

i've looked online on how , see lot of results jframe, i'm not seeing jframe appear @ all.

my code follows:

main

package helloworld; public class helloworld { public static void main(string[] args) { // todo code application logic here startgame startgame = new startgame(); play play = new play(); startgame.main(); play.main(); } }

window

package helloworld; import java.awt.*; import javax.swing.*; public class window { private static void createwindow() { jframe frame = new jframe("helloworld"); frame.setdefaultcloseoperation(jframe.exit_on_close); } }

the classes startgame , play doing calculations numbers don't matter.

i'm not getting error massages, it's not showing window.

jframe , valid fo top-level contianers aren't visible default, in compare jcomponents

you have phone call jframe.setvisible(true) after jcomponents added jframe, , sizing done

also read initial thread

java swing jframe

No comments:

Post a Comment