java - JFrame.setsize() not doing anything -
for reason, can't seem work:
public class app { public static void main(string[] args){ jframe frame = new jframe("hi"); frame.setsize(300, 400); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setvisible(true); } }
no matter size pass setsize(), resulting window when run program still tiny. suggestions?
you try code,will jframe. , setprefered method in program
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class jframedemo { public static void main(string s[]) { jframe frame = new jframe("jframe source demo"); frame.addwindowlistener(new windowadapter() { public void windowclosing(windowevent e) { system.exit(0); } }); jlabel jlbempty = new jlabel(""); jlbempty.setpreferredsize(new dimension(175, 100)); frame.getcontentpane().add(jlbempty, borderlayout.center); frame.pack(); frame.setvisible(true); } }
Comments
Post a Comment