Jeff SmithX

Ranch Hand
+ Follow
since May 04, 2001
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 Jeff SmithX

Hi,

I'm wondering if there's anyway to get Java's random number generator to generate the same sequence of numbers as C's srand and rand? That is, if I were to call C's srand() with a seed of 100 and create a new Random object in java with a seed of 100 and then use, in C, rand() and, in Java, nextInt() how can I get the same sequence of numbers from Java as I would from C? Is it even possible?

For those wondering, I'm trying to create a modified version of FreeCell and I want to have the games be the same as in the Microsoft version, which uses the random number generator in C to generate the card order in the games.

Thanks,
Jeff
17 years ago
Hi,
I'm experimenting with a custom look and feel for the first time and I'm having some problems I have no idea how to fix. I've downloaded the Kunststoff Look&Feel (www.incors.org) and I've written a really simple program that is just supposed to display a message box, with the custom look and feel. However, when I run the program I get the following error:

Here's my program:

Can anyone please tell me how to fix this problem, I don't understand what's happening here. And since this look and feel was created by someone else, and I've seen it used in other programs, I would think it should work ok.
Thanks,
Jeff
[ October 04, 2003: Message edited by: Jeff Smith ]
[ October 04, 2003: Message edited by: Jeff Smith ]
18 years ago
I need some help here. I'm trying to align the text in my JTextPane so that it's fully justified (has even left and right margins). I found the following code online:

The problem is that this sets the text as CENTER justified and I have no idea why? Can anyone tell me how to get my text fully justified?
Thanks,
Jeff
[ January 28, 2003: Message edited by: Jeff Smith ]
19 years ago
When you get a deprecation warning you should check out the API for that class, it usually provides an explanation. Here's what Date's API says about getDay():
"Deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.DAY_OF_WEEK)."
Jeff
20 years ago
Add a call to validate() after the line where you set the text field visible.
Jeff
20 years ago
Here's something I put together quickly that should give you the basic idea:

Jeff
20 years ago
You could use instanceof:

Jeff
20 years ago
I believe you just do something like:

Jeff
20 years ago
Have you tried setting focus to the frame. Or calling bringToFront() (I think there's a method like that, or something similar)? Sorry I can't be of more help, but the last time I used internal frames I had problems with focus as well, so I ended up not using them.
Jeff
20 years ago
You could add an InternalFrameListener, and listen for closed events and then remove the file from the HashMap when the internal frame is being closed.
Jeff
20 years ago
I'd probably use something like a HashMap. That way whenever a file is opened you could create the Internal Frame and store it in the map with a key of the file name. Then whenever the user clicks to open a file you could search the map to see if a key of that file's name already exists, if it doesn't create the frame and store it, otherwise you could get the internal frame from the map and bring it to the front or whatever.
Jeff
20 years ago
What you need to do is call setOpaque( false ) three times, first on your text area, then on your JScrollPane, then on the JViewport that the text area is in. Then you should be able to just add the scroll pane to your image panel and I think it'll work.
Jeff
20 years ago
I assume you're probably referring to the focus border that's painted when the button has focus. To get rid of it just call setFocusPainted( false )
Jeff
20 years ago
The easiest way would be to use a JSplitPane. One way to do it would be to put the component you had on the WEST on the left side of the split pane, then the component you had in the CENTER on the right side of the split pane. Then you could just add the split pane into the CENTER of your BorderLayout.
Jeff
20 years ago
I would recommend Sun's Java Tutorial, specifically the "Creating a GUI with JFC/Swing" trail.
And with regards to using a "layout manager inside of another layout manager" it's really quite simple. You would do it by simply setting the layout of a panel to the second layout you want and then adding it to the original layout. The easiest way to think about it is to split your interface into sections, using a panel for each section with whatever layout is needed. Then use another layout to bring each panel into the final UI design.
Jeff
20 years ago