Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java Complication Error
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


steph
Java Complication Error
3 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners



Advertisement
View Answers

October 12, 2009 at 2:19 PM


Hi Friend,
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.text.SimpleDateFormat;

public class MainPool extends JFrame implements ActionListener{
private JTabbedPane jtabbedPane;
private JPanel general;
private JPanel pools;
private JPanel hotTubs;
private JPanel tempCalc;
private JPanel customers;
private JPanel options;
private JComponent date;
JTextField lengthText, widthText, depthText, volumeText;

public MainPool(){
setTitle( "Pools," );
setSize( 300, 200 );
setBackground( Color.blue);

JPanel topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );

createGeneral();
createPools();
createHotTubs();
createTempCalc();
createCustomers();
createOptions();

jtabbedPane = new JTabbedPane();
jtabbedPane.addTab( "General", general );
jtabbedPane.addTab( "Pools", pools );
jtabbedPane.addTab( "Hot Tubs", hotTubs );
jtabbedPane.addTab( "Temp Calculator", tempCalc );
jtabbedPane.addTab( "Customers", customers );
jtabbedPane.addTab( "Options", options );

topPanel.add(jtabbedPane, BorderLayout.CENTER );
}
public void createGeneral(){
general = new JPanel();
general.setLayout( null );

JLabel dateLabel = new JLabel( "Todays Date" );
dateLabel.setBounds( 10, 15, 150, 20 );
general.add( dateLabel );

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

lengthText = new JTextField();
lengthText.setBounds( 260, 15, 150, 20 );
pools.add( lengthText );

JLabel widthLabel = new JLabel( "Enter the width of the swimming pool(ft):" );
widthLabel.setBounds( 10, 60, 260, 20 );
pools.add( widthLabel );

widthText = new JTextField();
widthText.setBounds( 260, 60, 150, 20 );
pools.add( widthText );

JLabel depthLabel = new JLabel( "Enter the average depth the swimming pool(ft):" );
depthLabel.setBounds( 10, 100, 260, 20 );
pools.add( depthLabel );

depthText = new JTextField();
depthText.setBounds( 260, 100, 150, 20 );
pools.add( depthText );

JLabel volumeLabel = new JLabel( "The pool volume is:(ft ^3" );
volumeLabel.setBounds( 10, 200, 260, 20 );
pools.add( volumeLabel );

volumeText = new JTextField();
volumeText.setBounds( 260, 200, 150, 20 );
volumeText.setEditable(false);
pools.add( volumeText );


October 12, 2009 at 2:22 PM


continue..

JButton calcVolume = new JButton("Calculate Volume");
calcVolume.setBounds(150,250,150,30);
calcVolume.addActionListener(this);
calcVolume.setBackground(Color.yellow);
pools.add(calcVolume);

JButton quit = new JButton("Quit");
quit.setBounds(350,250,80,30);
quit.addActionListener(this);
quit.setBackground(Color.red);
pools.add(quit);
}
public void createHotTubs(){
hotTubs = new JPanel();
hotTubs.setLayout( new GridLayout( 3, 2 ) );
hotTubs.add( new JLabel( "Field 1:" ) );
hotTubs.add( new TextArea() );
hotTubs.add( new JLabel( "Field 2:" ) );
hotTubs.add( new TextArea() );
hotTubs.add( new JLabel( "Field 3:" ) );
hotTubs.add( new TextArea() );
}
public void createTempCalc(){
tempCalc = new JPanel();
tempCalc.setLayout( null );
JLabel tempLabel = new JLabel( "Enter temperature:" );
tempLabel.setBounds( 10, 15, 260, 20 );
tempCalc.add( tempLabel );

JTextField temp = new JTextField();
temp.setBounds( 260, 15, 150, 20 );
tempCalc.add( temp );

JLabel resultsLabel = new JLabel( "Calculated Temp:" );
resultsLabel.setBounds( 10, 60, 260, 20 );
tempCalc.add( resultsLabel );

JTextField results = new JTextField();
results.setBounds( 260, 60, 150, 20 );
results.setEditable(false);
tempCalc.add( results );

JButton calcVol = new JButton("Calculate Volume");
calcVol.setBounds(100,115,150,30);
calcVol.addActionListener(this);
calcVol.setBackground(Color.yellow);
tempCalc.add(calcVol);

JButton quit = new JButton("Quit");
quit.setBounds(250,115,80,30);
quit.addActionListener(this);
quit.setBackground(Color.red);
tempCalc.add(quit);
}
public void createCustomers(){}
public void createOptions()
{
options = new JPanel();
options.setLayout( null );
JLabel labelOptions = new JLabel( "Change Company Name:" );
labelOptions.setBounds( 150, 50, 150, 20 );
options.add( labelOptions );

JTextField newTitle = new JTextField();
newTitle.setBounds( 150, 70, 150, 20 );
options.add( newTitle );

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


October 12, 2009 at 2:23 PM


continue.......

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

Thanks


Related Tutorials/Questions & Answers:
Java Complication Error - Java Beginners
Java Complication Error  Hello there, I was assigned to do a project in java that I have to set up tabs and in each tab have something in them. Well... this error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Java Complication Error - Java Beginners
Java Complication Error  Hello there, I was assigned to do a project in java that I have to set up tabs and in each tab have something in them. Well... this error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Advertisements
Java Program Complication error - Java Beginners
Java Program Complication error  Hi there, I have this program I had to write called ThreeArrayLists.java, but I keep getting this error "use of unchecked or unsafe operations" This is the criteria for the program
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
Java Error - Java Beginners
Java Error  Hello Sir ,How i Can solve Following Error Can not find Symbol - in.readLine(); Here Error Display at in  Hi Friend, It seems that you haven't defined the object 'in'.Anyways, Send your code so that we
runtime error in java
runtime 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 different types of a program like as Logic error,Fatal Errors,source code,wrong
java error - Java Beginners
java error  Hello sir, on compiling any program from command prompt.... But if I want to run that program the fetches me the following error. For example for file: Test.java C:\Program Files\Java\jdk1.6.0_17\bin>javac Test.java
java error - Java Beginners
java error  G:\threading>javac threadmethods.java Note: threadmethods.java uses or overrides a deprecated API. Note: Recompile with -Xlint... been obsoleted. To get the details of your error, compile your class with Xlint
pointer error java
pointer error java  How to catch null pointer errors in java if the if(value != null) or null
java compilation error - Applet
java compilation error  I am getting compilation error in the following code.: public void paint(Graphics g) { switch(screen...; } } Error is: Illegal start of expression Plz. find why am I getting this error
Java Error - Java Beginners
Java Error  E:\SUSHANT\Core Java\FileHandling\Error>javac... ch= reader.read(); ^ 1 error import java.io....); //System.out.println("Enter characters, 'q' to quit."); try
Java Error - Java Beginners
Java Error  Here Error near Read Method import java.util.*; import java.io.*; public class inputdemo { public static void main(String[] args) throws IOException { String bookname,author; float price; System.out.println
JAVA Annotation Error
JAVA Annotation Error  while compiling simple java program i get annotation error i.e class will only be accepted if annotation processing is explicitly requested..how to solve
java runtime error - JDBC
java 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... version error 49.0.so, please suggest how will i compensate this problem
java error - Java Beginners
java error  Thanks for providing me the answer for the question... be dereferenced If Programme saved in SortFileData also shows some error Please rectify the errors and provide the coding that run properly Write a Java program
Java compilation error - Java Beginners
Java compilation error  Method overridden problems in compile time error
JAVA Error - Java Beginners
JAVA Error  i have made my own calculator GUI..and i want the text..."); btnBack.setForeground(red); it send me an error message that goes like this unknown...: http://www.roseindia.net/java/ Thanks.   Hello Just use
java runtime error - JDBC
java 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
error - Java Beginners
Java error handling  How to write a code to handle the errors in Java?  hi all,visit these site mentioned belowhttp://www.ugrad.cs.ubc.ca/~cs211/tutorials/Eclipse/Eclipse_Java_Windows_XP.htmlit will work
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...;Hi friend, To compile and run a java program we need to install java
java compilation error - Applet
java compilation error  hi friends the following is the awt front design program error, give me the replay E:\ramesh>javac...://www.roseindia.net/java/example/java/awt/ Thanks
java error - Java Beginners
java error  Dear roseindiamembers, I have checked the registration form for new user to login roseindiamembers forum with different data.It's not working properly .when i am registering as new user in http
what is the error - Java Beginners
what is the error  What is the compile time error that i am getting... is creating the compile time error such as : - ? CANNOT FIND SYMBOL ? because you... this .correct code is this if you don?t want such type of error EG : - import java.lang.
Java Error - Java Beginners
Java Error  import java.io.*; import java.lang.*; public class Wrapperdemo { float prin; float rate; int no; float interest; Wrapperdemo() { try{ BufferedReader br = new BufferedReader(new InputStreamReader
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
runtime error - Java Beginners
runtime 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
Error with PrintDocument - Java Beginners
Error with PrintDocument  Error: StudRec.java:526: printComponent(java.awt.Component) in PrintableDocument cannot be applied.... Note: Recompile with -Xlint:unchecked for details. 1 error
Error - Java Beginners
Error  How to rectify requested resource()not found . HTTp-404 error
java runtime error - JDBC
java 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
complier error - Java Beginners
error shows syntax errors like: required : int found : byte Runtime error shows logical errors like: int x=2/0; //this expression causes runtime error Thanks  Hi Friend, Difference: Compile time error shows syntax
Advertisements
 

 

 

DMCA.com