Nothing Displayed On Screen Java Swing Application -
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class simultaneoussolver extends jframe implements actionlistener { jtextfield tfeq1x = new jtextfield (20); jtextfield tfeq1y = new jtextfield (20); jtextfield tfeq1num = new jtextfield (20); jtextfield tfeq2x = new jtextfield (20); jtextfield tfeq2y = new jtextfield (20); jtextfield tfeq2num = new jtextfield (20); jlabel lblx1 = new jlabel ("x₁"); jlabel lbly1 = new jlabel ("y₁"); jlabel lblnum1 = new jlabel ("number₁"); jlabel lblequal1 = new jlabel ("="); jlabel lblx2 = new jlabel ("x₂"); jlabel lbly2 = new jlabel ("y₂"); jlabel lblnum2 = new jlabel ("number₂"); jlabel lblequal2 = new jlabel ("="); jtextarea empty = new jtextarea ("",1,20); double x1, x2, y1, y2, num1, num2; double solx, soly; font font = new font("comic sans ms", font.bold, 14); simultaneoussolver() { super ("simultaneous equation solver"); setdesign(); setsize(700,400); setresizable(false); setdefaultcloseoperation(exit_on_close); jpanel panelequation1 = new jpanel(new gridlayout(1,7)); { panelequation1.add(lblx1); panelequation1.add(tfeq1x); panelequation1.add(lbly1); panelequation1.add(tfeq1y); panelequation1.add(lblequal1); panelequation1.add(lblnum1); panelequation1.add(tfeq1num); } jpanel panelequation2 = new jpanel(new gridlayout(1,7)); { panelequation2.add(lblx2); panelequation2.add(tfeq2x); panelequation2.add(lbly2); panelequation2.add(tfeq2y); panelequation2.add(lblequal2); panelequation2.add(lblnum2); panelequation2.add(tfeq2num); } setvisible(true); } public final void setdesign() { try { uimanager.setlookandfeel("com.sun.java.swing.plaf.nimbus.nimbuslookandfeel"); } catch(exception e) { } } public static void main(string[] args) { new simultaneoussolver(); } }
ok, starting new application development using pure swing if possible, set objects , stuff , when try run application see if looks good, nothing shows except empty container.
add these 2 lines @ end of constructor.
setlayout(new gridlayout()); // sets layout frame - can choose 1 suitable layout add(panelequation1); // adds 1st panel add(panelequation2); // adds 2nd panel
Comments
Post a Comment