Kenneth Kim

Greenhorn
+ Follow
since Aug 11, 2005
Merit badge: grant badges
For More
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 Kenneth Kim

I created a method called readFile as shown below:



And in my GUI, the pertinent code is like this:



My question is:

a) Is my method for reading a file and converting it into a string correct?
b) Why do I get the error message readFile(java.io.File) cannot be applied to java.lang.String?
18 years ago
Hello,

I'm having trouble appending the (multiple) outputs of a method to a textarea (not a JTextField), with each output on a new line, any ideas?



[ December 06, 2005: Message edited by: Kenneth Kim ]
18 years ago
My code won't compile...it always says that I have an else without an if...take a look!

18 years ago
Hi I have the following code:


Do you see the part of my code with the XXXXX's? I have the user input the name of a color in the string earlier in the program. How do I use the string in place of the XXXX's? The name of the string is "color", quite appropriately.
18 years ago
Supposing I assigned variables a,b, and c to the coefficients in the quadratic formula:

(-b +/- sqrt(b^2-4ac))/2a

How would I write that in Java? In my actual program I have assigned a as variable "coa", b as "cob", and c as "cob". Here is what I have tried without success:



When compiling, I get errors mainly saying that I cannot use a particular operator with a double variable.
18 years ago
I have the following bit of code in one of my programs:




The compiler keeps returning an error message of incompatible types, saying that it's expecting a double type, and that its declared as a String??? Does the JOptionPane class only accept Strings? I'm so confused. Thanks for your help in advance!
18 years ago
I'm working on an exercise, and I need a few pointers. Basically, I want to create a program that will create a frame using the JFrame class. Simple enough. However, I want to add a button so that if the user clicks "OK", the frame will relocate itself. I've looked hard at the API and I still haven't been able to find what I needed. My question is:

a) How do I create an OK button for my frame?

Here's the code I have now:

import javax.swing.*;

class JumpyWindow {

public static void main(String[] args) {
JFrame jumpywindow;
jumpywindow = new JFrame();
jumpywindow.setTitle("Jumpy Window");
jumpywindow.setSize(200, 100);
jumpywindow.setVisible(true);
jumpywindow.setLocation(412,334);
}

}

By the way, do I need to "cut and paste" that chunk of code setting the attributes of the JFrame jumpywindow five times if I want to relocate it five times? Thanks.
[ September 11, 2005: Message edited by: Kenneth Kim ]
18 years ago
Thank you all for your help! :-)
18 years ago
Hello,

Does anyone know of any websites where I can get source code for a very simple java program, just so that I can pick it apart and get a sense of how classes, methods, and conditional branching works?
18 years ago
Hey there,

I'm completely new to Java (hence the title) and I'm really eager to learn. I learn best by doing, and so I thought I'd start off with a project...

...I know this sounds pretty ambitious, but thats how I like to do things! Anyway, I was interested in making a basic program that would calculate the odds of making a sucessful hand in the popular poker game, Texas Hold'em. For those who don't know the rules, here's a link! http://boardgames.about.com/cs/poker/a/texas_rules.htm

I think that I'm beyond Forum help, so I was wondering if there was anybody out there that could help me outside of the forum (via e-mail or AIM) to help me code this thing.
18 years ago