Help noob with code
I am working on an applet that will use the g.drawRect from the applets paint method. I want to allow user to enter the data for the rectangle (coordinate and size).
What is the proper sytax to inclue variables as such?
g.drawRect( xplot, yplot, width, height );
**this code gives me the following error when compiling**
C:\Documents and Settings\Alan\My Documents\IUPUI\Java\Labs\Lab2\Lab2b\Lab2b.java:116: cannot resolve symbol
symbol : variable xplot
location: class Lab2b
g.drawRect( xplot,yplot,width,height );
The error is saying that the compiler cannot resolve the symbol xplot, the first argument in drawRect on line 116. It resolves the symbol by finding where it is declared, eg, "int xplot;". In the code below we declare the variables as class or instance variables, eg, "int height;", and instantiate them in the constructor, eg, the instance variable width = w, local variable passed in to the constructor. Can't resolve something means can't find where you declared it, where did it come into being.
import java.awt.*;
import javax.swing.*;
public class jota extends JPanel {
int x;
int y;
int width;
int height;
Color color;
public jota(int x, int y, int w, int h, Color c) {
this.x = x;
this.y = y;
this.width = w;
this.height = h;
this.color = c;
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(color);
g.drawRect(x, y, width, height);
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new jota(50,50,200,175,Color.red));
f.setSize(500,400);
f.setLocation(300,200);
f.setVisible(true);
}
Similar Messages
-
Forms6i(urgent)(help me with code)
Hi all,
I am having table like this
CREATE TABLE SYS_PROFILE (
APP_CD VARCHAR2 (5),
LOCK_DT DATE,
AUDIT_DT DATE,
ST_DT DATE,
END_DT DATE)
There is global variable: global.sys_id.
This is supplied from the main menu.
On loading the form for the :global.sys_id = 'ST', it should load the third record (maximum start date for that app_id) automatically.
In case the user changes the start_dt then it should pick up that record and display.
to acheive this please help me with the code
Regards
NiHello,
Firstly, please, avoid the "urgent" word in this forum. Nobody 's paid to answer questions, and there is no question that is more "urgent" than other.
You can filter a based block by 2 ways:
- set the Default_where block property
Set_Block_Property( 'the_block', DEFAULT_WHERE, 'the_new_where_clause');
- set the field content in a PRE-QUERY block-level trigger
:block.item := :GLOBAL.SYS_ID ;
Francois -
Noob with code problem. :P
Hello, I am a beginner in Flash and I have started to pick away at a couple of tutorials, recently I came up with this error in my code and I can´t seem to figure it out.
Error
C:\Users\anton\Downloads\Flash games\interactivestorybook\Main.as, Line 10
1046: Type was not found or was not a compile-time constant: HillPage.
C:\Users\anton\Downloads\Flash games\interactivestorybook\Main.as, Line 11
1046: Type was not found or was not a compile-time constant: PondPage.
package
import flash.display.MovieClip;
import flash.events.MouseEvent
public class Main extends MovieClip
var startPage:StartPage
var hillPage:HillPage
var pondPage:PondPage
public function Main()
startPage = new StartPage()
hillPage = new HillPage()
pondPage = new PondPage()
addChild(startPage)
//Event listeners
startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonClick)
startPage.pondButton.addEventListener(MouseEvent.CLICK, onPondButtonClick)
// Event handlers
function onHillButtonClick(event:MouseEvent):void
addChild(hillPage)
removeChild(startPage)
function onPondButtonClick(event:MouseEvent):void
addChild(pondPage)
removeChild(startPage)
Would appreciate if someone could give me a hand, it is probly just something obvious but at the same time not obvious to me.I was able to figure out my fatale error, and boy was it an obvious one, forgot to export the symbol to actionscript in the properties panel :/
Thanks for your help ! -
I got 2 ports on UDP, one incoming and one outgoing.
I’m looking for a way to sort out incoming and outgoing data on each port.
Like if I got two sensors incoming, I want to have unique ID on each, and data.
XX XXXX
ID DATA
Is there any good or preferred way to mange this?945077 wrote:
Hi,
i've made a psql script for my application in apex ,You might get a better answer asking this in the Apex forum, depending on what it is you need help with.
What are you trying to do? "scripts" are used in SQL*PLUS, TOAD, and other development tools for ad-hoc executions. Apex is an environment for generating web pages, although it can use scripts for its own SQL environment.
Are you trying to get the student, subjects, and grades to display them on a page? The easiest way to do that is to create a report region using the SQL and list them directly to the page.
You can convert the script to a function or procedure and use it to generate the list in Apex.
Oh, last time I looked htp.p() was slightly faster than htp.print(). Its been a long time since I checked and its possible they are the same now. Less typing anyway :) -
Flash pros help needed with code
I have been given task and dont know where to start.
I need to produce a small quiz that sends the selected values to an asp.net application form there populates the database with the values chosen.
Ive been told this is the best way to send values from flash to a database.
Can anyone help in how id even go about this?
below is a work flow of what i need to do.
thanks,if all your radio buttons have the same group name (say gn), you can use:
var sendLV:LoadVars=new LoadVars();
var receiveLV:LoadVars=new LoadVars();
receiveLV.onData=function(src){
// do whatever
sendLV.data=gn.selection.data; // assuming your radio buttons have data assigned
etc
sendLV.sendAndReceive("submit.aspx",receiveLV,"POST"); // assuming your asp si expecting posted variables. -
Help noob with simple issue. Thanks!
Hey guys!
I am a first time flash-maker, and I sure how to get things to work as planned.
I have written the following code:
stop();
import flash.events.MouseEvent;
Weightlifting_btn.addEventListener(MouseEvent.CLICK, CursorClick);
function CursorClick(event:MouseEvent):void{
gotoAndStop("25");
But my problem is that i have a motion tween that startes at frame 5 and ends at frame 25. And the code says that at will go to and stop at frame 25.
what I really want it to do, is to go to frame 5, play the motion, and stop at frame 25.
How can I do this?
Thanks in advanceThat is AS3 code, so you should have posted in the AS3 forum. To make it start playing at frame 5, tell it to do that. If you want it to stop at frame 25, then place a stop() command at frame 25.
stop();
Weightlifting_btn.addEventListener(MouseEvent.CLICK, CursorClick);
function CursorClick(event:MouseEvent):void{
gotoAndPlay(5); // no quotes for frame numbers
(It looks like it's another one of those missing postings days... there were no responses showing here when I started here, but there should have been. And I'm noticing a good number of what has been posted today in the AS3 forum was missing when I last checked) -
Closing a browser with the help of servlet code
Is it possible to close a browser by using servlet code?
If so please help me with code.
ThanksThis is really a javascript question, but it's:
window.close() -
Can somebody help me with this code?
Can anyone help me with this code? My problem is that i can't
seem to position this form, i want to be able to center it
vertically & horizontally in a div either using CSS or any
other means.
<div id="searchbar"><!--Search Bar -->
<div id="searchcart">
<div class="serchcartcont">
<form action='
http://www.romancart.com/search.asp'
name="engine" target=searchwin id="engine">
<input type=hidden value=????? name=storeid>
<input type=text value='' name=searchterm>
<input type=submit value='Go'> </form>
</div>
</div>
<div class="searchcont">Search For
Products:</div>
</div><!-- End Search Bar -->
Pleasssssseeeeeeee Help
ThanksHi,
Your form is defined in a div named "serchcartcont", you can
use attributes like position and align of the div to do what you
want to do. But there are two more dives above this dive, you will
have define the height width of these before you can center align
the inner most div. If you are not defining the height & width
then by default it decide it automatically to just fit the content
in it.
Hope this helps.
Maneet
LeXolution IT Services
Web Development
Company -
Can someone pls help me with setting up an apple id.Whats the itunes gift code?
Hi,
I have recently purchased an iphone 5S. I am not able to use my apple ID in app store as it states you have to reveiw it in itunes before you proceed.When i review it, it asks for my credit card details.Thats fine.However I am not able to get itunes gift code.Can someone help me with this.ThanksHi,
I have recently purchased an iphone 5S. I am not able to use my apple ID in app store as it states you have to reveiw it in itunes before you proceed.When i review it, it asks for my credit card details.Thats fine.However I am not able to get itunes gift code.Can someone help me with this.Thanks -
Please! help me with this wrong code, where is mistake
please! help me with this wrong code, where is mistake?
import java.util.Stack;
public class KnightsTour {
Vars locs[];
private int size, max=1, d=0, board[][];
public KnightsTour(int x,int y, int newSize)
size=newSize;
locs=new Vars[size*size+1];
for(int n=1;n<=size*size;n++)
locs[n]=new Vars();
board=new int[size+1][size+1];
for(int n=1;n<=size;n++)
for(int n2=1;n2<=size;n2++)
board[n][n2]=0;
locs[max].x=x;
locs[max].y=y;
locs[max].d=1;
board[x][y]=max;
max++;
class Vars{
int x;
int y;
int d;
public void GO()
int n=0;
while(max<=size*size)
n++;
d++;
if(d>8)
max--;
board[locs[max].x][locs[max].y]=0;
d=locs[max].d+1;
move();
printBoard();
public void move()
int x=locs[max-1].x, y=locs[max-1].y;
switch(d)
case 1:x--;y-=2;break;
case 2:x++;y-=2;break;
case 3:x+=2;y--;break;
case 4:x+=2;y++;break;
case 5:x++;y+=2;break;
case 6:x--;y+=2;break;
case 7:x-=2;y++;break;
case 8:x-=2;y--;break;
//System.out.println(" X: "+x+" Y: "+y+" |"+max);
if((x<1)||(x>size)||(y<1)||(y>size)){}
else if(board[x][y]!=0){}
else
locs[max].x=x;
locs[max].y=y;
locs[max].d=d;
board[x][y]=max;
max++;
d=0;
//printBoard();
public void printBoard()
for(int n=1;n<=size;n++)
for(int n2=1;n2<=size;n2++)
if(board[n2][n]<10)
System.out.print(board[n2][n]+" ");
else
System.out.print(board[n2][n]+" ");
System.out.println();
//System.out.println();
System.out.println();
public static void main (String[]args){
KnightsTour k = new KnightsTour(1,1,8);
}public class KnightsTour {
Vars locs[];
private int size, max = 1, d = 0, board[][];
public static void main (String[] args) {
KnightsTour k = new KnightsTour (1, 1, 8);
k.GO ();
public KnightsTour (int x, int y, int newSize) {
size = newSize;
locs = new Vars[size * size + 1];
for (int n = 1; n <= size * size; n++) {
locs[n] = new Vars ();
board = new int[size + 1][size + 1];
for (int n = 1; n <= size; n++) {
for (int n2 = 1; n2 <= size; n2++) {
board[n][n2] = 0;
locs[max].x = x;
locs[max].y = y;
locs[max].d = 1;
board[x][y] = max;
max++;
class Vars {
int x;
int y;
int d;
public void GO () {
int n = 0;
while (max <= size * size) {
n++;
d++;
if (d > 8) {
max--;
board[locs[max].x][locs[max].y] = 0;
d = locs[max].d + 1;
move ();
printBoard ();
public void move () {
int x = locs[max - 1].x, y = locs[max - 1].y;
switch (d) {
case 1:
x--;
y -= 2;
break;
case 2:
x++;
y -= 2;
break;
case 3:
x += 2;
y--;
break;
case 4:
x += 2;
y++;
break;
case 5:
x++;
y += 2;
break;
case 6:
x--;
y += 2;
break;
case 7:
x -= 2;
y++;
break;
case 8:
x -= 2;
y--;
break;
//System.out.println(" X: "x" Y: "y" |"+max);
if ((x < 1) || (x > size) || (y < 1) || (y > size)) {
} else if (board[x][y] != 0) {
} else {
locs[max].x = x;
locs[max].y = y;
locs[max].d = d;
board[x][y] = max;
max++;
d = 0;
//printBoard();
public void printBoard () {
for (int n = 1; n <= size; n++) {
for (int n2 = 1; n2 <= size; n2++) {
if (board[n2][n] < 10) {
System.out.print (board[n2][n] + " ");
} else {
System.out.print (board[n2][n] + " ");
System.out.println ();
//System.out.println();
System.out.println ();
}formatting ftw.
If you call GO () you get in an infinite loop. max gets decreased, and it loops while max is smaller then or equal to size * size. Is your looping logic correct ? -
Hi, my iphone 4 is stuck telefonu because put the wrong security code.
And I can not connect to itunes to update telefonu.
I get an error and would like to help me with information
Thank you! [email protected]We need the exact error message in order to help you.
-
Hi,
I'm new to java, i'm creating java analog clock application. but i'm getting so many errors. i still try to figur out what are those. can someone please help me with this code. Thank you
here is my code
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
import javax.swing.*;
//The main class
public class AnalogClock extends JFrame
// Initialize all the variables
SimpleDateFormat f_s = new SimpleDateFormat ("ss", Locale.getDefault());
SimpleDateFormat f_m = new SimpleDateFormat ("mm", Locale.getDefault());
SimpleDateFormat f_h = new SimpleDateFormat ("hh", Locale.getDefault());
SimpleDateFormat standard = new SimpleDateFormat ("HH:mm:ss", Locale.getDefault());
int xs, ys, xm, ym, xh, yh, s, xcenter, ycenter, m, h, x, y, mouse_x, mouse_y;
String temp;
Dimension d;
Date now;
Thread thr = null;
Image im;
Boolean M = false;
Graphics gIm;
Dimension dIm;
int sx, sy, sx2, sy2;
Color digital = Color.blue, hour = Color.blue, minute = Color.yellow,
second = Color.green, circle = Color.red, hours = Color.blue, mute_logo = Color.green;
// paint(): the main part of the program
public void paint(Graphics g)
d = getSize();
xcenter = d.width/2;
ycenter = d.height/2;
x = d.width;
y = d.height;
if(im == null)
im = createImage(x, y);
gIm = im.getGraphics();
dIm = new Dimension(x, y);
// Get the current timestamp
now = new Date();
// Get the seconds
temp = f_s.format(now);
s = Integer.parseInt(temp);
temp = f_m.format(now);
m = Integer.parseInt(temp);
temp = f_h.format(now);
h = Integer.parseInt(temp);
// Calculate all the positions of the hands
xs = (int) (Math.cos(s * Math.PI / 30 - Math.PI / 2) * 45 + xcenter);
ys = (int) (Math.sin(s * Math.PI / 30 - Math.PI / 2) * 45 + ycenter);
xm = (int) (Math.cos(m * Math.PI / 30 - Math.PI / 2) * 40 + xcenter);
ym = (int) (Math.sin(m * Math.PI / 30 - Math.PI / 2) * 40 + ycenter);
xh = (int) (Math.cos((h * 30 + m / 2) * Math.PI / 180 - Math.PI / 2) * 30 + xcenter);
yh = (int) (Math.sin((h * 30 + m / 2) * Math.PI / 180 - Math.PI / 2) * 30 + ycenter);
// Refresh the image
gIm.setColor(getBackground());
gIm.fillRect(0, 0, dIm.width, dIm.height);
// Draw the circle of the clock
gIm.setColor(circle);
gIm.drawOval(0, 0, d.width-1, d.height-1);
gIm.setColor(hours);
// Draw the stripes of the hours
for(int i = 0;i<12;i++)
sx = (int) (Math.cos((i * 30) * Math.PI / 180 - Math.PI / 2) * 47 + xcenter);
sy = (int) (Math.sin((i * 30) * Math.PI / 180 - Math.PI / 2) * 47 + xcenter);
sx2 = (int) (Math.cos((i * 30) * Math.PI / 180 - Math.PI / 2) * 49 + xcenter);
sy2 = (int) (Math.sin((i * 30) * Math.PI / 180 - Math.PI / 2) * 49 + xcenter);
gIm.drawLine(sx, sy, sx2, sy2);
// Draw the time on the top of the clock
gIm.setColor(digital);
gIm.drawString(standard.format(now), 25, 30);
// Draw the mute logo
Mute m = new Mute(M, gIm);
// Draw the hands
// Seconds
gIm.setColor(second);
gIm.drawLine(xcenter, ycenter, xs, ys);
// Minutes
gIm.setColor(minute);
gIm.drawLine(xcenter, ycenter-1, xm, ym);
gIm.drawLine(xcenter-1, ycenter, xm, ym);
// Hour
gIm.setColor(hour);
gIm.drawLine(xcenter, ycenter-1, xh, yh);
gIm.drawLine(xcenter-1, ycenter, xh, yh);
// Paint the generated image on the screen
if(im != null)
g.drawImage(im, 0, 0, null);
if(M == false)
play(getCodeBase(), "Sound/Click.wav");
public void update(Graphics g)
paint(g);
class Mute
Mute(Boolean mute, Graphics g)
g.setColor(mute_logo);
Polygon p = new Polygon();
p.addPoint(1, 7);
p.addPoint(6, 2);
p.addPoint(6, 12);
g.fillPolygon(p);
g.drawLine(7, 5, 7, 9);
g.drawLine(9, 4, 9, 10);
g.drawLine(11, 3, 11, 11);
if(mute == true)
g.drawLine(13, 3, 1, 11);
/* // All the mouse events
public void mousePressed(MouseEvent evt)
mouse_x = evt.getX();
mouse_y = evt.getY();
if(mouse_x <= 11 && mouse_x >= 1 && mouse_y <= 12 && mouse_y >= 2)
if(M == true)
M = false;
} else {
M = true;
repaint();
public void mouseReleased(MouseEvent evt){}
public void mouseEntered(MouseEvent evt){}
public void mouseExited(MouseEvent evt){}
public void mouseClicked(MouseEvent evt){}
}There is a gross misconception among the new and learning programmers that a lot of code is good and once you put that last close scope in place that things are wonderful because you have all the code down...
Please repeat this: NO, short debugged runs and incremental builds are better.
As a matter of fact, that is so important, go back and say it again and again until it really truly sinks in.
This concept is really pounded into your soul when you program in assembler--probably an ailment of the new generation of programmers, they never have had to do assembler or machine coding--but any time you get more than about 20 lines of code that hasn't been checked for bugs, you should start thinking... "Oh, do I really have the skills and patience to go back and debug (yes, actually use the debugger to step through it all.) that big of mess?" The biggest project is just like eating an elephant, you do it one small bite at a time over as long a time as it takes--you don't cook half the elephant and sit down and expect to eat it in one meal; neither do you sit down and decide to code a whole program and then debug it. You just don't have the skill to do it.
When you modify someone else's code, the same is true--small changes and debug as you change. Making all the changes you want, then debugging just runs into a huge error file of related problems that are basically indiscernible from each other because many of them are probably related.
Most of the request for "Help, I cannot get this to run." Also contain the words: "I just finished coding..." That statement in and of itself is one of the great flawed concepts that anyone can have--coding is complete when you have an acceptable release candidate, and then only until you decide or are asked to make further changes.
Work in small blocks of code and incrementally build a project--your frustration levels will be much less. And as you gain skill, increase the size of the code blocks (I had a friend in college that never had 5 consecutive lines of code compile--ever! He works for MS now.) and get to know your debugger. Your debugger is your friend, if you've not been introduced to your debugger, then get acquainted soon! Like maybe before you even try to cut another piece of code.
On the other side of things... cheer up, we've all been there and learned the lessons... some lessons just come harder than others... make your life less frustrating, it's a lot more fun and enjoyable. -
i brought a iTunes card and the the code on the back is not there it has faded away can u please help me with this problem
Hi Daniel ...
Try here > iTunes Store: Invalid, inactive, or illegible codes -
Hi Gurus,
Please help me with the code.
Algorithm: This is for master data extraction. I need to append some records to I_T_DATA before the loop on I_T_DATA begins.
ZTAB is a custom defined table with key KEY. STAB is standard table with key KEY.
1. Create an internal table I_T_STAB similar to STAB.
2. Loop at I_T_DATA
Read record from ZTAB where KEY = I_T_DATA-KEY and { field1 <> I_T_DATA-field1 or field2 <> I_T_DATA-field2 <> field3 <> I_T_DATA-field3}
If success
Delete record from I_T_DATA.
Else
Continue loop.
Copy all records of STAB to I_T_STAB.
3. Delete records in I_T_STAB where I_T_STAB-KEY = ZTAB-KEY.
Now
4. Delete all records in I_T_DATA where I_T_DATA-KEY = I_T_STAB-KEY.
Now,
5. Append all the remaining records from step 3 in I_T_STAB to I_T_DATA.
Please help me with the code upto this part.
Now the actual code in exit starts.
Loop at I_T_DATA
Thanks,
Regards,
aarthi
[email protected]You might get a quick answer if you were to post in the ABAP forum.
Moderator, please move to ABAP forum. Thanks.
Regards,
Rich Heilman -
Help! error code 8 with Adobe premier cs4 and OpenGl
hey there,
i've been trying to work with adobe premier cs4 on my new Thinkpad w520 (i7 2720, 8GB, Nvidia quadro 1000m)
i keep getting this error messege regarding the OpenGl (error code #8) that lost connection with the display driver, after that its automaticly shutting down premier.
nvidia representive suggested me to download an old driver (268.71) instead of the latest one, still wouldn't solve the problam.
can anyone help me with that issue!?
jonnyhey jonygeron,
if you uninstall the current graphic driver , let windows install its generic driver .. can you get Premier CS4 to work ?
WW Social Media
Important Note: If you need help, post your question in the forum, and include your system type, model number and OS. Do not post your serial number.
Did someone help you today? Press the star on the left to thank them with a Kudo!
If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"!
Follow @LenovoForums on Twitter!
Have you checked out the Community Knowledgebase yet?!
How to send a private message? --> Check out this article.
Maybe you are looking for
-
Transfer video from iphone to computer?
How do I transfer my videos from my iPhone 4s to my computer. I try just copy & pasting them from my phone to my computer using My Computer, but the videos play upsided down on my computer. Any idea what I am doing wrong?
-
Hello, We need the ability to display message attachments in the browser. Some files display in IE fine (PDF, TXT, DOC, GIF, JPG) but others don't (PPT, XLS, RTF) -- instead a download dialog box is displayed. Anyone know how to get PowerPoint, Excel
-
Which is better the "Ipods" or ZENS personally i think the zens there way better that the ipods by the long shot.
-
How to Attach a clickable HTML link to a SendMail Step?
Hi Guys! Please help me provide a link in my sendmail step. Is this possible? The editor for sendmail step interprets a word which is enclosed by '&' sign as symbol. This has caused a problem since the link invloves many '&' sign for it ti work. I'll
-
[ebs@shankar ~]$ sudo rc.d restart bumblebeed Password: :: Stopping Bumblebee [DONE] :: Starting Bumblebee [BUSY] FATAL: Module bbswitch not found. And due to that, my graphics card Nvidia is always draining power and heating up. How can I fix this?