java - Swing gui disappeared -
i working on simple gui options add,remove,write disk etc.. while coding program came problem gui start disappear , opening blank frame in design tab/editor(also in run time), tried undo multiple times , coming time point cannot undo anymore. posted code have. solution problem ?
package nikola.lozanovski.bitola; import java.awt.eventqueue; import java.awt.font; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.util.hashtable; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.joptionpane; import javax.swing.jpanel; import javax.swing.jtextfield; import javax.swing.border.emptyborder; public class vozenred extends jframe { public vozenred() { } /** * */ private static final long serialversionuid = 1l; private jpanel contentpane; private jbutton delete; private jbutton transporter; private jtextfield idbox; private jtextfield initialbox; private jtextfield finalbox; private jtextfield hbox; private jtextfield pricebox; private jtextfield agencybox; private jtextfield savebox; private jtextfield mbox; private jtextfield deletebox; private jtextfield destinationsbox; /** * launch application. */ public static void main(string[] args) { eventqueue.invokelater(new runnable() { public void run() { try { vozenred frame = new vozenred(); frame.setvisible(true); } catch (exception e) { e.printstacktrace(); } } }); } /** * create frame. * @return */ public void pishi(){ //tried deleting here hashtable<broj, elementi> h1=new hashtable<broj, elementi>(); try { broj b=new broj(idbox.gettext()); elementi elem=new elementi(initialbox.gettext(), finalbox.gettext(), hbox.gettext(), mbox.gettext(), pricebox.gettext(), agencybox.gettext()); h1.put(b , elem); } catch(exception e)//i tried nullpointerexception still same { system.out.println("asd");//not realy meant } } //deleting here, still no frame public void vozenred1() { settitle("transport me"); setdefaultcloseoperation(jframe.exit_on_close); setbounds(100, 100, 502, 396); contentpane = new jpanel(); contentpane.setborder(new emptyborder(5, 5, 5, 5)); setcontentpane(contentpane); contentpane.setlayout(null); jbutton initialdestination = new jbutton("initial destination"); initialdestination.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "input initial destination, i.e. home", "initial destination", 2); } }); initialdestination.setbounds(255, 63, 194, 23); contentpane.add(initialdestination); jbutton finaldestination = new jbutton("final destination"); finaldestination.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "input final destination, i.e. home", "final destination", 2); } }); finaldestination.setbounds(255, 97, 194, 23); contentpane.add(finaldestination); jbutton timedeparture = new jbutton("departure time"); timedeparture.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "input time, hours in first box, minutes in second box, i.e. 00:00", "departure time", 2); } }); timedeparture.setbounds(255, 128, 194, 23); contentpane.add(timedeparture); jbutton ticketprice = new jbutton("ticket price"); ticketprice.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null,"input price, digits only, i.e. 100","ticketprice",2); } }); ticketprice.setbounds(255, 159, 194, 23); contentpane.add(ticketprice); transporter = new jbutton("transport agency"); transporter.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null,"input transporter name, i.e. mytrans","transporter",2); } }); transporter.setbounds(255, 190, 194, 23); contentpane.add(transporter); jbutton saveroute = new jbutton("save route"); saveroute.setbounds(255, 320, 194, 23); contentpane.add(saveroute); delete = new jbutton("delete"); delete.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { } }); delete.setbounds(255, 286, 194, 23); contentpane.add(delete); jbutton destinations = new jbutton("destinations"); destinations.setbounds(255, 252, 194, 23); contentpane.add(destinations); jlabel inputlabel = new jlabel("input elements"); inputlabel.setbounds(44, 11, 211, 14); contentpane.add(inputlabel); jlabel commandslabel = new jlabel("additional commands"); commandslabel.setbounds(44, 222, 201, 14); contentpane.add(commandslabel); jbutton identificationnumber = new jbutton("identification number"); identificationnumber.addactionlistener(new actionlistener() { public void actionperformed(actionevent arg0) { joptionpane.showmessagedialog(null, "enter identification number , numbers, i.e. 0123","identificationnumber", 2); } }); identificationnumber.setbounds(255, 29, 194, 23); contentpane.add(identificationnumber); jbutton clearall = new jbutton("clear all"); clearall.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { idbox.settext(null); initialbox.settext(null); finalbox.settext(null); hbox.settext(null); mbox.settext(null); pricebox.settext(null); agencybox.settext(null); } }); clearall.setfont(new font("tahoma", font.bold, 11)); clearall.setbounds(255, 218, 194, 23); contentpane.add(clearall); jlabel lblhelpbuttons = new jlabel("help buttons"); lblhelpbuttons.setbounds(314, 11, 76, 14); contentpane.add(lblhelpbuttons); jbutton helpdestinations = new jbutton(""); helpdestinations.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "outputs destinations in new box","destinations", 2); } }); helpdestinations.setbounds(459, 252, 17, 23); contentpane.add(helpdestinations); jbutton helpdelete = new jbutton(""); helpdelete.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "deletes selected identification","delete", 2); } }); helpdelete.setbounds(459, 286, 17, 23); contentpane.add(helpdelete); jbutton helpsave = new jbutton(""); helpsave.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "choose directory save","save document", 2); } }); helpsave.setbounds(459, 320, 17, 23); contentpane.add(helpsave); jbutton helpclearall = new jbutton(""); helpclearall.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "clears boxes above","clear all", 2); } }); helpclearall.setbounds(459, 218, 17, 23); contentpane.add(helpclearall); jbutton identificationhelpbutton = new jbutton(""); identificationhelpbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { idbox.settext(null); } }); identificationhelpbutton.setbounds(10, 29, 17, 23); contentpane.add(identificationhelpbutton); jbutton initialdestinationhelpbutton = new jbutton(""); initialdestinationhelpbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { initialbox.settext(null); } }); initialdestinationhelpbutton.setbounds(10, 60, 17, 23); contentpane.add(initialdestinationhelpbutton); jbutton finaldestinationhelpbutton = new jbutton(""); finaldestinationhelpbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent arg0) { finalbox.settext(null); } }); finaldestinationhelpbutton.setbounds(10, 97, 17, 23); contentpane.add(finaldestinationhelpbutton); jbutton departuretimehelpbutton = new jbutton(""); departuretimehelpbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { hbox.settext(null); mbox.settext(null); } }); departuretimehelpbutton.setbounds(10, 129, 17, 23); contentpane.add(departuretimehelpbutton); jbutton ticketpricehelpbutton = new jbutton(""); ticketpricehelpbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { pricebox.settext(null); } }); ticketpricehelpbutton.setbounds(10, 159, 17, 23); contentpane.add(ticketpricehelpbutton); jbutton transporterhelpbutton = new jbutton(""); transporterhelpbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { agencybox.settext(null); } }); transporterhelpbutton.setbounds(10, 190, 17, 23); contentpane.add(transporterhelpbutton); jlabel label = new jlabel(" :"); label.setbounds(113, 132, 39, 14); contentpane.add(label); jbutton savedocumentbutton = new jbutton(""); savedocumentbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { savebox.settext(null); } }); savedocumentbutton.setbounds(10, 320, 17, 23); contentpane.add(savedocumentbutton); idbox = new jtextfield(); idbox.setbounds(44, 30, 201, 20); contentpane.add(idbox); idbox.setcolumns(10); initialbox = new jtextfield(); initialbox.setcolumns(10); initialbox.setbounds(44, 64, 201, 20); contentpane.add(initialbox); finalbox = new jtextfield(); finalbox.setcolumns(10); finalbox.setbounds(44, 98, 201, 20); contentpane.add(finalbox); hbox = new jtextfield(); hbox.setcolumns(10); hbox.setbounds(44, 129, 86, 20); contentpane.add(hbox); pricebox = new jtextfield(); pricebox.setcolumns(10); pricebox.setbounds(44, 160, 201, 20); contentpane.add(pricebox); agencybox = new jtextfield(); agencybox.setcolumns(10); agencybox.setbounds(44, 191, 201, 20); contentpane.add(agencybox); savebox = new jtextfield(); savebox.setcolumns(10); savebox.setbounds(44, 321, 201, 20); contentpane.add(savebox); mbox = new jtextfield(); mbox.setcolumns(10); mbox.setbounds(145, 129, 100, 20); contentpane.add(mbox); deletebox = new jtextfield(); deletebox.setcolumns(10); deletebox.setbounds(44, 287, 201, 20); contentpane.add(deletebox); destinationsbox = new jtextfield(); destinationsbox.setcolumns(10); destinationsbox.setbounds(44, 253, 201, 20); contentpane.add(destinationsbox); jbutton deletehelpbutton = new jbutton(""); deletehelpbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { deletebox.settext(null); } }); deletehelpbutton.setbounds(10, 286, 17, 23); contentpane.add(deletehelpbutton); jbutton destinationhelpbutton = new jbutton(""); destinationhelpbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { destinationsbox.settext(null); } }); destinationhelpbutton.setbounds(10, 252, 17, 23); contentpane.add(destinationhelpbutton); } }
looks code never calls ui stuff in vozenred1()
.
you create vozenred
object, calls empty constructor, set visible. never calling vozenred1()
.
Comments
Post a Comment