473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need some assistance please

Hello everyone! I am trying to learn java and have run into kind of a
snag. Here is the code that I have so far:

------ <begin_code> ----------

import javax.swing.*;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import java.awt.Graphics;

public class Rectangles {

public static void main ( String args[] ) {

// Variables to hold the users input
String number1;
String number2;
String number3;
String number4;
int x;
int y;
int width;
int height;

nextRect: // Continue point for drawing another Rectangle

// Gather input and parse into integers
number1 = JOptionPane.showInputDialog(null, "Please input the x value: ");

number2 = JOptionPane.showInputDialog(null, "Please input the y value: ");
number3 = JOptionPane.showInputDialog(null, "Please input the width
value: ");
number4 = JOptionPane.showInputDialog(null, "Please input the height
value: ");

x = Integer.parseInt(number1);
y = Integer.parseInt(number2);
width = Integer.parseInt(number3);
height = Integer.parseInt(number4);

public void paint( Graphics g )
{
super.paint(g);

g.drawRect(x, y, width, height);

String answer;

answer = JOptionPane.showInputDialog(null, "Would you like to draw
another rectangle? ");

if ( answer == "yes | y")
continue nextRec; // go to nextRec and start over
else
System.exit(0);
}

}

}

------ </end_code> --------

Now, the problem I am having, is I am getting an error between the 't' and
the '(' in "public void paint( Graphics g )" Please be kind in your
comments and keep in mind that I am just learning. If I am trying to do
something that I shouldn't please let me know. I would really like to
know why this won't work.

Thank you in advance!

Regards,

jlk
Jul 17 '05 #1
1 2142
jlk-

You are attempting to define your paint(Graphics) method within your main
method. This will not work. Define the paint method outside of the
main method and you'll have much more luck,
-c
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: CHRIS ALOZIE | last post by:
NIGERIAN TELECOMMUNICATION LIMITED. FEDERAL SECRETARIAT COMPLEX, GARKI, ZONE II ABUJA. E-MAIL: chrisalozie@uboot.com DATE:16th August 2003 REF:rf/ntl-fgn
0
by: TN Bella | last post by:
Hi, I am trying to get my compare validator to fire properly...Since I have panels the validator wouldn't work properly, the app would fire right but would insert the data regardless and the...
0
by: Luis Esteban Valencia | last post by:
I've never worked with LDAP before, and I'm having issues connecting to our AD for user authentication. I am trying to use the code found at: ...
46
by: Bruce W. Darby | last post by:
This will be my very first VB.Net application and it's pretty simple. But I've got a snag in my syntax somewhere. Was hoping that someone could point me in the right direction. The history: My...
1
by: DR | last post by:
What ports do i need to unblock on client and server (running msvsmon.exe) to debug remotely from my client box with visual studio 2005 pro? When I attach to remote process a connection shows up...
2
by: quack | last post by:
In SQL Server 2005 I have database mail, I need experienced assistance with a project- when a new record is created send an html message to the new records column "Authorize" , for example...
3
by: gaurav92K | last post by:
sir i am working in a company . there are many pc. i want to use remote assistance. i configure all group policy which are related remote assistance.and i enable service through remote in system...
2
by: gaurav92K | last post by:
sir, why are you not tell me about setting of remote assistence in win xp. i want to establish remote assistace ,i enable all group policy setting about remote assistance and check all essential...
2
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I have a Solution with 50 project and over 100 forms - I need to ensure That on each form the Localizable Property is set to TRUE Where is that property store and is there a way to write a...
9
by: moondaddy | last post by:
using c# 3.5 I have list of business objects which I will use in lists for databinding and I want to hide some of the fields so they don't show up in the list control. some of my list will be:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.