java - Use window builder jframe in a different class -
i trying use gui built window builder in eclipse using jframe. have tried call method ftwo(); in main method , imported class not recognize method package com.cameron.main;
import java.awt.borderlayout; import java.awt.eventqueue; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.border.emptyborder; public class ftwo extends jframe { private jpanel contentpane; /** * launch application. */ public static void main(string[] args) { eventqueue.invokelater(new runnable() { public void run() { try { ftwo frame = new ftwo(); frame.setvisible(true); } catch (exception e) { e.printstacktrace(); } } }); } /** * create frame. */ public ftwo() { setdefaultcloseoperation(jframe.exit_on_close); setbounds(100, 100, 450, 300); contentpane = new jpanel(); contentpane.setborder(new emptyborder(5, 5, 5, 5)); contentpane.setlayout(new borderlayout(0, 0)); setcontentpane(contentpane); } }
assuming myapp
in same java package, instantiate new ftwo
instance , set visible. example:
import java.awt.*; public class myapp { public static void main(string[] args) { ftwo ftwo = new ftwo(); eventqueue.invokelater(() -> ftwo.setvisible(true)); } }
Comments
Post a Comment