code related problem



Share on Google+Share on Google+

shipra gupta
code related problem
1 Answer(s)      6 years and 8 months ago
Posted in : Java Beginners

this code is compiling but not running please help

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Mybutton11 extends JFrame { JTextField text1 = new JTextField(20); JButton button1; JButton button2 ; JFrame frm;

public Mybutton11() { new JFrame("issuing form"); JLabel lbl = new JLabel("Please fill:"); frm.add(lbl); frm.setSize(500,500); frm.setVisible(true); frm.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0);
} }); JPanel p = new JPanel(); JPanel p1 = new JPanel(); p.setLayout(new GridLayout(3,1)); JLabel label1=new JLabel("Enter your name:", Label.RIGHT); JLabel label2=new JLabel("Enter your age:", Label.RIGHT); JTextField text2 = new JTextField(20); JLabel label3=new JLabel("Enter your course:", Label.RIGHT); JTextField text3 = new JTextField(20); p.add(text1); p.add(text2); p.add(text3); p.add(label1); p.add(label2); p.add(label3); new JButton("SUBMIT"); p.add(button1); new JButton("EXIT"); p.add(button2); p1.add(p); frm.add(p1,BorderLayout.NORTH); button1.addActionListener(new ButtonListener()); button2.addActionListener(new ButtonListener()); }

public class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { if(e.getSource()==button1) { String name = text1.getText(); if(name.length()==0) { JOptionPane.showMessageDialog(null,"u didnt enter anything"); } JOptionPane.showMessageDialog(null, "Hello!! " + name); } //text1.requestFocus(); if(e.getSource()==button2) { frm.setDefaultCloseOperation(JFrame.EXITONCLOSE); } } } public static void main(String[] args) throws Exception { Mybutton11 m = new Mybutton11(); } }

View Answers

March 24, 2011 at 4:06 PM


JFrame frm=new JFrame("issuing form");

outside the Mybutton11() constructor.

After this update, your frame will be visible.

For more detail go to this link


Related Tutorials/Questions & Answers:
code related problem
code related problem  this code is compiling but not running please help import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Mybutton11 extends JFrame { JTextField text1 = new JTextField(20
problem related to onSubmit() method
problem related to onSubmit() method  Hello, I am developing application.when i submit form at that time formBacking() method is call...Instead of that onSubmit() should have to call .... please help me
JDBC related Problem - JDBC
JDBC related Problem  Hey plz check out the following code... connectivity code ...... my problem is... that even after the successful... the other the access from the database is successful the problem is only arising
JDBC ODBC related problem
JDBC ODBC related problem  i WANT HELP RELATED TO JDBC CONNECTIVITY WITH MS ACCESS.. HERE IS MY FULL CODE... import java.awt.Container; import...[]) { New_Customer v = new New_Customer() {}; } } AS I SHOW IN CODE
Need the Following MobileApplication Related Code
Need the Following MobileApplication Related Code  Hi, I need java coding for the following requirements in Collections.. Mobile Subscriber name... can provide code in switch cases,I feel more happy. Please reply me ASAP
code problem:ajax - Ajax
code problem:ajax  Hi,I am using ajax to populate a select box.for this I am writing out.write("ONE"); like runs fine in not in IE.Can anyone help me out this... thanks
Hibernate code problem - Hibernate
Hibernate code problem  Hi, This is Birendra Pradhan.I want... in the DAO.Can it be possibe. Please send some sample code.. thanks & Regards Birendra  Hi friend, For solving the problem visit
code problem - Java Beginners
code problem  Dear sir, my problem is that I've a string value if this String value has "quit" then output should be "bye". i want to make this program using SWITCH CASE statement. how to implement String value in Switch plz
code problem - Java Beginners
code problem  Dear sir, I'm havin a problem that suppose i've got... java script j2ee j2me sql plz help me to sort out this problem. thnx   Hi Friend, Please try the following sample code to solve your problem
problem with code - Ajax
problem with code  hi friends i am sending a code in that when we... to use ajax i wrote the code of jsp and the remaning code by using ajax is not wrritened by observing these below code please try the remainning ajax code its
Hibernate code problem - Hibernate
problem please send me code. Visit for more information. http...Hibernate code problem  Hi This is Raju.I tried the first example........How can i solve this problem. Am i need to Kept any other jars in path. 
Problem with code - Java Beginners
Problem with code  Hi Deepak. Im a newbie here at your forum. I have got a simple code of mine which is having a little problem. When I compile it, i get an...,identifier expected'...error. Could you help me out? Thank you
hibernate code problem - Hibernate
/selectclause.shtml If you have any problem this send me detail and source code...hibernate code problem  suppose i want to fetch a row from the table through a value which i got from the jsp page. how can i do it and iterate
code problem - Java Beginners
code problem  Dear sir, My problem is that i have some string value and in some case i want to remove all the value of this string, i tried this code- Response.str.clear(); but it shows some error called "response package
code problem - Java Beginners
code problem  Dear sir, my problem is given below: suppose a file Carries the following lines- Name: john age: 45 Address: goa phone...; Hi friend, Code to help in solving the problem : import
code problem - Java Beginners
code problem  Dear sir, my question was actually how to find a particual line's contain, example if a file contains- hy, how r u? regrd, john... your problem in details. Which keyword search the line. Thanks
combo box code problem
combo box code problem  in this my problem related to : when i select state MP then i wil open the its corresponding city but in database it only stores the option value no like MP at option value 10 then it will stores the 10
code problem - Java Beginners
of program. thnx  Hi friend, Code to help in solving the problem...code problem  Dear sir, I've some integer value in ArrayList like- 10 40 30 i want to add them and print should be like- "total value
code problem - Java Beginners
code problem  Dear sir, I have an excel file in D: drive called today.xls, i want to open it thru java program, what code would be compatible plz help me  Hi friend, Code to help in solving the problem : import
problem:struts code - Struts
problem:struts code  Hi, Am using struts1.2.I wrote a form(dynavalidator form)with validation after completing the form if we press submit its call the action class,in action class i gave forward to same form,the problem is if i
code problem - Java Beginners
code problem  Dear sir, my problem is that, i have two Combobox one.... plz tell how to code this program.   Hi Friend, You can use the following code: ComboBox var arr = new Array(); arr[0] = new
code problem - Java Beginners
code problem  Dear sir, I've some string called "JohnSon" that has to be crypted first and then decrypted, how to crypt and decrypt data plz tell me.  Hi friend, Code to help in solving the problem : public
code problem - Java Beginners
; Hi friend, Code to help in solving the problem : import problem  Dear Sir, I've to make a program where there are 10 lines of a particular file i've to display every Line's contains, example- Line1
code problem - Struts
code problem  hi friends i have 1 doubt regarding how to write the code of opensheet in action class i have done it as the action class code...(); System.out.println(conn); //Code to generate new sheet i.e login time IS NULL
Application context problem code
Application context problem code   now i am posting my code here . i..."); // code to set test action environment createAction("/create", "Test", "list"); // code to execute test action String result = proxy.execute(); // code
code problem - Java Beginners
code problem  My code is below: import*; class FileRead...()); } } } Dear sir, my problem is that suppose i enter line number: 3 if line... your code and then again try it : import*; class FileRead
code problem - Java Beginners
code problem  i've to send a login packet( username & password..., what code should be compatible, as i heared with UDP programing there is no Guarantee of packet's delevery so send me code made of TCP, plz help me
Hibernate code problem - Hibernate
Hibernate code problem  how to write hibernate Left outer join program
Code problem - Java Beginners
Code problem  Hi. I want to create a drop down button,where the value will be hard coded and on selecting an option another drop down button... and these values will come from the database. Can anyone help me with the code
code for this problem - JSP-Servlet
code for this problem   i have buttom submit .It is working with single click.Suppose if i am At the same time clicking(parallel) twise second request will be stoped until process the proces first requst and terminate
Hibernate code problem - Hibernate
Hibernate code problem   Hi This is Raju I tried the first example of hibernate course material.This is to insert a record into CONTACT table.Is Hibernate code automatically creates the CONTACT table and then insert


Advertisement null