Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Mike Brown

Greenhorn
+ Follow
since Oct 19, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike Brown

I think all of the problems with the Indians can be blamed on the cowboys.
17 years ago
I'm glad he asked that question! I have been wondering that since I started studying Java. I have seen it both ways and both seem to work but I dodnt want to ask. Thanks cq!
17 years ago
Do you have any other advice for me?
17 years ago
Ok, I did that but it only shows the jre. Does that mean that the sdk is not installed?
17 years ago
Hello all. I am somewhat new to Java. And completely new to linux. I am having trouble installing the sdk on my suse 9.0 system. I'm sure that the fact that I have a limitied understanding of what it takes to make any kind of application work in linux has something to do with it. Anyway I am excited about learning linux and I want to continue Java with linux. I would appreciate any advice. I have been running the rpm -i command and nothing seems to happen. How can I check to see if it is installed and ready to go? What is the best download to use with suse? There are two types available from sun.One is the self extracting file and the other is a self extracting rpm file. I have some books but I cant seem to find enough info on what it takes to download, install and run an application. Sorry such a newbie question. Any advice or push in the right direction would really be appreciated. Thanks
17 years ago
Thanks guys, I am new but not that new! I should have seen that! I need to create the object first like Square mySquare = new Square. That's why I like this forum, no matter how lame of a question I post nobody flames me.
Thanks for the help.
17 years ago
Can someone tell me what it is that I am overlooking here? I am trying o make a subclass that will use the getSurfaceArea() method that I have created. Then I will override it with a cube but for now I can't even do this. I keep getting these errors.
non-static method setHeight(int) cannot be referenced from a static context
Here is my code:
public class Square
{
int width;
int height;
int surface;
public void setWidth(int w)
{
width = w;
}
public int getWidth()
{
return width;
}
public void setHeight(int h)
{
height = h;
}
public int getHeight()
{
return height;
}
public void getSurfaceArea()
{
surface = getHeight() * getWidth();
}
}
/***********here comes the problem***************************/
public class SquareSurface extends Square
{
public void main(String[] args)
{
Square.setHeight(10);
Square.setWidth(5);
Square.getSurfaceArea();
System.out.println("The surface of this square is " + surface);
}
}
17 years ago
Ernest,
One more thing on this and I will leave it alone. When I was trying to call getGraphics() in actionPerformed() and paint things frome there, It would work, but like you said any resize or overlap from another window would erase it. Why is that? If you could explain this when you have the time it would help me. thanks
17 years ago
Thank you for your patience Ernest. This is very diferent from the way that I have been attempting to do this as you know. Here are my questions regarding these things I havemt yet encountered.
1. super.paintComponent(g); //I am not sure what super is
2. theString = stringToDisplay;//I know that strings are immutable so how are we changing the contents of the string or are we?
3.How do we know when the user clicks the button with no actionPerformed method?
4. What are we doing with the last three lines? Is it to reset the frame?
As you can see I am still very green,but eager to learn. I have quite a few Java books but sometimes I feel that I am skipping around too much to try and find things that I am missing the bigger picture. I will look in my books to try to answer some of my own questions. I will laso experiment with the code you sent me. That sometimes helps me to see the importance of things. Thank you
18 years ago
I can compile the first part of the code but when I run it I get an applet with the message Exception: java.lang.ClassCastException:MyPanel.
Here is my code and my html
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyPanel extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString("Hello, World", 10, 50);
}
public static void main(String[] argv) {
JFrame frame = new JFrame();
frame.getContentPane().add(new MyPanel(), BorderLayout.CENTER);
frame.setSize(300, 100);
frame.setVisible(true);
}
}
<html>
<applet code = "MyPanel.class"
width = 400
height = 400
</applet>
18 years ago
Ernest,
I am sorry that I seem to not be taking your advice. It is just that some of the things you have explained are a bit beyond my level at this point. I will try to do as you say but it will lead to more questions. (If you don't mind) I do intend to learn to do it the proper way as you have explained and I have printed out all of you responses so that I can have them for a reference. Please don't think your time is wasted I am listening and taking it all in and I sincerely appreciate all of your help. This site has been my best resource to date.
18 years ago
I need to take the input from two textboxes and display them with the paint
method. I got it working with the first textbox but how do I add a second
and put it together to be displayed by the paint method? Am I getting close
with this code. Eventualy it will display a first name, last name and emailaddress from three textboxes after the user pushes the button. Here is a
piece of my code where I am having the problem.
Thanks, Mike
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if (source == btn)
{
Graphics g = getGraphics();
g.drawString(txtFirst.getText() + "" + txtLast.getText(), 10,190);
}
}
18 years ago
Thanks Paul, I remember now that strings are immutable so the way I had it couldnt possibly work.
18 years ago
I hope I am not exceeding my limit of questions here. I appreciate the help so much. This will be my last question tonight I promise.Can somebody tell me where I went wrong on this. I just want to take the input from the textbox and display it with the paint method when the user clicks the button.

I edited your code to include the UBB Code Tags to make your code easier to read.
[ October 26, 2003: Message edited by: Gregg Bolinger ]
18 years ago
I hope there isnt a limit of posts per person around here. I have been having problems editing my code. Being new I add a component and whatever functionality I need to my applet and I compile it and run it to see if it works. If it does I add the next thing and so on. I am starting to realize that sometimes the changes arent happening after I compile it and run it. Like I may add a label and the code is right and I save and compile it and call the applet with my HTML code and the changes arent there. If I rename the .java file and then save and recompile it shows up. Has anyone had similar problems or is it just me.
18 years ago