Nice news, Tk-UI provide an implementation of CSS in Java for Swing and SWT. This is a nice news. It can make easiest for making great interfaces.
An example :
And you can find more information here.
Java and php expert
Nice news, Tk-UI provide an implementation of CSS in Java for Swing and SWT. This is a nice news. It can make easiest for making great interfaces.
An example :
And you can find more information here.
The main problem with JDialog is that it is not appear by default in taskbar. (You know it is where application are at the bottom on your screen, near the Start menu.) Further more I like my JDialog also got a identified icon.
The first time I search for resolving this two problems, I found one solution for each problem but they don’t work together. After a few tries, I found the best way to do it.
This is my JDialog’s constructor :
public MasterPasswordForm() { super(null,ModalityType.TOOLKIT_MODAL); setIconImage(new ImageIcon( getClass().getResource("/images/icon.gif") ).getImage()); setLocationRelativeTo(null); initialize(); jDialog = this; }
The call to super’s contructor make application appear in taskbar.
The setIconImage’s function do for my icon !
The setLocationRelative to null it is for centering my Jdialog !
And this is a perfect integrated JDialog !
This tips is easy to find nevermind I post it to have a note about it.
For example in a JDialog or JFrame constructor :
this.setLocationRelativeTo(null);
Easy isn’it ?
I don’t know why but I need at least 4 or 5 hour just for creating a simple Form. I don’t know if I am using wrong tools but it is a little… embarassing to need so many time for making interface.
According me, It coul be link to Swing’s philosophy. I think now language must be more like HTML like. It is enought simple to make interface as fast as the wind, and got enought options to be more configurable.
Perhaps making html interface for application is a better idea ? I don’t know but I need to find a way to be better in interface development because next form would be complicated.
So the good news, it is that now user car change Social Bridge’s preferences with a form and save it….
Next step would be to allow user to create new treatment….
Here a small code example to manage messages into java application. This mono instance class allow you to load messages according language. You could also replace token into messages with dynamical argument.
You can find java class at the end of this post.
This class does not contain a lot of code. The next instruction allow to load messages according language :
msg = ResourceBundle.getBundle("message", new Locale(ApplicationPreference.getLanguage(),"") );
This allow to load message.properties from the classpath. If language is “fr” then the file which is going to be loaded is “message_fr.properties”. But if file doesn’t exist so application would try to load the properties according default language defined for Java (then.. it is the one by default). And if the fileis not find again the file message.properties is loaded (f not find again then an exception is raised).
Then deux function allow you to get message from key. To manage messages with token, the class use MessageFormat. Here the code :
return MessageFormat.format(getInstance().msg.getString(key),arguments);
The argument called “arguments” is an object list.
How does it work ? Then it is very simple. Imagine this messages into the properties file :
msg1=My name is {1} and not {2}If I called the function with a list with John and Tom, I will got this message :
My name is John and not Tom
Here is the example end, Have a nice day….
package com.cba.socialBridge.util.application; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; public class ApplicationMessage { static protected ApplicationMessage instance=null; static public String[] languageList = { "Français", "English" }; static public String[] languageListCode = { "fr", "en" }; protected ResourceBundle msg; private ApplicationMessage() { super(); msg = ResourceBundle.getBundle("message", new Locale(ApplicationPreference.getLanguage(),"") ); } public static int getIndexLanguageInLanguageList() { int index=-1; for (int i=0 ; index==-1 && i { if ( languageListCode[i].equals(ApplicationPreference.getLanguage()) ) { index = i; } } return index; } protected static ApplicationMessage getInstance() { if ( instance==null ) { instance = new ApplicationMessage(); } return instance; } public static String getMessage(String key) { String result = "?" + key + "?"; try { result = getInstance().msg.getString(key); } catch(Exception e) { ApplicationLogger.getLogger().error("There is a problem with messages management : " + e.getMessage() ); } if ( result == null ) result = "?" + key + "?"; return result; } public static String getMessage(String key,Object[] arguments) { String result = "?" + key + "?"; try { result = MessageFormat.format(getInstance().msg.getString(key), arguments); } catch(Exception e) { ApplicationLogger.getLogger().error("There is a problem with messages management : " + e.getMessage() ); } if ( result == null ) result = "?" + key + "?"; return result; } }
get latest updates on site news and site post