Help coderanch get a
new server
by contributing to the fundraiser

Jahed Hossain

+ Follow
since Nov 30, 2012
Jahed likes ...
Firefox Browser Windows Linux
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jahed Hossain

Tony Docherty wrote:Or you could just get the selected item, use the model's clear() method to remove all the items from the list and then put the selected item back into the list.

Yeah, that's what I thought of before, but I remembered that I also have to delete files based on the names on the listBox, so that wouldn't totally help
10 years ago
I have a window with a JListBox and a button which deletes all the elements of the list except the element that is currently selected on the JListBox.

So, this is the code I've written at an unsuccessful attempt:

I'm actually just confused of what to do in order to make this happen, I'm trying anythin.

The strange thing is that there is always going to be an ArrayIndexOutOfBoundsException and after that listBox's Model gets modified without me trying to change it, I've only tried to changed defaultListModel.
10 years ago

Ulf Dittmer wrote:If you want cross-platform compatibility, use the java.util.prefs API, and you won't have to worry about where it stores anything :-)

Thanks! I think this will work.
10 years ago
I haven't used OS X much. I don't know where settings are kept.
Like for example in Windows: %AppData%\AppName
Linux: ~/.appname

So, in order to make my java application cross-platform, where can I store a settings file in OS X?
10 years ago
I've been trying to just make this work but.. I am trying to get the directory listings of a path and then use that to search for files that starts with ".mbf" extension into a String array and then set the ListBox Items to that String array.

I'd be grateful if you give me an example of your own solving my problem than try and fix this[/b]:

1. Create ListBox
2. Store directoryListings of "./backup" in a String array
3. Sort through the array and select only the ones with ".mbf" extension and save it into a new array
4. Set the ListBox's Items to the data in the new array.
10 years ago

Richard Tookey wrote:Why do you need to access a jar file from your application?

As far as making things cross-platform is concerned environmental variables are bad news since event if they exist they may not have the same name on different OS. You should try to make sure any files are in a subdirectory relative to the user's home directory or the current working directory. The home directory is always available using System.getProperty("user.home") and the working directory using System.getProperty("user.dir") . When I want to create files I usually use the home directory as the base directory since that is the only directory that is pretty much guaranteed to be writeable on all OS. If you need to create temporary files then you can also use System.getProperty("") but remember that on some OS files in this area get remove when the system is re-started.

Actually I'm creating a Minecraft Backup & Restore application and I don't want the users to go through the trouble searching for the minecraft location. Thanks for the info.
If I finish this, this will be my fully functional GUI app in java :|

10 years ago
I need to be able to access Environment Variables to find files such as:

Plus, I want to make my application cross-platform on at least Windows and Linux OSes.

So, how do I do it?
10 years ago
I'm currently using Net Beans and I know that there is many other IDEs out there like Eclipse. I just want to know more about each of the features of the various IDEs has to offer.

Paul Clapham wrote:The CLS command works for me in Windows 7. What happens when you type CLS at the command line?

(Also I will move this to the General Computing forum since it isn't about Java.)

I'm looking for a statement or something you can write in java to clear the screen.
11 years ago

Adam Burda wrote:Need help. This should be simple, but i can not seem to get it.
I want to take a double like 0.01 and then times it by 2 for each output.
like this....
Do i use a loop of if, else?

Thank you.

You can use a loop like:
11 years ago
I'm using Windows 7 and I'm wondering how I can clear the command line screen,
using java code, like normally you would write CLS for Command & Prompt.
11 years ago