JFormattedTextField date = new JFormattedTextField( java.util.Calendar.getInstance().getTime()); date.setEditable(false); date.setBounds(150,15,150,20); general.add(date);
JButton quit = new JButton("Quit"); quit.setBounds(10,80,150,30); quit.addActionListener(this); quit.setBackground(Color.red); general.add(quit); } public void createPools(){ pools = new JPanel(); pools.setLayout( null );
JLabel lengthLabel = new JLabel( "Enter the length of swimming pool(ft):" ); lengthLabel.setBounds( 10, 15, 260, 20 ); pools.add( lengthLabel );
JButton newName = new JButton("Set New Name"); newName.setBounds(100,115,150,30); newName.addActionListener(this); newName.setBackground(Color.yellow); options.add(newName);
JButton quit = new JButton("Quit"); quit.setBounds(250,115,80,30); quit.addActionListener(this); quit.setBackground(Color.red); options.add(quit); } public void actionPerformed(ActionEvent event){ JButton button = (JButton)event.getSource(); String buttonLabel = button.getText(); if ("Quit".equalsIgnoreCase(buttonLabel)){ Exit_pressed(); return; } if ("Set New Name".equalsIgnoreCase(buttonLabel)){ New_Name(); return; } if ("Calculate Volume".equalsIgnoreCase(buttonLabel)){ Calculate_Volume(); return; } if ("Customers".equalsIgnoreCase(buttonLabel)){ Customers(); return; } if ("Calculate Volume".equalsIgnoreCase(buttonLabel)){ Calculate_Volume(); return; } if ("Options".equalsIgnoreCase(buttonLabel)){ Options(); return; } } private void Exit_pressed(){ System.exit(0); } private void New_Name(){ System.exit(0); } private void Calculate_Volume(){ String lengthString, widthString, depthString; int length=0; int width=0; int depth=0;
lengthString = lengthText.getText(); widthString = widthText.getText(); depthString = depthText.getText(); if ( lengthString.length() < 1 || widthString.length() < 1 || depthString.length() < 1 ){ volumeText.setText( "Error! Must enter in all three numbers!!" ); return; } length = Integer.parseInt(lengthString ); width = Integer.parseInt(widthString ); depth = Integer.parseInt(depthString); if ( length != 0 || width != 0 || depth != 0 ){ volumeText.setText((length * width * depth) + "" ); } else{ volumeText.setText( "Error! Must Enter in all three numbers!!" ); return; } } private void Customers(){} private void Options(){} public static void main(String[] args){ JFrame frame = new MainPool(); frame.setSize(525, 350); frame.setVisible(true); }
}
However there is an error at line 20 saying the return type is missing?? Any help please?!?!
View Answers
April 6, 2010 at 11:50 AM
Hi Friend,
You have defined the class name 'SwimmCalc' and you have declared the constructor with different name. Therefore, you have got that error. We have modified your code:
JFormattedTextField date = new JFormattedTextField( java.util.Calendar.getInstance().getTime()); date.setEditable(false); date.setBounds(150,15,150,20); general.add(date);
JButton quit = new JButton("Quit"); quit.setBounds(10,80,150,30); quit.addActionListener(this); quit.setBackground(Color.red); general.add(quit); } public void createPools(){ pools = new JPanel(); pools.setLayout( null );
JLabel lengthLabel = new JLabel( "Enter the length of swimming pool(ft):" ); lengthLabel.setBounds( 10, 15, 260, 20 ); pools.add( lengthLabel );
JButton newName = new JButton("Set New Name"); newName.setBounds(100,115,150,30); newName.addActionListener(this); newName.setBackground(Color.yellow); options.add(newName);
JButton quit = new JButton("Quit"); quit.setBounds(250,115,80,30); quit.addActionListener(this); quit.setBackground(Color.red); options.add(quit); } public void actionPerformed(ActionEvent event){ JButton button = (JButton)event.getSource(); String buttonLabel = button.getText(); if ("Quit".equalsIgnoreCase(buttonLabel)){ Exit_pressed(); return; } if ("Set New Name".equalsIgnoreCase(buttonLabel)){ New_Name(); return; } if ("Calculate Volume".equalsIgnoreCase(buttonLabel)){ Calculate_Volume(); return; } if ("Customers".equalsIgnoreCase(buttonLabel)){ Customers(); return; } if ("Calculate Volume".equalsIgnoreCase(buttonLabel)){ Calculate_Volume(); return; } if ("Options".equalsIgnoreCase(buttonLabel)){ Options(); return; } }
April 6, 2010 at 11:55 AM
continue..
private void Exit_pressed(){ System.exit(0); } private void New_Name(){ System.exit(0); } private void Calculate_Volume(){ String lengthString, widthString, depthString; int length=0; int width=0; int depth=0;
lengthString = lengthText.getText(); widthString = widthText.getText(); depthString = depthText.getText(); if ( lengthString.length() < 1 || widthString.length() < 1 || depthString.length() < 1 ){ volumeText.setText( "Error! Must enter in all three numbers!!" ); return; } length = Integer.parseInt(lengthString ); width = Integer.parseInt(widthString ); depth = Integer.parseInt(depthString); if ( length != 0 || width != 0 || depth != 0 ){ volumeText.setText((length * width * depth) + "" ); } else{ volumeText.setText( "Error! Must Enter in all three numbers!!" ); return; } } private void Customers(){} private void Options(){} public static void main(String[] args){ JFrame frame = new SwimmCalc(); frame.setSize(525, 350); frame.setVisible(true); }
}
Thanks
Related Pages:
swimming pool calculator swimmingpool calculator i'm writing a program to calculate the measurements of a swimmingpool & a hot tub. and then the user can enter... of swimmingpool(ft):");
lengthLabel.setBounds(10, 15, 260, 20
Swimming Pool Calculator - Java Beginners
PoolVolume() {
mainFrame = new JFrame("SwimmingPool Volume Calculator...SwimmingPool Calculator I have to write a program to calculate the volume of a swimmingpool. The assignment is as follows:
This SwimmingPool
Swimming Pool Calculator - Java Beginners
());
mainFrame = new JFrame("SwimmingPool Volume Calculator");
calcButton = new...SwimmingPool Calculator When I run the program the login window... JTextField(5);
lengthLabel = new JLabel("Enter the length of the swimmingpool
Swimming Pool Calculator - Java Beginners SwimmingPool Calculator Okay, so I tried making the program... );
JLabel lengthLabel = new JLabel( "Enter the length of swimmingpool(ft... of the swimmingpool(ft):" );
widthLabel.setBounds( 10, 60, 260, 20 );
pools.add
POOL
a variety of services to customers who own swimming pools, including cleaning and filling pools.
Create pool class that calculates the price of a service call... on the amount of time it will take to fill a customer's pool with water.
Table below
Calculator
Calculator need a simple java program to degin a CALCULATOR without using ADVANCED JAVA....
Calculator in Java Swing
Pool Chlorine Pool Chlorine *** Deleted by Admin ***** Pool Chlorine
Watson's of Cincinnati is a toy store for adults offering above ground pools, pool supplies, Envisions Home Theater electronics, home theater furniture, casual patio
Pool Chemicals Pool Chemicals **delted by admin *** a toy store **deleted by admin** offering above ground pools, pool supplies, Envisions Home Theater electronics, home theater furniture, casual patio furniture, spas & hot tubs etc
calculator midlet calculator midlet give me code calculator midlet in bluetooth application with j2me
Calculator class Calculator class I am a beginner in Eclipse. I have to do a program called calculator that adds numbers. This is my code so far:
//Margaret
//ICS... class Calculator extends JFrame implements ActionListener {
JTextField text
threads & autorelease pool
threads & autorelease pool How to set autorelease pool for NSThread method in Objective C?
[NSThread detachNewThreadSelector:@selector... {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//Do stuff
[pool release
Java-Connection Pool - JDBC
Java-Connection Pool How can I create a connection pool. My database is MS SQL server 2000(username-sa, pwd-admin) and my application server is Weblogic 8. Which is the best approach to create a connection pool? Kindly help
Java-Connection Pool - JDBC
Java-Connection Pool How can I create a connection pool. My database... is Weblogic 8. Which is the best approach to create a connection pool? Hi friend,import java.sql.*;import java.io.*;public class ConnectionPool
thread program for calculator implementation
thread program for calculator implementation Hi i'm prem i need calculator progrm in java that are implemented by Thread interface.....pls strong text
Enhancement for connection pool in DBAcess.java
Enhancement for connection pool in DBAcess.java package spo.db... database connection pool.");
else
return connection1;
}
public... have try to make some modification to improve current connection pool
calculator - Java Interview Questions
calculator create calculator by java code Hi Friend,
Please visit the following link:
http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml
Thanks
Program for Calculator - Swing AWT
Program for Calculator write a program for calculator? Hi Friend,
Please visit the following link:
http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml
Hope that it will be helpful
PHP Tax Calculator - PHP
PHP Tax Calculator In my project i required a tax calculator that can calculate the property tax
A connection pool with multiple user ID.
A connection pool with multiple user ID. Can I set up a connection pool with multiple user IDs? The single ID we are forced to use causes problems when debugging the DBMS
simple calculator - Java Beginners
simple calculator how can i create a simple calculator using java codes? Hi Friend,
Please visit the following link:
http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml
Thanks
Calculator - JSP-Servlet
Calculator Dear Deepak Sir,
Calculator program is avilable in Jsp...
calculator program in jsp
function checkValue(){
var msg...;
}
Simple calculator program in jsp
/>
>
Scientific Calculator - Java Beginners
Scientific Calculator Develop a scientific calculator using even-driven programming paradigm of Java.?
Thanks in ADVANCE Hi Friend,
Please visit the following link:
http://www.roseindia.net/tutorial/java
matrix calculator - Java Beginners
matrix calculator hi.....
can you help me in writing source code of matrix calculator in java...
i know you are the best you can do it!!! show yourself
Connection pool in Tomcat 6 - JDBC
Connection pool in Tomcat 6 Hi All,
Any one please tell me how to implement connection pooling in Tomcat 6 and MySQL 5.0.1b.
Thanks,
Ramarao Hi Friend,
Please visit the following link:
http
base calculator.. - Java Beginners
base calculator.. need some help!!! I cant install jcreator properly?? there's always an error (Error : Invalid path, "C:\Program Files\Java\jre1.6.0_01\bin\javac.exe" -classpath "C:\Program Files\Java\jdk1.6.0_01\bin" -d "C
calculator in java with stack calculator in java with stack i want calcultor with interface in java and in interface there is button called postfix ,,, when the user enter opertions and numbers first check if is vaild or not then convert to postfix
Java Calculator Program
Java Calculator Program Hi, so I need to make a program that "works like a calculator". I need to make two versions:
1) I'm given the Expression Class and need to implement the children classes, which are Number, Product, Sum
JDBC Connection Pool
JDBC Connection Pool
In this section we will learn about JDBC Connection Pool and see how to use
Apache DBCP for creating the database connection pool. We... pooling.
What is JDBC Connection Pool?
The database connection is expensive
Connection pool in Tomcat 6 - JDBC
Connection pool in Tomcat 6 Hello Everybody,
I am trying to implement connection pooling in Tomcat 6 and MySQL 5.0.41 with mysql-connector-java-5.1.6-bin.jar but without any success (for the last 2 days).
I have followed
class NSCFString autoreleased with no pool in place - just leaking
class NSCFString autoreleased with no pool in place - just leaking Hi,
In my application following error is coming:
class NSCFString autoreleased with no pool in place - just leaking
What is the solution?
Thanks
Simple Java Calculator - Java Beginners Calculator for 4 basic Math operations,
Addition, Subtraction, Multiplication and Division.
The calculator should simulate the look of handheld calculator containing.... Write proper code for making this
calculator operational. Students
Example - Simple Calculator
Java: Example - Simple Calculator
Here is the source for the simple calculator shown at the left.
It's divided into three source files.
Main (Calc.java) - A simple main program.
User interface (CalcGUI.java
Java Calculator program - Java Beginners
Java Calculator program import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Calculator implements ActionListener
{
int c,n...;
Calculator()
{
f=new Frame("Calculator");
p=new Panel();
b1=new JButton("0
Java: Example - Simple Calculator
Java: Example - Simple Calculator
Here is the source for the simple calculator shown at the left.
It's divided into three source files.
Main...*;
///////////////////////////////////////////////////////////// class Calc
/** Calc.java - A simple calculator.
@author Fred
Java Thread not geting Connection pool - JSP-Servlet
Java Thread not geting Connection pool Hi All,
Please help me in following problem.
I have database connection on server using connection pool.
There is on background process which will get execute when user click button
Java Swing Scientific Calculator
Java Swing Scientific Calculator
A Scientific Calculator is a very powerful and general purpose calculator. In
addition to basic arithmetic functions... calculator using java swing.
Here is the code:
import java.awt.*;
import
java loan calculator applet help
java loan calculator applet help Hi, I could use some help correcting a code here. I need to write a Java applet program (together with its html test file) to calculate loan payments. The user will provide the interest rate
Simple Calculator Application In Java Script
Simple Calculator Application In Java
Script
 ... Calculator
The objective of this project is learn how to write a simple calculator with the JavaScript programming language. You will learn how to write
Calculator program in Java Calculator program in Java is used by programmer to add, subtract, multiply... a class "calculator" is used.
System.in takes the input from the system/user at run... other wise it will be a fraction value)
Example of Calculator program in Java
iPhone EMI Calculator, EMI Calculator for iPhone
EMI Calc - iPhone EMI Calculator
EMI Calc...
of an EMI Calculator with the tool name of EMI Calc. The EMI Calc provides you... financial institution. The EMI Calculator tab of EMI Calc
calculates the exact