Java runtime not working
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SwingFrame
{
public static void main(String[] args) throws Exception
{
SwingFrame1 sf=new SwingFrame1();
}
public SwingFrame(){
JFrame f = new JFrame("Frame in Java Swing");
f.getContentPane().setLayout(null);
JLabel lbl1 = new JLabel("Name");
JTextField jt1=new JTextField(15);
JLabel lbl2 = new JLabel("Age");
JTextField jt2=new JTextField(15);
JLabel lbl3 = new JLabel("Gender");
final JTextField txt=new JTextField(15);
JRadioButton Male,Female;
ButtonGroup radioGroup=new ButtonGroup();
Male=new JRadioButton("Male");
radioGroup.add(Male);
Female=new JRadioButton("Female");
radioGroup.add(Female);
JLabel lbl4=new JLabel("Branch");
final JComboBox jc=new JComboBox();
jc.addItem("Select");
jc.addItem("MCA");
jc.addItem("MBA");
jc.addItem("BE");
jc.addItem("BTech");
jc.addItem("Others");
lbl1.setBounds(100,120,70,30);
lbl2.setBounds(100,240,70,30);
lbl3.setBounds(100,340,70,30);
lbl4.setBounds(100,420,70,30);
jt1.setBounds(170,120,100,40);
jt2.setBounds(170,230,100,40);
Male.setBounds(170,340,100,40);
Female.setBounds(270,340,100,40);
jc.setBounds(170,420,100,40);
txt.setBounds(290,420,200,40);
jc.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e){
if(e.getSource() == jc) {
if(jc.getSelectedItem().equals("Others")){
txt.setVisible(true);
}
else{
txt.setVisible(false);
}
}
}
});
f.add(lbl1);
f.add(lbl2);
f.add(lbl3);
f.add(lbl4);
f.add(jt1);
f.add(jt2);
f.add(jc);
f.add(Male);
f.add(Female);
f.add(txt);
txt.setVisible(false);
f.setSize(1000,1000);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
The above program not running please check it and reply..
View Answers
February 2, 2010 at 11:22 AM
Hi Friend,
You are calling constructor of another class in the main() method instead of SwingFrame() therefore you have got that error.Anyways, here is your code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SwingFrame
{
public static void main(String[] args) throws Exception
{
SwingFrame sf=new SwingFrame();
}
public SwingFrame(){
JFrame f = new JFrame("Frame in Java Swing");
f.getContentPane().setLayout(null);
JLabel lbl1 = new JLabel("Name");
JTextField jt1=new JTextField(15);
JLabel lbl2 = new JLabel("Age");
JTextField jt2=new JTextField(15);
JLabel lbl3 = new JLabel("Gender");
final JTextField txt=new JTextField(15);
JRadioButton Male,Female;
ButtonGroup radioGroup=new ButtonGroup();
Male=new JRadioButton("Male");
radioGroup.add(Male);
Female=new JRadioButton("Female");
radioGroup.add(Female);
JLabel lbl4=new JLabel("Branch");
final JComboBox jc=new JComboBox();
jc.addItem("Select");
jc.addItem("MCA");
jc.addItem("MBA");
jc.addItem("BE");
jc.addItem("BTech");
jc.addItem("Others");
lbl1.setBounds(100,120,70,30);
lbl2.setBounds(100,240,70,30);
lbl3.setBounds(100,340,70,30);
lbl4.setBounds(100,420,70,30);
jt1.setBounds(170,120,100,40);
jt2.setBounds(170,230,100,40);
Male.setBounds(170,340,100,40);
Female.setBounds(270,340,100,40);
jc.setBounds(170,420,100,40);
txt.setBounds(290,420,200,40);
jc.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e){
if(e.getSource() == jc) {
if(jc.getSelectedItem().equals("Others")){
txt.setVisible(true);
}
else{
txt.setVisible(false);
}
}
}
});
f.add(lbl1);
f.add(lbl2);
f.add(lbl3);
f.add(lbl4);
f.add(jt1);
f.add(jt2);
f.add(jc);
f.add(Male);
f.add(Female);
f.add(txt);
txt.setVisible(false);
f.setSize(1000,1000);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Thanks
Related Tutorials/Questions & Answers:
Java runtime not working - Java BeginnersJava runtime not working import javax.swing.*;
import java.awt.... SwingFrame(){
JFrame f = new JFrame("Frame in
Java Swing");
f.getContentPane...("Frame in
Java Swing");
f.getContentPane().setLayout(null);
JLabel lbl1 = new
Advertisements
stuts java script validation is not working.stuts
java script validation is not
working. hello my stuts client side validation is not
working.
pls help me out i have put jsp file's code and validation.xml file's code.
pls help
--of jsp page
Get current working directory in Java Get current
working directory in
Java
In this section we will discuss about how to get the the current
working directory in
java. Current
working directory means the current
working directory where
java
program execute. In
java stuts java script validation is not working.stuts
java script validation is not
working. hello my stuts client side validation is not
working.
pls help me out i have put jsp file's code and validation.xml file's code.
pls help
--of jsp page--
> <html:form action
working wit string - Java Beginnersworking wit string accept a paragraph of text. consisting of sentences that are terminated by either '.' or '?' or '!' followed by a single space. assume that there can be maximum of five sentences in a paragraph. design
java runtime error - JDBCjava runtime error when i m running my program using type1 driver it is showing a
runtime error of SQLException of unable to create the connection object.please give the solution
Java Runtime
Java Runtime
In this section, you will learn about
Java Runtime
Environment (JRE), it also known as
Java Runtime. This is a part of
Java
Development Kit (JDK). It is a set
java runtime error - JDBCjava runtime error when i m running my program by using jdk1.6.0 then it is giving the error of classunsupported major.minor version 50.0.to remove it i installed jdk1.5 but now it is giving the classunsupported major.minor
runtime error in javaruntime error in java What is Run time error in
Java?
Run time error is a syntax error that during the execution of a program.It hash... the link, may this will be helpful for you.
http://www.roseindia.net/
java/
java java runtime error - JDBCjava runtime error when i m running my jdbc program it is giving the problem as class not found exception.so, please suggest me what may be the solution regarding this. Hi friend,
The problem is of Jar
runtime error - Java Beginnersruntime error I created a sample
java source ,compiled it succesfully using command prompt but when i tried to run i got the folowing error
" Exception in thread "main" java.lang.UnsupportedClassVersionError"
I have set
java runtime error - JDBCjava runtime error when i am running my jdbc program using thin driver this error is coming at
runtime:
Exception in thread "main... to this :
Thrown when the
Java Virtual Machine attempts to read a class file
java runtime error - JDBCjava runtime error sir when i m running the jsp connectivity program it is giving the error as follows:'
java.lang.NullPointerException
at jsp_servlet.__resplogin._jspService(__resplogin.java:237
java runtime exception - JDBCjava runtime exception while i executing this source code:-
import java.sql.*;
public class MysqlConnect
{
public static void main(String args[])
{
System.out.println("MySQL Connect Example
java runtime error - Java Beginnersjava runtime error import java.io.*;
class Test {
public static....(on checking JVM from java.com, it says my JVM is
working perfectly fine.)
pls reply... and set the following:
JAVA_HOME=C:\Program Files\
Java\jdk1.6.0;
Path=C
runtime error - Java Beginnersruntime error sir run time error is coming again in this code also
null pointer Exception at for( File f:contents)
import java.io.*;
public class RecentDocumentsDelete
{
public static void main(String[] args)
{
String
java runtime errorjava runtime error hi friends i am trying to run the fallowing program but i am getting the error
Exception in thread "main" java.lang.UnsupportedClassVersionError: JDBCCreateTab
le (Unsupported major.minor version 50.0
runtime error - Java Beginnersruntime error import java.io.*;
public class RecentDocumentsDelete
{
public static void main(String[] args)
{
String currentUser = System.getProperty("user.name");
System.out.println(currentUser
java runtime error - Java Beginnersjava runtime error sir,
i have installed jdk in my system.i had also set path.But i am unable to run the compiled class file.it shows run time...://www.roseindia.net/
java/
java-classpath.shtml
Thanks
htpasswd working htpasswd
working hii,
What does htpasswd do?
hello,ADS_TO_REPLACE_1
htpasswd creates a new user in a specified group, and asks to specify a password for that user
java runtime error - Development processjava runtime error I Migrated jdk1.3 to jdk1.4. after that my ftp clint not working.iam getting class not found exception fileinputstreem.
i am using sun package. can any one send pure
java code for FTP process i think jdk
hibernate.archive.autodetection not workinghibernate.archive.autodetection not working Hi,
What is the use of hibernate.archive.autodetection?
I am trying to use in my project but its not
working.
How to resolve hibernate.archive.autodetection not
working issue
Datagrid not workingDatagrid not working The code here is
working fine, apart from the fact that that I'm using netbeans 6.5 and the servlet v2.5 and struts 1.1....
working. please help me out
Java Runtime error - Java BeginnersJava Runtime error I have designed a simple chat application where the client and the server is the same computer itself. I have used the ipaddress of my computer and then designed a GUI application to interact between the two
JDBC:Runtime error - Java BeginnersJDBC:
Runtime error Dear sir/madam i am facing a problem with jdbc program.
When i run my program using NetBeans6.1 it is
working fine. When i try to run the program from command prompt it is giving error.
The follwing
How to create a Java Runtime Editor - Swing AWTHow to create a
Java Runtime Editor Hi,
I am
working on a requirement in which I need to integrate a
java runtime editor in swing application... using
java swing, try the following code:
import java.awt.BorderLayout
Why this is not working...?Why this is not
working...? import java.util.*;
public class Family {
int size_of_family=0;
public Person[] members=new Person[size_of_family];
Person d = new Person();
public Family (int size_of_family){
members = new
Error during runtime NoClassDefFound in javaError during
runtime NoClassDefFound in java code:
package Jama...;
/**
Working storage for nonsymmetric algorithm.
@serial
working storage...[n-1][n-1] - H[n][n]) / 2.0;
q = p * p + w;
z
Error during runtime NoClassDefFound in javaError during
runtime NoClassDefFound in java code:
package Jama...;
/**
Working storage for nonsymmetric algorithm.
@serial
working storage...[n-1][n-1] - H[n][n]) / 2.0;
q = p * p + w;
z
Code not workingCode not working i want to write my first applet. I wrote the
java program and html code for that. while im running in appletviewer it is asking for security permissions. so, i created a policy file and linked it with html file
If-else not workingIf-else not working <%@ page contentType="text/html; charset=utf-8" language="
java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>Untitled Document</title>
</head>
<
If-else not workingIf-else not working <%@ page contentType="text/html; charset=utf-8" language="
java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>Untitled Document</title>
</head>
<
Java runtime error - JSP-ServletJava runtime error Following Error is showing when i way scanner.acquire() can any body help me please
uk.co.mmscomputing.device.sane.SaneIOException: uk.co.mmscomputing.device.sane.SaneDeviceManager.getDevice
Java runtime example - JSP-ServletJava runtime example in eclipse after submiting the data throgh jsp page i got the following error
com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 1.
the code is:
Bean
java runtime error: JDBC code - Java Beginnersjava runtime error: JDBC code Hi i want to insert data into mysql database in my local system. I installed mysql5.0 and using mm.mysql-2.0.4-bin.jar and also set in the class path. the code is compilled and giving
runtime error