Important Message

You are browsing the archived Lancers Reactor forums. You cannot register or login.
The content may be outdated and links may not be functional.


To get the latest in Freelancer news, mods, modding and downloads, go to
The-Starport

Help me with Java (Look if you know C++ also)

This is where you can discuss your homework, family, just about anything, make strange sounds and otherwise discuss things which are really not related to the Lancer-series. Yes that means you can discuss other games.

Post Tue Feb 08, 2005 4:39 pm

Help me with Java (Look if you know C++ also)

Simple Java. BreezySwing. For those of you who dont know, BreezySwing is an extension of Swing which was very hard to use for making GUI programs. C++is like java so if yoiu know that you could help me also. This is for my first computer science class, so dont expect mind bogglin, I'm expecting simple errors.





import java.awt.*;
import javax.swing.*;
import BreezySwing.*;

public class EventHandling3 extends GBFrame
{
// instance variables
public JLabel right;
public JLabel wrong;
public JLabel score;
public IntegerField right2;
public IntegerField wrong2;
public IntegerField score2;
public JButton calc;
public JButton reset;
int z;
int x;
int y;

public EventHandling3()
{
right = addLabel ("Right",1,1,1,1);
right2 = addIntegerField (0,1,2,1,2);
wrong = addLabel ("Wrong",2,1,1,1);
wrong2 = addIntegerField (0,2,2,1,2);
score = addLabel ("Score",3,1,1,1);
score2 = addIntegerField (0,3,2,1,2);
calc = addButton ("Calculate",4,1,1,1);
reset = addButton ("Reset",4,2,1,1);
}


public void buttonClicked(JButton buttonObj)
{
if(buttonObj == calc)
{
z = right2.getNumber();
x = wrong2.getNumber();
y = (z * 6) - (x * 2);
score2.setNumber(y);
}
if(buttonObj == reset)
{
right2.setNumber(0);
wrong2.setNumber(0);
score2.setNumber(0);
}
}

}
// main method
public static void main(String [ args)
{
EventHandling3 app = new EventHandling3()
app.setSize(200,200);
app.setTitle("Arav";
app.setVisible(true);
}



Edit: This looks ugly, cause it did not copy the alignment.
________________________
Watch the head humpers Gordon!

Edited by - Aravis/eX-Project on 2/8/2005 4:40:15 PM

Edited by - Aravis/eX-Project on 2/8/2005 4:50:11 PM

LXP

Post Tue Feb 08, 2005 5:34 pm

Okay...

I don't know BreezySwing, only Swing, but I assume GBFrame is the BreezySwing counterpart of Swing's JFrame.

The thing that hits me like a ton of bricks is your name choice for a class that is derived from GBFrame - EventHandling3. Or is that somehow due to the original task specification?

By the way, it might help if you explain the task, as well as elaborate upon your question.

Edited by - LXP on 2/8/2005 5:50:03 PM

Post Tue Feb 08, 2005 7:21 pm

EventHandling3 is the name of the java file. I could change it to anything I want. Arav, MongolianWarriors, Alaska,RaidersOfTheLostArk, whatever. EventHandling3 is just what my teacher said to call it. It wont compile. I'm using JCreator. I'm thinking its a simple error like missed semi-colon. but you never know. I can't find whatever it is.

The process, is to create a score calculator for UIL Tests for school, theoretically. Highest score is 240, the equation is demonstrated in the buttonClicked method.

Edited by - Aravis/eX-Project on 2/8/2005 7:22:59 PM

LXP

Post Tue Feb 08, 2005 7:34 pm

What about the 4th line in main:

app.setTitle("Arav";

Don't you think the semi-colon immediately following the closing quote is the troublemaker?

Also, the finishing semi-colon terminating the line containing app's definition is missing:

EventHandling3 app = new EventHandling3()

should read

EventHandling3 app = new EventHandling3();

Also, you might want to have a look at Eclipse at www.eclipse.org - highly recommended for Java development.

Edited by - LXP on 2/8/2005 8:24:09 PM

Post Tue Feb 08, 2005 8:17 pm

Anything that use brackets wont show up on TLR, it trys to render it as html, which is the same way I.E. to get this you type [ b closing bracket here . I'll check it out though.

LXP

Post Tue Feb 08, 2005 8:22 pm

LOL, didn't know that, anyway there are two bugs left.

And, btw, let me know about your progress, OK?

Edited by - LXP on 2/9/2005 4:18:08 AM

Post Wed Feb 09, 2005 2:43 pm

It appears I left out the main method from the public class..lol...Simple errors always throw me off..

Return to Off Topic