java - Swing & AWT: ContentPane items not showing in JFrame -


i'm creating basic java swing app having problems content pane not showing objects.

this main class calling other classes in future , calling frame.java:

public class main  {      public static void main(string[] args)     {        system.out.println("hi");         frame frameobject = new frame();        frameobject.main();     } } 

this frame class create frame:

import javax.swing.*; import java.awt.*;  public class frame {     public static void main()     {         swingutilities.invokelater(new runnable()         {             public void run()             {                 jframe frame = new mainframe("warlock of firetop mountain");                  //implementing toolkit allow computer dimensions of screen , assign them 2 int values                 toolkit tk = toolkit.getdefaulttoolkit();                 int xsize = (int) tk.getscreensize().getwidth();                 int ysize = (int) tk.getscreensize().getheight();                  frame = new jframe("warlock of firetop mountain");                 frame.settitle("warlock of firetop mountain");                 frame.setsize(new dimension(xsize, ysize));                 frame.setdefaultcloseoperation(jframe.exit_on_close);                 frame.setresizable(true);                 frame.setlocationrelativeto(null);                 frame.setvisible(true);             }         });     } } 

this mainframe.java store components:

public class mainframe extends jframe {     public mainframe(string title)     {         super(title);          setlayout(new borderlayout());          //components - buttons         jbutton savebutton =new jbutton("save");          jbutton loadbutton =new jbutton("load");          jbutton optionsbutton = new jbutton("options");          jbutton inventorybutton =new jbutton("inventory");          container buttonscontainer = getcontentpane();         buttonscontainer.add(savebutton, borderlayout.line_start);         buttonscontainer.add(loadbutton, borderlayout.center);         buttonscontainer.add(optionsbutton,borderlayout.center);         buttonscontainer.add(inventorybutton,borderlayout.after_line_ends);          //components - enter button         jbutton enterbutton = new jbutton("enter");          // /components - combobox         jcombobox pageturner = new jcombobox();          //components = jtextarea         jtextarea currenttext = new jtextarea();     } } 

frame = new jframe("warlock of firetop mountain"); 

why resetting frame new instance of jframe? didn't set mainframe?


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -