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); 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

Use

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

Ads









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
Advertisements
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
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
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
Java code problem
Java code problem  Please check the errors,if any,in this code...i am a java beginner import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map
Give me the source code for this problem
Give me the source code for this problem  Ram likes skiing a lot. That's not very surprising, since skiing is really great. The problem with skiing is one have to slide downwards to gain speed. Also when reached the bottom most
JSP code problem - JSP-Servlet
JSP code problem  HI.. I have a DB2 stored procedure wich return a result set. I have made a report basing on this procedure using Crystal Reports. How to pass parameters to this procedure with java code in a JSP page
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void main(String[]args)throws IOException{ BufferedReader br=new BufferedReader(new
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void main(String[]args)throws IOException{ BufferedReader br=new BufferedReader(new
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void main(String[]args)throws IOException{ BufferedReader br=new BufferedReader(new
Applet run with appletviewer but not in browser, any code problem.
Applet run with appletviewer but not in browser, any code problem.  Hi,My problem is when I am running my applet in appletviewer index.html, Its work... can be problem in code also. please check my code. 1) Card.java package
Problem with Java Source Code - Java Beginners
Problem with Java Source Code  Dear Sir I have Following Source Code ,But There is Problem with classes, plz Help Me. package mes.gui; import javax.swing.JOptionPane.*; import java.sql.*; import javax.swing.*; import
Given a security-related deployment descriptor tag, identify correct and incorrect statements and code related to that tag.
Given a security-related deployment descriptor tag, identify correct and incorrect statements and code related to that tag. Prev ... and incorrect statements and code related to that tag
Java Compilation error. Hibernate code problem. Struts first example - Hibernate
Java Compilation error. Hibernate code problem. Struts first example  Java Compilation error. Hibernate code problem. Struts first example
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration... RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException... in database as text and set the mobile field or telephone field as string in your code
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration... RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException... in database as text and set the mobile field or telephone field as string in your code
this is my code but i cant able to run it wt is the problem
this is my code but i cant able to run it wt is the problem  import java.io.*; class createthread { int thread=4,i; class thread1 extends createthread { public void run() { for(i=0;i
this is my code but i cant able to run it wt is the problem
this is my code but i cant able to run it wt is the problem  import java.io.*; class createthread { int thread=4,i; class thread1 extends createthread { public void run() { for(i=0;i
Problem
(); stdIn.close(); echoSocket.close(); } } this is my code, compiled
Problem
(); echoSocket.close(); } } this is my code, compiled with no errors, but when running giving
problem
;Hi, What do you want to do with this code. Please clarify
Related to Histogram
Related to Histogram  hi this is srinivasrao. In my project i have to display using chart for that i want to use histogram. k chart displayed but the values given by me is not related display chart so please give the code if u
StringBuffer related.
StringBuffer related.  how to make StringBuffer as immutable
Please can I get the code for solution of producer consumer problem using semaphores?
Please can I get the code for solution of producer consumer problem using semaphores?  Please can I get the code for solution of producer consumer problem using semaphores?   import java.util.*; class Semaphore
related to database
related to database  how to override existing values in table? when user enters his updated data through query
related to java
related to java  what is mean of }); in java.i know that } is used to close a block of statement,) is used to close a statement and ";"is used after close a statement but i can not usderstood the use of }); together in a java
Dumps related to weblogic certification
Dumps related to weblogic certification   I want to perform the weblogic certification exam code 1z0-110. Can anybody please provide me the dumps related to 1z0-110 Thanks in advance
Related Questions
Related Questions  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Related Questions... "Related Questions". Also tell me which is the good training courses
Related to Project
Related to Project  how speech to text project can be make in java? Please tell me the coding part therapeutically i know i have to use java speech api which offer two technology 1. speech recognization 2. speech syenthesis
Related to XML
Related to XML  I have made a web application which send the SMS, i have provided the url in which i have to save the msg and the number's(to whom the message to be send).After fetching the message and numbers i was keeping

Ads