Win a copy of Rust Web Development this week in the Other Languages forum!

Charles Mulloy

Ranch Hand
+ Follow
since Oct 25, 2009
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 Charles Mulloy

I'm a little confused now. I thought I was actually putting things into the list. And get(int index) returns the object at the index and not the String equivalent, right?
10 years ago
Like the title says. If I put an object like a string, int, long, or even a custom object into an array list how big can it be without it returning an error? I'm not asking about the maximum size of the list but the individual element(s) going into the list. I know that a string object can't be larger than 2 or 4 GB but i'm not sure if objects in an array list have special restrictions on them.
10 years ago
Found the problem.

First off, line 31 is useless. It is from a past attempt and I forgot to remove it, so ignore it altogether.

Second, the error is in line 24. I constructed the FileOutputStream wrong. I used...

This will delete the file if it exists. But this...

... will make it append to the end.

The final product (before I start adding stuff):


@Amit: I only wanted to give credit where it was due. I had code before seeing this link, but it wasn't working like I wanted. What I have now is a derivative of the code found there.
10 years ago
I'm trying to design an open source, java based download module. I'm still in the proof of concept stage though. I've made the code necessary to download a file, but to test the resume feature, I would terminate the process before the download finished and then restart it. But when it restarts, it deletes the file and makes a new one in it's place. Here is my code so far:


How can I make it pick up where it left off?

Note: Code is adapted from http://www.roseindia.net/java/java-conversion/InputstreamToFile.shtml. Not mine.
10 years ago
Awesome! It works perfectly. Now I have to figure out an easy way to delete the tabs and I'll be on easy street.

Also thanks for the links. They help immensely.
11 years ago
I have no clue how to cast. I googled it and the tutorials all use arithmetic examples. When I add to the tabbedPane I do this.

CharacterPanel extends JPanel, and getStringFromUser() is a dialog method I use to get strings from the user. How would I cast in this instance?

edit: I think I should also mention that CharacterPanel has a getText() method that returns the text in a JTextField.
11 years ago
I'm trying to reference the component in the tab, which will always be a JPanel.
11 years ago
I am writing a program that will help keep track of characters (like from books, movies, etc). As of right now I have a method that will create a JPanel and add it to the JTabbedPane. I could also probably delete them at will. But because the number of tabs is undetermined at runtime, I have to do this:

The JPanelMaker is a JPanel form that I have. It is my intention to have a method go through each and every currently open tab and get the data from it (JTextFields and such). If possible, I would like a way to use the methods of the component in a particular tab. Kinda like how I do with vectors so I can load a file and be right where I left off.

Is there a way to access methods from component in a specified tab?
11 years ago
I'm about to write a program that adds and removes tabs from a tabbed pane. But I'm not so sure of the mechanics behind the remove() method. The addTab() method requires a component. So far I've only used JPanels. If I use the remove() method and target a panel, will it just drop it from the TabbedPane but stay in memory or will it drop the panel along with everything in the panel? I'm not sure it matters, but what I usually do, for organization's sake, to create JPanels is I use a single method to construct the panel and then return it like this:

If that doesn't work how can I drop an object? I'm asking this because I don't want my application to eat anymore memory that it has to.
11 years ago
A while back, I was extending ActionListener but for reasons I can't fathom it stopped compiling right. I looked around and found the following method.



I don't know what this technique or concept is called, but I want to learn more about it, instead of just copy, pasting, and modifying it without understanding the mechanics behind it. Anyone know what I'm talking about?
11 years ago
In all honesty, I was looking for something like the first method Sunny posted. But after double checking the javadocs for the Scanner class, I realized that methods like hasNextInt() don't advance the scanner to the next int or whatever. Thanks for the help guys!
11 years ago
I need a way to test a string to make sure that it only contains numbers. The program it's going into uses a while() loop to run a "sanity check" on the file it tries to open. The file's data pattern is "numbers string numbers string etc". The string can be whatever but if the scanner find's a letter in the next() return when it should be numbers, then the loop should break. Is there an easy way to check a string specifically for letters or am I making this more complicated than it needs to be?
11 years ago
I see. I did a search like you said and found out that arraylists are not thread safe. As far as threads are concerned, the Vector is not used or called outside of a script and even empties once the script completes. Nothing accesses this vector outside this script and chances are there never will be. Should I switch to arrayLists, keep the vectors, or just experiment for a few days?
I'm using NetBeans 6.9. My program is using a vector constructed like this:


However, though the program compiles and runs flawlessly, NetBeans is giving me a warning (in the left margin, where the light bulbs show up) and says "Obsolete Collection". It also says that I should surround it with something that looks WAY over my head:



I didn't until recently get this warning. Is there something better I'm supposed to be using or can I just suppress the warning?
Here's a method that I made if anyone's interested. I had some trouble at first but I got it working.




Simply modify the code so that fileString is passed to the file constructor you want to use. Now I gotta get the filter working. Thanks for the help every one!
11 years ago