I'm writing a new Java 6 Swing application and want to have a "Show tips at start-up" feature. I've done this before, but never with localization in mind.
In the past, my tips dialog used an XML file to hold the tips, but I'm afraid this will make things difficult when it comes time to translate these tips into different languages. I've thought about using a .properties file like with other strings in the application, but wonder if this is a maintainable approach. I would like to give the user the ability to add their own tips which will also display in the same dialog.
Is the properties approach the way to go? If I allow users to add their own tips, I'll need some way to make sure the keys (for text retrieval) are unique.
I would say the properties files is the best approach. But i would make the user a screen to add new tips, instead of letting them modify the properties files directly.
To read all the keys, you can use java.util.ResourceBundle you will find a method called getKeys
You should build a screen like this:
(source: cimco-hsm.com)
Related
I am looking to build a web app that allows you to pick from options like color and size, essentially custom building your own item. Similar to this: http://www.mangobikes.co.uk/bikes/custom/custom-build-your-single-speed-bike
It needs to allow me to display different pictures depending on the choices, and its supposed to have 5 dropdown menus with options. Those options also have submenus to pick colors from.
I am new to Java, and not sure where to start. Is there maybe a good how-to somewhere on the internet? And if not, any hints on how to set it all up?
Thank you
It is quite difficult to answer such a broad question (and that's why it is downvoted), but sometimes it is also difficult for beginners to know where to look.
So some pointers then:
The first thing you want: "display different pictures depending on the choices, and its supposed to have 5 dropdown menus with options" is a matter of web user interface, so you can solve it with basic javascript and HTML (see Change image source with javascript as an example). You can do that in an offline html file (you don't need java for it).
Then I assume that you need some kind of backend to send the selected values and do whatever you need with them. Without more information and assuming you want to do it with java, maybe a good alternative to prototype it could be the spark java framework.
I am trying to have my custom file type .vrs (which for all intents and purposes is an rich text format).
I am pleased with what I have since I am self taught.
But am having difficulties associating that file with my program so that when a user double clicks it, it automatically open my document editor.
All searches so far have come up with either right clicking and setting the association, but this is not what I would need.
I may not have explained as well as needed so think Photoshop's .psd when you install Photoshop all psd files are automatically set to open when you double click them.
Hopefully I have been clear enough for you to help.
Also whilst the question is regarding Java any resource be it for C# C++ etc, would also be appreciated.
Thanks for your time and any responses.
This functionality is system dependent, and in Windows involves the registry. If you really want to delve into this, take a look at this post, which goes into great detail on how to accomplish programmatically setting a file extension association using C++. If this is helpful, please write back telling us how you solved the problem in your individual situation.
If that isn't helpful I would try this link instead, as it links to more resources and demonstrates a little C# code.
I am new to using JTrees in Java. I am kind of in doubt as to how to configure it the way I want. I've been looking around for answers, but either I am not searching right, or maybe it's not possible without extensive coding?
I want to use a JTree to show all files on the computer and update whenever a file is changed/added/created/deleted etc. (Does JTree keep track of this itself?)
Place a check box next to all files that have a Cpp extension.
Some kind of method to get all the files that have had their box checked and pass it to parser I've made.
How would I go about this exactly? I can't really seem to find an easy way to configure the JTree as I please, unless I am completely missing something?
I did a project for university (it is a personal implementation of Zork the Game). As asked I did it with a text interface, using system.out.print. Is there a way to "put the text interface in a GUI" ? I mean for example a simple window with 2 fields, one that displays text output and one for the text input by keyboard.
I downloaded windowsBuilder for eclipse but.. I dont know what to do! :(
Thanks!
Sure there is, just change the output stream for System class. Create a PrintStream that will write out your data to your swing components and then replace it in the System class to use it.
System.setOut(printStream);
If you're doing this for a text game, I'd recommend using a Glk library. Glk is a cross-platform windowing I/O system designed for text games. You may have to write a JNI interface since the libraries tend to be written in C: an existing project called GlkJNI is meant to work the other way around, so a C program can use a Java UI, but it might be helpful anyway.
For an example of how to create a GUI that does what you are asking, take a look at this article: http://www.comweb.nl/java/Console/Console.html
This does not use best practices for building a GUI, but for quick and dirty, it'll get you started. You really should read up on how to properly write a Swing application, though, if this is going to be something you are serious about.
I want to make a help/instructions page for my Java program but I really don't want to have to go through and program all the frames and searching and such. Is there a package or program that I can just insert the data into and it will read it and create the dialog? I couldn't seem to find anything about it on Google.
It doesn't have to look like this at all but I like having the table of contents and the search at least.
alt text http://www.freeimagehosting.net/uploads/752f287397.png
Thanks
Java help system : https://javahelp.dev.java.net/
The windows help dialog you show is part of the Window Help subsystem. You could easily create a help file for that and launch it from your Java application, but it would be platform specific. If you want to implement cross-platform help functionality, you're probably going to have to implement it yourself, but you could probably do it simply by including a set of HTML resources and using an embedded lucene index to supply search functionalty.
Have you consider using a simple HTML based manual and/or website where all that information may be accessed through?
Pretty much like http://java.sun.com/javase/6/docs/ for instance where you have a main page and you can navigate the topics from there?
If that's a website ( rather than a local /doc directory ) you can have the extra benefit from having a full featured search engine index it for you.
See also: Google is the Help menu
After all, how many times do you use these help systems instead of searching the web?