Change language during Runtime
Hey,
i have following problem: I use Resourcebundles to internationalize my Java Applet. Now i want to add two Buttons where the user can change the language.
I changed my i18n class to the following code:
public class Messages
private static final String BUNDLE_NAME = "de.mypackage.core.messages"; //$NON-NLS-1$
private static ResourceBundle resBundle = null;
static
try
resBundle = ResourceBundle.getBundle(BUNDLE_NAME);
} catch (MissingResourceException exc)
System.out.println("Can not find the ressource bundle for i18n.");
static void setLocale(Locale locale)
resBundle = ResourceBundle.getBundle(BUNDLE_NAME, locale);
public static String getString(String key)
try
return resBundle.getString(key);
} catch (MissingResourceException e)
return '!' + key + '!';
}When pressing the "english" button following code is executed:
Messages.setLocale(Locale.ENGLISH);
applet.repaint();
applet.validate();But the language doesn�t change :-( What can i do?
Thanks alot
But the language doesn�t change :-( What can i do?I once did it this way: the problem is that all your Components already
had their text set (e.g. JButton.setText(...)) and all those components are
not aware of the fact that you changed your Locale so they don't do
anything.
Therefore I extended all these Swing classes and added an interface:
LanguageListener which gets invoked when a Locale has changed.
The Language listener just extends the PropertyChangeListener.
When the method is invoked the Component sets its text again according
to the now current Locale. It's a bit of work but it pays off ;-)
kind regards,
Jos
Similar Messages
-
How to change language during a browsing session
Hi everybody,
We need an implementation where a user can log in with a guestuser (which is shared with different real persons).
So we have user "Guest1" being used by x number of persons.
During their browsing session there persons need to be able to switch the language of the portal between English, French and Dutch WITHOUT changing the language attribute of the portal user "Guest1" in the UME.
Does anybody know how we can achieve this?
I already thought about changing the browser language using javascript but I cant find a way to do this...
(tried navigator.userLanguage = "EN" but this gives me nothing)
Thanks in advance
Kind Regards
Wouter Delellio
Edited by: Wouter Delellio on Nov 12, 2008 4:20 PMHi,
Take a look at this
Setting/Getting Available Languages in the portal using code
Regards
DV -
Is it possible to change fps during runtime? in Flash CS4 (AS3)
hi,
I was wondering if there is a way to change fps(Frames Per Second) during run time using AS3.
is there? if so is it recommended? or is there a way to slow down the execution of the code(like adding a pause?)
Thank you for attributing anything related!You can use the stage.frameRate property to eadr or set the fps rate during run time. The only way to really pause code from executing is to build the paused code into a function and delay calling that function using some form of a timer (like setTimeout).
-
How to convert ABAP Reports in other languages during runtime.
Hi Gurus,
In SAP during Log-in, I select "EN" sa my language. Is there a way where in I will log-in using English language but upon generating abap report, the result is in Chinese characters?
Thanks in advance.If you use chinese data in the program then it should work.
DATA: var(20) type c.
START-OF-SELECTION.
var = 'u6807u51C6u6587u672C'.
write: var. -
Hi there,
I have a rather difficult question I think.
I work with jsp and struts and I want my users to change the language of the content by clicking on a button.
I have the following method in my action:
public ActionForward execute(ActionMapping mapping,ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session= request.getSession();
System.out.println(request.getLocale().getLanguage()+" bla");
Locale locale = (Locale) session.getAttribute(Globals.LOCALE_KEY);
System.out.println(locale.getCountry()+" "+locale.getLanguage());
String language=request.getParameter("language");
locale = new Locale(language);
session.setAttribute(Globals.LOCALE_KEY, locale);
Config.set(session, Config.FMT_LOCALE, locale);
return new ActionForward("/pm_main.jsp");
Why doesn't this work?
I just want to change the users locale, so the site gets his resources from the new resources.properties file...
I hope someone knows where I'm getting at!
ThanksYou are replacing Globals.LOCALE_KEY in the session. You are doing this in the execute method of the action. But execute is not really the first thing that happens, nor the last, in the process of receiving the request and sending the response. So if Struts for some reason sets this value in the session after execute (I'm not sure why it would) then it would overwrite whatever you put there.
-
Change Language in runtime ( in the portal)
Hi ,
We use the personalize to change the language ,
most of the WD application translate to 2 languages...
When we change the languages all the menus(roles) translated to the chosen language..except the application ( xlf files ) .
We need to close the browser , open new one and gust then we see the translations....
How i see the translation without closing the browser ???
ThanksFaniel,
Please read my answer to similar question:
Re: Urgent: Internationalization
Valery Silaev
SaM Solutions
http://www.sam-solutions.net -
Change titles during runtime?
Hi there,
Suppose I have a table in the Field Explorer and all columns have name and HeadingText. Is it possible to change the heading text at runtime in the JRC SDK? How?
Thanks,
PascalIn the designer, create parameter fields of type String, one for each heading that you have.
Remove the heading that you have, and replace with the parameter field.
It's not a pretty solution.
Sincerely,
Ted Ueda -
Dear Friends,
I have procedure to retrieve data from tables, this procedure uses cursor to fetch the records into the required data block.
i need to change the where clause of the query which used to build the cursor during run time based on data will be gathered from another data block. how can i achieve that??
is there any suggestions???
thanks in advance
MohammadHello,
Check Re: Control Block
for changing the WHERE attribute of a block.
In your case, you want to set the WHERE condition for the cursor and this depends on a value or values you get from another block. In this case, it is best to give the user a way to either enter that condition or store the result you get from the other block in a variable and use that variable in your cursor.
You can use a parameter to store that condition and this will be local to the current form. If however you need to get that from another module, then you might need to use a parameter list and you can pass the WHERE condition in there to the module that has your cursor.
Hope this helps. -
Changing fieldcatalog during runtime in an ALV
Hi All,
I have a requirement like : On selection-screen I have 2 input parameters and 2 pushbuttons namely. After input, if press one of these pushbuttons a pop up will come which is having 2 radio buttons. Based on the selection of the radiobutton, I need to make some of the fields editable in a fieldcatalog. But what my problem is .... whatever I select[Radio Button] the first time only that fieldcatalog is getting displayed. Hope I am clear in explaining my problem.
-SatyaPriyaHi Sathish,
I have used the methods <b>get_frontend_fieldcatalog</b> and <b>set_frontend_fieldcatalog</b> of class cl_gui_alv_grid..
-SatyaPriya -
A question about how to change a button in a JPanel during runtime
I am a beginner of GUI. Now I am trying to change a specific component, a button, when the application is running. For example, I have 3 buttons in a JPanel. Each button has its onw icon. If I click one of them, it will change its icon, but the other two don't change. I don't know if there is any method for changing a specific component during runtime. If any one knows please let me know, I will appreciate that very much!!!
What you're going to have to do is loop inside the actionlistener but still have accessability to click while its looping. I don't know much about it, but I think you're going to need a thread. Try something like this... (it doesn't work yet, but I have to take off)
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class buttonxdemo extends JFrame implements ActionListener{
Buttonx mybutton;
//set it all up, make it look pretty =]
public buttonxdemo()
mybutton = new Buttonx("default");
getContentPane().add(mybutton.thebutton);
mybutton.thebutton.addActionListener(this);
this.setDefaultCloseOperation(3);
this.setSize(200,200);
public void actionPerformed(ActionEvent ae){
if (ae.getSource() == mybutton.thebutton)
if (mybutton.keepGoing)
mybutton.keepGoing = false;
else if (!mybutton.keepGoing)
mybutton.keepGoing = true;
mybutton = new Buttonx(/*Icon,*/"My Button");
//getContentPane().remove(mybutton);
//getContentPane().add(mybutton.thebutton);
mybutton.startstop();
}//actionperformed
static void main(String args[])
new buttonxdemo().show();
} //movingicondemo
class Buttonx extends Thread{
public boolean keepGoing;
//public Icon ICx; //perhaps an array, so you can loop through?
public String strbuttonx;
public JButton thebutton; //may have to extend JFrame?
public Buttonx(/*Icon IC,*/ String strbutton){
//ICx = IC;
strbuttonx = strbutton;
thebutton = new JButton(strbuttonx);
public void startstop()
int i = 0;
while (keepGoing)
thebutton.setLabel(strbuttonx.substring(0,i));
//if an array of Icons ICx
//thebutton.setIcon(ICx);
i++;
if (i > strbuttonx.length() - 1)
i = 0;
try
Thread.sleep(1000);
catch (InterruptedException ie)
System.out.println("sleep caught: " + ie);
}//startstop()
}//buttonx
kev -
Changing type of process during runtime
hi to all/Mike/Antony
is there anyway to change a sync process to async during runtime?
thnx in advance
KAMhi
sorry for making confusion by putting a (little) wrong question because of being in a hurry...
it was supposed to be that " is there anyway to change the type of the process from async to sync after executing the process"
i m sorry for taking ur time by putting a wrong question!
actually i made a sync process of "HelloWorld " but mistakenly declared its type as "async" and it did not generate the required output, because it was an async process and i was treating it as a sync one!
thanks for ur interest. i'll write, as i find the solution.
KAM. -
Is it possible to add/change a ViewContainerUIElement during runtime?
Hi all,
i want to add/change the content of a ViewContainerUIElement (VCUI) during runtime, but it doesn't work as expected (or hoped;). What i got working so far for an <b>already exising</b> VCUI is:
1. Find the IWDViewContainerInfo for the VCUI
2. If no default view usage exists, create an embedded view usage and set is as default.
3. Set the component usage to the IWDComponentUsageInfo requested.
4. Set the view to the IWDViewUsageInfo of the interface view, which should be the content of the VCUI.
This doesn't work, if it's done after the wdDoInit()s of the controller hierarchy has been processed. The component, which is represented by the usage, is deleted and recreated, but the visual representation doesn't get updated (e.g. no changes on the display) if it's done in an action handler for example. Why? If i change the component usage (cloned component usage) nothing happens too.
Even more problems arise, if i try to add a new VCUI. The steps are pretty the same as before, what is done additionally (and prior the steps above) is:
1. Creating a IWDViewContainerInfo from the IWDViewInfo of the "parent" view.
2. Creating a IWDViewContainerAssignmentInfo from the view usage of the "parent" view
3. Setting the created IWDViewContainerInfo as view container in the assignment.
4. Create the VCUI, set the view container name to the name of the created IWDViewContainerInfo and add the VCUI to an arbitrary container in the parent view.
But this doesn't work, i'm getting:
java.lang.NullPointerException
at com.sap.tc.webdynpro.clientimpl.html.uielib.standard.uradapter.ViewContainerUIElementAdapter.getContent(ViewContainerUIElementAdapter.java:98)
What is wrong? What am i missing?
Thanks in advance.
StefanHi,
I had the same problem with
"java.lang.NullPointerException at com.sap.tc.webdynpro.clientimpl.html.uielib.standard.uradapter.ViewContainerUIElementAdapter.getContent(ViewContainerUIElementAdapter.java:98)"
when I included ViewUsages dynamically in an action handler (outside wdDoInit()).
The code below fixed that problem.
This code creates a new OutboundPlug for the embedding view with the embedded view as target and fires the plug.
<i>// Create OutboundPlug
IWDOutboundPlugInfo outboundPlug = embedderViewInfo.createOutboundPlug();
//Create navigation link
rootViewUsage.createNavigationTarget(outboundPlug.getName(), interfaceViewUsage, "Default");
// fire navigation link
wdThis.wdGetAPI().firePlug(outboundPlug, Collections.EMPTY_MAP);
</i>
I hope I could help you. Probably you don't need the information anymore, but perhaps anybody else has the same problem.
Regards, Alex -
Change XSD / XML dataset during runtime and display texts in field explorer
Hi there,
I am changing the datasource of a report during runtime. Afterwards, I would like to change the texts of the fields appearing in the field explorer.
I tried:
CrystalDecisions.ReportAppServer.DataDefModel.XMLDataSetClass xmlDS =
new CrystalDecisions.ReportAppServer.DataDefModel.XMLDataSetClass();
byte[] xmlContent = reportContent.getXmlContent();
byte[] xsdContent = reportContent.getXsdContent();
CrystalDecisions.ReportAppServer.CommonObjectModel.ByteArray xmlData =
new CrystalDecisions.ReportAppServer.CommonObjectModel.ByteArray();
CrystalDecisions.ReportAppServer.CommonObjectModel.ByteArray xsdData =
new CrystalDecisions.ReportAppServer.CommonObjectModel.ByteArray();
xmlData.ByteArray = xmlContent;
xmlDS.XMLData = xmlData;
xsdData.ByteArray = xsdContent;
xmlDS.XMLSchema = xsdData;
rasDoc.DatabaseController.SetDataSource(xmlDS, "", "");
rasDoc.Database.Tables[0].Description = "POMMES";
for (int i = 0; i < rasDoc.DatabaseController.Database.Tables[0].DataFields.Count; i++)
rasDoc.Database.Tables[0].DataFields.Name = "TEST";
MessageBox.Show(rasDoc.Database.Tables[0].DataFields.Name);
rasDoc.Database.Tables[0].DataFields.HeadingText = "HOORAY";
rasDoc.Database.Tables[0].DataFields.Description = "NOPE";
MessageBox.Show(rasDoc.Database.Tables[0].DataFields.Description);
MessageBox.Show(rasDoc.Database.Tables[0].DataFields.HeadingText);
When running this, the message boxes include the right strings I set before but when this is done, the filed explorer still shows no changes. What am I doing wrong?
Also, I would like to change the field texts that are displayed in the field explorer. How can this be done?
Thanks,
PascalAlso, I do not understand why I am not able to change the display of the fields in the filed explorer.
This coding does not change a bit, but why??
//preparation
string tableName = reportDataSet.Tables[0].TableName;
// Get the table definition exactly like the definition of my own dataset.
CrystalDecisions.ReportAppServer.DataDefModel.Table table = GetTable(tableName);
table.ConnectionInfo = connectionInfo;
//delete all existing tables if there are any
foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table oldTable in rasDoc.DatabaseController.Database.Tables)
rasDoc.DatabaseController.RemoveTable(oldTable.Name);
//add my new table with the IDs of the XSD
rasDoc.DatabaseController.AddTable(table, null);
//now I want to change the displayed fields texts
CrystalDecisions.ReportAppServer.DataDefModel.Tables modifyTables =
rasDoc.DatabaseController.Database.Tables;
CrystalDecisions.ReportAppServer.DataDefModel.Table myTable =
(CrystalDecisions.ReportAppServer.DataDefModel.Table)modifyTables[0];
Fields fields = myTable.DataFields;
for (int i = 0; i < fields.Count; i++)
ISCRField field = fields<i>;
ResultFieldController resultFieldController =
rasDoc.DataDefController.ResultFieldController;
try
resultFieldController.Remove(field);
string sText = "";
sText = "Bäschreibung" + i.ToString();
field.Description = new string(sText.ToCharArray());
sText = "Häding" + i.ToString();
field.HeadingText = new string(sText.ToCharArray());
//sText = "Näme" + i.ToString();
//field.Name = new string(sText.ToCharArray());
resultFieldController.Add(-1, field);
catch (Exception exp)
MessageBox.Show(exp.Message);
I am completely stuck.
Thanks for any help.
Pascal
Edited by: Pascal Schmidt-Volkmar on Sep 30, 2008 9:31 AM -
Changing Changing Database Location During Runtime
I'm using Netbeans 6.0.1. My database location ALWAYS change in place. That's why I'm planning that there would be a "Database Settings..." inside my program. But I don't know how to change the current: user, password, url settings of my program DURING RUNTIME. Here's my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="LibraryPU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<class>desktopapplication2.Books</class>
<properties>
<property name="toplink.jdbc.user" value="root"/>
<property name="toplink.jdbc.password" value="password"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/Library"/>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>To solve the "why the hell would I want that stuff inside a jar file" issue, I googled a bit and found this
style of approach in a Oracle forum. Essentially think of the persistence.xml file as an template
that the program uses.
I use a properties file to set all local DB configuration aspects. Load the properties at application
startup and set then extract the required fields into a Map to create the persistent unit.
All the "examples" I seen always use a static xml which is never what you need in the real
world.
Map properties = new HashMap();
properties.put(TopLinkProperties.JDBC_URL, dbProps.getString("abc.jdbcurl") );
properties.put(TopLinkProperties.JDBC_DRIVER, dbProps.getString("abc.jdbcdriver"));
properties.put(TopLinkProperties.JDBC_USER, dbProps.getString("abc.user"));
properties.put(TopLinkProperties.JDBC_PASSWORD, dbProps.getString("abc.password"));
EntityManagerFactory emf = Persistence.createEntityManagerFactory("abcPU", properties);
entityManager = emf.createEntityManager();
HTH Altimes. -
Change Form Size during runtime
Could someone tell me how to change the size of my VI form during runtime?
I want the ability to click a button and have the height increase by 50 points or so, then go back to the original value after I click the button again.
Thanks for the help!
Angus Cattle from Pool Ranch and Steel Repairs via Joe's Welding.Ok, that got me on the right track.
For some reason, though, my VI still does not change whenever I click the button.
I have attached my VI, saved in 8.2 format.
Does anyone see why my form doesn't grow by "98" whenever I click the "More >>" button?
Angus Cattle from Pool Ranch and Steel Repairs via Joe's Welding.
Attachments:
Event Notifications.vi 44 KB
Maybe you are looking for
-
Hi everyone, I'm using Indesign 5.5 for Windows and have inherited a technical document with no styling applied (not even text threads or auto-pagination), but all the fonts are in the correct sizes and colours. So it looks ok in print, but trying to
-
Encore CS3 submenus not looping - in regular DVD player?
Hi all, I have a SD PAL project, 1 main movie, 1 main menu and 2 submenus. The total data is around 4,1 GB. My submenus have a video background which lasts for 45 seconds. I have set up the submenus play over again by setting the "end action" back to
-
Does photoshop cs3 work on lion
trying to decide whether to upgrade... does anyone know how photoshop cs3 works on lion? I really need the other cloud compatability to sync all my devices easily but would hat to lose my photoshop as I havent yet spent the money to move to cs5... t
-
Specs for my emac specify support for 1GB of ram. In searching for additional ram (I presently have 512MB) I have found some suppliers that claim you can install 2GB (1GB in each of the two slots). I called and they said they have tested this and it
-
NB100 internal microphone not working
Hi I did a fresh XP SP3 install on my NB100. I did not do it from the Toshiba recovery disc as my NB100 would not write that Toshiba disc creator that came with it to my external DVDR/CDR even though it works fine with Veritas. So I downloaded all th