Daniel Searson

Ranch Hand
+ Follow
since Dec 03, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Daniel Searson

Make sure the PATH variable does not include the old installation directory at all. You might also need to reboot your computer.
20 years ago
When actionPerformed() is called on the button, where is it fetching the filename from? Is the filename only being stored in one place or do you have it set in two places?

The other thing is that you might need to reload the audio stream, but I don't know too much about audio streams.
20 years ago
Thanks for your reply James. It seems that I have found a solution to the problem myself.

Basically the solution I have found is to use the getResource() method in the Class class to retrieve a URL to the file I need. This works whether the image or other required external file is inside the JAR file or not. This is all on

http://www.cs.duke.edu/courses/fall01/cps108/resources/jar.html

Thanks again.
20 years ago
Hi Artsi,

Thanks for your reply. I'm not really concerned about packaging up different class dependcies, just about packaging the image files into the JAR as well.

Basically, I don't want users to have to install anything - just download the single JAR from my website and run that.
20 years ago
Well, if its absolutely mission-critical that it draws symmetrically you could write your own code to grab the image data of one corner, invert it, and then redraw it on the opposite side.
20 years ago
Something that always works for me is:

invalidate()
validate()
repaint()

Sort of covers all of your bases. Hope that helps.

Normally, I would expect the JLabel to repaint itself when you call setText() so its surprising that you are having that problem actually...
20 years ago
Howdy folks,

I am currently working on a relatively simple Java application that uses Swing for its GUI. As such, there are several image files that it needs to load for icons etc. There are also a few text files that it might need to read for help files.

Ideally, the entire application, including all of the picture/text files, will be packaged into a single JAR file. At runtime, the application would be able to load the required files out of the JAR file.

Now, I'm not sure if there is a simple solution to this. If there is, please share because my googling hasn't given me much success.

Alternatively, I suppose what the program needs to do is find the JAR file that is being loaded from - this in itself is not an easy task because the working directory may not always be the same as the directory with the JAR in it. After finding the JAR file, I figure I can use the JAR API included with Java to pull the required files out and load them up.

Any help would be greatly appreciated. Thanks.
20 years ago
A JWindow would be much nicer from the sounds of things. Its pretty much exactly the same as a JFrame but with no title bar (that you don't have anyway) and it doesn't have resizing controls.

One downside is that I'm pretty sure it won't show up in the task bar at all, which may or may not be a problem for you.
20 years ago
I would agree that your best bet is to write a class called "StationList" which has a List encapsulated inside of it. Then write a few accessor methods like setStation, getStation, size, addStation and maybe removeStation. These could all operate on a class called "Station" which has whatever properties you want a station to have....

I tend to do this with most custom list applications, and I like it because you are writing the list accessor methods yourself, so you can control what goes in and what goes out. A BIG plug here is that you do the casting to Object inside these accessor methods, so all the "client" programmer sees is Station's going in and out.

You can also do things like check for null, so that null references cannot be added to the list.

Hope that helps.
20 years ago
When you start off your constructor it should read 'public BarGraph()' and not 'public void BarGraph()'. Constructors never return a value so you don't need the 'void' bit.
21 years ago
Hi Jim,
Its definitely worth a shot. Try overriding the paintComponent() method within the JComboBox and drawing an Image instead. You can load up an image file into an Image object using Toolkit.getDefaultToolkit().createImage() and draw it using Graphics.drawImage() - check the documentation.
I imagine that performance of the combo box would be affected, but I'm not sure by how much.
Good luck.
21 years ago
The exception you are getting is because you are in a Java applet and Java applets aren't allowed to access other files. The method getImage() in the Applet/JApplet class is a way around this (I'm not entirely sure how it works, but it does).
Creating an ImageIcon using "new ImageIcon()" is not possible because it relies on normal I/O. So you get an access permission exception. Instead, use getImage() from the Applet class to create you're image. Then create a new ImageIcon using that Image object. This should get rid of that exception.
If you are doing anything in Swing you should use paintComponent() and NOT paint(). This stuffs up the way Swing does back buffering.
When you are setting the size of a JPanel, you should use setPreferredSize() instead of resize(). You will probably have more luck this way.
Hope that helps.
21 years ago
Yep, you're pretty much right when you say that you can't rely on the user to have a recent JVM. The Swing JApplet is also slower of course, like everything in Swing. If you find that you really need the features that Swing offers then just use the JApplet anyway and redirect users who don't have the latest version to the Sun website.
21 years ago
Check the API documentation - there is a method in the JMenu class that spits out a JPopupMenu that is exactly like the JMenu.
Hope that helps.
22 years ago
When printing a double value using Double.toString(), they always come out with about 8 digits shown. I can't find any way to make the method print shorter versions (say, to 4 decimal places). Is there any way to achieve this, short of writing my own string formatting method? (which I want to avoid...)
Thanks.
22 years ago