ERROR with my JAVA code 3 Answer(s) 2 years and 9 months ago
Posted in : Java Beginners
The error came up in my main method... it wasnt there until i finished my actionListener coding so I dont know how to fix this....it is really stressing me out!! HELP!!!
public class FinalProject extends JFrame implements ActionListener { JLabel textPrompt; JTextArea inputText; JLabel keyPrompt; JTextField inputKey; Container container;
public FinalProject() { super( "Final Project " );
JTabbedPane tab = new JTabbedPane();
// constructing the Pool Panel
JPanel p1 = new JPanel(); JLabel label4,label5,lable6; final JTextField text4,text5,text6,text13; label4 = new JLabel(); label4.setText("Height:"); p1.add(label4); text4 = new JTextField(20); p1.add(text4); JLabel space3 = new JLabel(" "); p1.add(space3); label5 = new JLabel(); label5.setText("Width:"); p1.add(label5); text5 = new JTextField(20); p1.add(text5); JLabel space5 = new JLabel(" "); p1.add(space5); lable6 = new JLabel(); lable6.setText("Depth:"); p1.add(lable6); text6 = new JTextField(20); p1.add(text6); JLabel space2 = new JLabel(" "); p1.add(space2); JButton button = new JButton("Enter"); p1.add(button); tab.addTab( "Pool", null, p1, " Pool" ); text13 = new JTextField(); p1.add(text13); button.addActionListener(this); new ActionListener(){ public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String choice = e.getActionCommand(); int length=Integer.parseInt(text4.getText()); int width=Integer.parseInt(text5.getText()); int depth=Integer.parseInt(text6.getText());
if (e.getActionCommand().equals("Enter")) {
int volume = ((length * width) * depth); JOptionPane.showMessageDialog(null, "The Volume is:"+volume,"for your pool.", JOptionPane.INFORMATION_MESSAGE); } } };
// constructing the Hot Tube panel
JLabel l2 = new JLabel("Hot Tube"); JPanel p2 = new JPanel(); JLabel label7,label8,lable9; final JTextField text7,text8,text9;{ label7 = new JLabel(); label7.setText("Height:"); p2.add(label7); text7 = new JTextField(20); p2.add(text7); JLabel space6 = new JLabel(" "); p2.add(space6); label8 = new JLabel(); label8.setText("Width:"); p2.add(label8); text8 = new JTextField(20); p2.add(text8); JLabel space7 = new JLabel(" "); p2.add(space7); lable9 = new JLabel(); lable9.setText("Depth:"); p2.add(lable9); text9 = new JTextField(20); p2.add(text9); JLabel space8 = new JLabel(" "); p2.add(space8); JRadioButton rbutton = new JRadioButton("Oval"); p2.add(rbutton); JRadioButton rbutton1 = new JRadioButton ("Round"); p2.add(rbutton1); JButton button2 = new JButton("Enter"); p2.add(button2); tab.addTab( "Hot Tube", null, p2, " Hot Tube" ); rbutton.addActionListener(this); rbutton1.addActionListener(this); button2.addActionListener(this);
new ActionListener(){ public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String choice = e.getActionCommand(); int length=Integer.parseInt(text7.getText()); int width=Integer.parseInt(text8.getText()); int depth=Integer.parseInt(text9.getText());
if(choice.equals("Oval")){ int volume = ((length * width) * depth); JOptionPane.showMessageDialog(null, "The Volume is:"+volume,"" + "for your oval hot tube.", JOptionPane.INFORMATION_MESSAGE); } else if(choice.equals("Round")){ int volume1= (((length/2)^2) * depth); JOptionPane.showMessageDialog(null, "The Volume is:"+volume1,"" + "for your round hot tube.", JOptionPane.INFORMATION_MESSAGE); } } };
// constructing the Temperature Change panel
JLabel l3 = new JLabel( " Temperature Change!" ); JPanel p3 = new JPanel(); JLabel label10; final JTextField text10; label10 = new JLabel(); label10.setText("Temperature:"); p3.add(label10); text10 = new JTextField(20); p3.add(text10); JButton button3 = new JButton("Enter"); p3.add(button3); JCheckBox boxF = new JCheckBox("F"); p3.add(boxF); JCheckBox boxC = new JCheckBox("C"); p3.add(boxC); tab.addTab( "Temperature Change", null, p3, " Temperature Change" ); button3.addActionListener(this); boxF.addActionListener(this); boxC.addActionListener(this); new ActionListener(){ public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String choice = e.getActionCommand(); int temperature=Integer.parseInt(text10.getText()); if(choice.equals("C")){ int temp = (( temperature* 9)/5+32); JOptionPane.showMessageDialog(null, "The Celcuis temperature is changed to:" +temp,"" + "in fahrenheit", JOptionPane.INFORMATION_MESSAGE); } else if(choice.equals("F")){ int temp1= (((temperature - 32)/9)*5); JOptionPane.showMessageDialog(null, "The farhrenheight temperature is changed to:"+temp1,""+ "in Celcius.", JOptionPane.INFORMATION_MESSAGE); } } };
// constructing the Customer panel
JPanel p4 = new JPanel(); JLabel label1,label2; final JTextField text1,text2; label1 = new JLabel(); label1.setText("Name:"); p4.add(label1); text1 = new JTextField(20); p4.add(text1); JLabel space = new JLabel(" ");//MDB p4.add(space); label2 = new JLabel(); label2.setText("Address:"); p4.add(label2); text2 = new JTextField(20); p4.add(text2); JButton button4 = new JButton("Enter"); p4.add(button4); tab.addTab( "Customer", null, p4, " Customer" ); button4.setActionCommand ("Enter");
new ActionListener(){ public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String choice = e.getActionCommand(); int Name=Integer.parseInt(text1.getText()) ; int Address=Integer.parseInt(text2.getText());
public class FinalProject extends JFrame { JLabel textPrompt; JTextArea inputText; JLabel keyPrompt; JTextField inputKey,txt,txt1; Container container;
public FinalProject(){ super( "Final Project " ); JTabbedPane tab = new JTabbedPane(); JPanel p1 = new JPanel(); JLabel label4,label5,lable6; final JTextField text4,text5,text6; label4 = new JLabel(); label4.setText("Height:"); p1.add(label4); text4 = new JTextField(20); p1.add(text4); JLabel space3 = new JLabel(" "); p1.add(space3); label5 = new JLabel(); label5.setText("Width:"); p1.add(label5); text5 = new JTextField(20); p1.add(text5); JLabel space5 = new JLabel(" "); p1.add(space5); lable6 = new JLabel(); lable6.setText("Depth:"); p1.add(lable6); text6 = new JTextField(20); p1.add(text6); JLabel space2 = new JLabel(" "); p1.add(space2); JButton button = new JButton("Enter"); p1.add(button); tab.addTab( "Pool", null, p1, " Pool" );
button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) {
String choice = e.getActionCommand(); int length=Integer.parseInt(text4.getText()); int width=Integer.parseInt(text5.getText()); int depth=Integer.parseInt(text6.getText());
int volume = ((length * width) * depth); JOptionPane.showMessageDialog(null, "The Volume is:"+volume,"for your pool.", JOptionPane.INFORMATION_MESSAGE); } });
JLabel l2 = new JLabel("Hot Tube"); JPanel p2 = new JPanel(); JLabel label7,label8,lable9; final JTextField text7,text8,text9; ButtonGroup gp=new ButtonGroup(); label7 = new JLabel(); label7.setText("Height:"); p2.add(label7); text7 = new JTextField(20); p2.add(text7); JLabel space6 = new JLabel(" "); p2.add(space6); label8 = new JLabel(); label8.setText("Width:"); p2.add(label8); text8 = new JTextField(20); p2.add(text8); JLabel space7 = new JLabel(" "); p2.add(space7); lable9 = new JLabel(); lable9.setText("Depth:"); p2.add(lable9); text9 = new JTextField(20); p2.add(text9); JLabel space8 = new JLabel(" "); p2.add(space8); txt = new JTextField(20); JRadioButton rbutton = new JRadioButton("Oval"); p2.add(rbutton); JRadioButton rbutton1 = new JRadioButton ("Round"); p2.add(rbutton1); JButton button2 = new JButton("Enter"); gp.add(rbutton); gp.add(rbutton1); p2.add(button2); p2.add(txt); txt.setVisible(false); tab.addTab( "Hot Tube", null, p2, " Hot Tube" ); rbutton.addActionListener(al); rbutton1.addActionListener(al); button2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String choice=txt.getText(); int length=Integer.parseInt(text7.getText()); int width=Integer.parseInt(text8.getText()); int depth=Integer.parseInt(text9.getText());
if(choice.equals("Oval")){ int volume = ((length * width) * depth); JOptionPane.showMessageDialog(null, "The Volume is:"+volume,"" +"for your oval hot tube.", JOptionPane.INFORMATION_MESSAGE); } else if(choice.equals("Round")){ int volume1= (((length/2)^2) * depth); JOptionPane.showMessageDialog(null, "The Volume is:"+volume1,"" +"for your round hot tube.", JOptionPane.INFORMATION_MESSAGE); } } });
August 28, 2010 at 12:07 PM
continue..
JLabel l3 = new JLabel( " Temperature Change!" ); JPanel p3 = new JPanel(); JLabel label10; final JTextField text10; label10 = new JLabel(); label10.setText("Temperature:"); p3.add(label10); text10 = new JTextField(20); p3.add(text10); JButton button3 = new JButton("Enter"); p3.add(button3); JCheckBox boxF = new JCheckBox("F"); p3.add(boxF); JCheckBox boxC = new JCheckBox("C"); p3.add(boxC); txt1=new JTextField(20); p3.add(txt1); tab.addTab( "Temperature Change", null, p3, " Temperature Change" ); ButtonGroup gp1=new ButtonGroup(); boxF.addActionListener(il); boxC.addActionListener(il); gp1.add(boxF); gp1.add(boxC); txt1.setVisible(false); button3.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String choice = txt1.getText(); int temperature=Integer.parseInt(text10.getText()); if(choice.equals("C")){ int temp = (( temperature* 9)/5+32); JOptionPane.showMessageDialog(null, "The Celcuis temperature is changed to:"+temp,"" +"in fahrenheit", JOptionPane.INFORMATION_MESSAGE); } else if(choice.equals("F")){ int temp1= (((temperature - 32)/9)*5); JOptionPane.showMessageDialog(null, "The farhrenheight temperature is changed to:"+temp1,""+"in Celcius.", JOptionPane.INFORMATION_MESSAGE); } } }); JPanel p4 = new JPanel(); JLabel label1,label2; final JTextField text1,text2; label1 = new JLabel(); label1.setText("Name:"); p4.add(label1); text1 = new JTextField(20); p4.add(text1); JLabel space = new JLabel(" "); p4.add(space); label2 = new JLabel(); label2.setText("Address:"); p4.add(label2); text2 = new JTextField(20); p4.add(text2); JButton button4 = new JButton("Enter"); p4.add(button4); tab.addTab( "Customer", null, p4, " Customer" ); button4.setActionCommand ("Enter"); button4.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String choice = e.getActionCommand(); String Name=text1.getText() ; String Address=text2.getText(); if (e.getActionCommand().equals("Enter")) { JOptionPane.showMessageDialog(null, "Customer's name is:"+Name+"Their address is:"+Address); } } });
JLabel l5 = new JLabel( "General" ); JPanel p5 = new JPanel(); Date date = new Date(); SimpleDateFormat dateformatMMDDYYYY = new SimpleDateFormat("MM/dd/yyyy"); StringBuilder nowMMDDYYYY = new StringBuilder( dateformatMMDDYYYY.format( date ) ); JLabel space11 = new JLabel(" "); p5.add(space11); JLabel space12 = new JLabel(" "); p5.add(space12); JLabel space13 = new JLabel(" "); p5.add(space13); JLabel label11; label11 = new JLabel(); label11.setText("Today's Date is:"); p5.add(label11); JLabel texta1; texta1 = new JLabel(); texta1.setText(dateformatMMDDYYYY.format(date)); p5.add(texta1); tab.addTab( "General", null, p5, " Today's Date");
JPanel p6 = new JPanel(); JLabel label3; final JTextField text3; label3 = new JLabel(); label3.setText("Manufacture:"); p6.add(label3); text3 = new JTextField(20); p6.add(text3); JLabel space1 = new JLabel(" "); p6.add(space1); tab.addTab( "Manufacture", null, p6, " Manufacture" ); JButton button6 = new JButton("Enter"); p6.add(button6); button6.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String choice = e.getActionCommand(); int Manufacture=Integer.parseInt(text3.getText()) ; if (e.getActionCommand().equals("Enter")) { JOptionPane.showMessageDialog(null, "Manufacture's name is:"+Manufacture,"", JOptionPane.INFORMATION_MESSAGE); } } });
August 28, 2010 at 12:08 PM
continue..
JLabel l7= new JLabel("Customer Comments?"); JPanel p7 = new JPanel(); JPanel enterPanel = new JPanel( ); textPrompt = new JLabel("Customer comments:"); inputText = new JTextArea(5, 15); inputText.setLineWrap(true); inputText.setWrapStyleWord(true);
getContentPane().add( tab ); setSize( 400, 250 ); setVisible( true ); JButton button7 = new JButton("Enter"); p7.add(button7); tab.addTab ("Customer Comments?",null,p7,"Customer Comments?"); button7.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String choice = e.getActionCommand(); String Comments=inputText.getText() ; if (e.getActionCommand().equals("Enter")) { JOptionPane.showMessageDialog(null, "Customer's comment:"+Comments,"", JOptionPane.INFORMATION_MESSAGE); } } }); } private ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent e) { txt.setText(((JRadioButton) e.getSource()).getText()); } }; private ActionListener il = new ActionListener() { public void actionPerformed(ActionEvent e) { txt1.setText(((JCheckBox) e.getSource()).getText()); } }; public static void main( String args[] ){ FinalProject demo = new FinalProject(); demo.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } }
Thanks
Related Pages:
ERROR with my JAVA code - Java Beginners ERROR with myJAVA code The error came up in my main method... it wasnt there until i finished my actionListener coding so I dont know how to fix this....it is really stressing me out!! HELP!!!
import java.awt.*;
import
Error in a code. - Java Beginners Error in a code. This is the question I posted yesterday:
"I'm.... I'm confused about where and what i should put into the overall code. Also I can't quite figure out how to write the code for the GUI. Could anyone please help
i am unable to identify the error in my code
i am unable to identify the error in my code class Program
{
public static void main(String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter
i am unable to identify the error in my code
i am unable to identify the error in my code class Program
{
public static void main(String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter
What's wrong with my pagination code in JSP?
What's wrong with my pagination code in JSP? Dear experts,
I've tried the following codes which I have copied from Java Ranch forum and deleted whatever lines that NetBean IDE has given me error signal.
The resulted page
java runtime error: JDBC code - Java Beginners java 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
Code error Code error package trail;
import...)
read.close();
}
}
}
While using this it shows error as:
run...(ClassLoader.java:247)
... 17 more
Java Result: 1
BUILD SUCCESSFUL (total time: 9
My Sql Error - Development process My Sql Error Hello Sir ,I have Created Table with following Query,then Table Created Succefully,But some errors Occured,
can u give me the Code...,Its Very Very Urgent.
Thank u very Much for urs Great Support in My
this is my code java - Date Calendar
this is mycode java /*
* NewJFrame.java
*
* Created on 11... NOT modify this code. The content of this method is
* always regenerated...;
jTextField1.setText(months); #### This My problem
jTextField2.setText(days
java Compilation error:jsp code - JSP-Servlet java Compilation error:jsp code I am getting an Generated Servlet error:
String literal is not properly closed by a double-quote.
here is mycode:
<%
{
Dbclass2 d= new Dbclass2
Problem in my code - Development process
Problem in my code Plz go thru this code. I want to check login and pwd with database.
Backend MsAccess , Table name : Reg , Dsn Name: JJ
While executing code am getting 404 error
User Name
Password
error
"+it);
}
}
this is my program i am getting an error saying cannot find symbol class string... inside the method 'accept()'. Here is your modified code:
import java.util.
pls review my code - Struts
pls review my code Hello friends,
This is the code in struts. when i click on the submit button.
It is showing the blank page. Pls respond soon...("error in connecting database");
}
return null
Syntax error in my UPDATE..please advise
Syntax error in my UPDATE..please advise Hi experts,
I tested mycode and NetBean IDE gave me the following message:-
You have an error...)
And here's my UPDATE Statement:
String sql = "UPDATE members SET strNRICNO
my answer my answer import com.mysql.jdbc.Connection;
import...-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected... {
/*
* TODO output your page here. You may use following sample code
doubt in my program code - Java Beginners
doubt in my program code i have developed a web browser with the help of standard widget toolkit(swt) and java. i creted some buttons such as GO... the code i developed i can send u to ur mail if u give ur mail id
anyone willing to look over my code? (java)
anyone willing to look over mycode? (java) package inorder.without.cheats;
import java.util.Arrays;
import javax.swing.JOptionPane;
public class InOrderWithOutCheats {
public static void main(String[] args
how can i simplify my java code
how can i simplify myjava code /*
Create a program that prompts the user to enter a password. Display a suitable message for each
correct... Scanner (System.in);
String pass="";
int c = 1;
int code=0
Error in Code - Development process Error in Code Hi; This is mycode to get all d records from View_Service table
but am getting error. I just copied this from net.I am doing mini project
plz send me code to get records. What action should i mention
error in java code - Java Beginners error in java code Hi
Can u say how to communication between systems in a network. Hi friend,
A method for controlling an operation.../java/network/index.shtml
Thanks
Java code error - Java Beginners Javacode error Hi,
I am using a MooreQuery to look for neighbors in a grid:
MooreQuery query = new MooreQuery(grid, this,(int) (2*myHomeRangeRadius), (int) (2*myHomeRangeRadius));
if(query != null){
for (Object
JAVA Error - Java Beginners JAVA Error i have made my own calculator GUI..and i want the text... but when i used this code:
JButton btnBack=new JButton("Backspace");
btnBack.setForeground(red);
it send me an error message that goes like this unknown
error message - Java Beginners error message sir,
while i m trying to execute my first program(print my name)I get error message like" javac is not recognized as internal... and run java programs.
i am sending simple javacode,
public class Hello
Java error code JavaerrorcodeJavaErrorcode are the set of error that occurs during the compile-time and
Run-time. From javaerror we have given you a sample of code
My name, java project My name, java project Write a class that displays your first name... displayLetterA()
{
code goes in here
},
...and my names hayley ... anyone... letter being displayed should have the lines of code needed to
display
My name, java project My name, java project Write a class that displays your first name... displayLetterA()
{
code goes in here
},
...and my names hayley ... anyone... letter being displayed should have the lines of code needed to
display
Snippet Code Error
Snippet Code Error The following is a snippet of code from a Java application which uses Connector/J to query a MySQL database. Identify possible problems and possible solutions.
Connection cn= DriverManager.getConnection
Please help me to modify my java code from php code
Modify Javacode from PHP Code i want to covert this php code int java/JSP.
if (isset($_POST['orders'])) {
$orders = explode('&', $_POST...];
}
}
I tried like this (see below JSP code) ... but this is not giving me
Please help me to modify my java code from php code
Please help me to modify myjavacode from php code i want to covert this php code int java/JSP .
if (isset($_POST['orders'])) {
$orders...]);
$array[] = $item[1];
}
}
I tried like this (see below JSP code
Java Program MY NAME Java Program MY NAME Write a class that displays your first name vertically down the screen where each letter uses up to 5 rows by 5 columns... should have the lines of code needed to display that
letter in a method
My first Java Program My first Java Program I have been caught with a practical exam to do the following:
Write a program that takes input from a user through... You may not "cut off" any words in the middle
I can be able to code step 1
Some additions for my previous question - Java Beginners
Some additions for my previous question This is the question I... into the overall code. Also I can't quite figure out how to write the code for the GUI. Could anyone please help?"
So my other two questions are:
1
java runtime error - JDBC java runtime error when i am running my jdbc program using thin driver this error is coming at runtime:
Exception in thread "main..., give me the suggesion yo solve this problem This kind of error due
jsp code error - Java Beginners
jsp code error Hi,
I have a problem with following code... part. Is it possible to display a message box or alert box in jsp code??. plz help...; Hi friend ,
Try this code:
/*out.println("Login Failed
java compilation error - Java Beginners error for my program to run. The error I keep getting is unclosed string literal...
and this is when my compiler error occurs. Let me know if you need any... occurs.Even then if you found error,send the full code.
Thanks
Error - Java Beginners
Error Hai I am sending my two files.This is for conversion of String to hex.
Please have a look on the code. In jsp page I got errors.
Error No 1:Incompatible type found,java.lang.objectrequired,java.lang.string.
Error
java compilation error - Java Beginners
writing mycode through command line instead of a note pad but while compiling I'm getting the error like file not found : exxx.java(my file name is exx),
Ill...java compilation error Dear Sir ........
I was installed the java
java compilation error - Java Beginners
. It's flagging two errors for this one code. The first error says identifier.... This is what mycode looks like:
};
private JButton nextButton = newJButton...java compilation error Hello,
I'm having problems with trying
readline Error - Java Beginners
readline Error Hi sir, please helpme with mycode.
Mycode does...; Hi Friend,
Your code works fine here.
Thanks The error is hard to pust. but if you execute the code,
1. enter a string the first input
Compile error - Java Beginners
Compile error I get this error when compiling my program:
java:167...
This is an example of mycode:
import java.io.*;
import java.util.*;
import... on the end of line in mycode so I don't count this
// you have to determine
Compilation error in java - Java Beginners
that file in java class,mycode is
Properties props = new Properties();
File...Compilation error in java i have a properties file named... FileInputStream(f);
props.load(in);
but i got a error the system could
Logical error - Java Magazine
Logical error hi guys...
I am facing some probleam in do-while loop so
plz check out mycode and inform me whats wrong with this code
thanks.....
import java.io.*;
class searchex
{
String str=new String
Error processing Java: Error processing
Error in user input or action
If the user makes an error in input, give the appropriate feedback,
and allow them to correct... in processing" as
the error message. There was no hint as to whether is was myerror
java compilation error - Java Beginners
);
MYERROR FLAGS HERE public class DisplayImage extends Panel {
BufferedImage image;
public DisplayImage() {
try{
MY SECOND ERROR FLAGS HERE...java compilation error Hello,
I had recently sent an email
java runtime error - Java Beginners java runtime error sir,
i have installed jdk in my system.i had... friend,
Please send source code and explain in detail.
I am sending you...://www.roseindia.net/java/java-classpath.shtml
Thanks
java compilation error - Java Beginners java compilation error Hello,
I sent a previous message regarding... the codes I still received this message. My program compiles with no errors but I just can't run it
ProductInventoryVGUI
Uncaught error fetching image
jsp code error - JSP-Servlet
jsp code error hello,
is anyone here who can solve my problem.
what happen experts where r u? r u not able to do
jsp code error - JSP-Servlet
jsp code error hello,
is anyone here who can solve my problem.
what happen experts where r u?
or
u r not able to do