473,550 Members | 2,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change language of menu

19 New Member
Hi! I'm trying to let the end-user select the language of the menues I'm showing him.
To do that I've got this Selector class that shows the end user a combo box, a label and a button. In the combo box the user selects the language (English,Spanis h,French,..) and when he clicks in the button shows the label in the language selected.
This works fine but it's just one form, I need to change the language of all the menues in an application, so now I've got the Menus class which shows some items one of them is FILE, when you select FILE, then CONFIGURATION you are in the Selector class.
Now I need to change the items in the menu class when you change the language in the Selector. Do I have to declare all the Menus items in the Selector class to do that?
Any help will be appreciated


Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.util.*;
  5.  
  6. public class Selector extends javax.swing.JFrame
  7. {
  8. //private ResourceBundle resources;
  9. private javax.swing.JLabel jEtSaludo;
  10. private javax.swing.JButton jBtSaludo;
  11. private javax.swing.JComboBox langList;
  12. private javax.swing.JButton jbtAceptar;
  13. private javax.swing.JLabel jlbGradosC;
  14. public javax.swing.JMenu jmnuArchivo;  
  15.  
  16.   public Selector()      // constructor
  17.   { //loadResources();
  18.     setSize(300, 200);      // tamaño del formulario
  19.     setTitle("Language Selector"); // título del formulario
  20.     initComponents();       // iniciar controles o componentes
  21.   }
  22.  
  23.  
  24.     private void initComponents()//GEN-BEGIN:initComponents
  25.   {
  26.  
  27.    getContentPane().setLayout(null);
  28.       addWindowListener(new java.awt.event.WindowAdapter()
  29.         {
  30.           public void windowClosing(java.awt.event.WindowEvent evt)
  31.             {
  32.           exitForm(evt);
  33.             }
  34.         });
  35.  
  36.  
  37.      jlbGradosC = new javax.swing.JLabel();
  38.      jlbGradosC.setText("TestLabel");
  39.      getContentPane().add(jlbGradosC);
  40.      jlbGradosC.setBounds(12,28,116,16);
  41.  
  42.      String[] langStrings = { "Español", "French", "Dutch", "Catalan", "Ingles" };
  43.  
  44.    langList = new JComboBox(langStrings);
  45.    langList.setSelectedIndex(4);
  46.    getContentPane().add(langList);
  47.     langList.setBounds(42,90,204,30);
  48.  
  49.     jbtAceptar= new javax.swing.JButton();
  50.     jbtAceptar.setText("Aceptar");
  51.     getContentPane().add(jbtAceptar);
  52.     jbtAceptar.setBounds(195,20,85,26);
  53.    jbtAceptar.addActionListener(new java.awt.event.ActionListener()
  54.     {
  55.       public void actionPerformed(java.awt.event.ActionEvent evt)
  56.       {
  57.         jbtAceptarActionPerformed(evt);
  58.       }
  59.     });
  60.  
  61.   }//GEN-END:initComponents
  62.  
  63.  
  64. private void jbtAceptarActionPerformed(java.awt.event.ActionEvent evt)
  65.  {
  66.  
  67.   Object nombre;
  68.   nombre = langList.getSelectedItem();
  69.  
  70.         System.out.println("Language--> " + nombre);
  71.         if(nombre.equals("Ingles")){
  72.             Locale localizacion = Locale.US;  //en inglés
  73.             ResourceBundle mensajes = ResourceBundle.getBundle("Datos",localizacion);      
  74.             jlbGradosC.setText(mensajes.getString("Etiquetaprueba"));
  75.  
  76.  
  77. }
  78.  
  79. else if(nombre.equals("Español")){
  80.             Locale localizacion2;
  81.            localizacion2 = new Locale("es", "ES");
  82.             ResourceBundle mensajes = ResourceBundle.getBundle("Datos",localizacion2);      
  83.            jlbGradosC.setText(mensajes.getString("Etiquetaprueba"));
  84.  
  85.  
  86.  }
  87.  
  88. else if(nombre.equals("Catalan")){
  89.             Locale localizacion3;
  90.            localizacion3 = new Locale("ca", "ES");
  91.             ResourceBundle mensajes = ResourceBundle.getBundle("Datos",localizacion3);      
  92.            jlbGradosC.setText(mensajes.getString("Etiquetaprueba"));
  93.  
  94.  
  95.                  }
  96.  
  97.  
  98.  
  99. }  
  100.  
  101.  
  102.   /** Exit the Application */
  103.   private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
  104.     System.exit (0);
  105.   }//GEN-LAST:event_exitForm
  106.  
  107.  
  108.  
  109.  
  110.  
  111.   public static void main (String args[])
  112.   {
  113.     new Selector().setVisible(true);
  114.   }
  115.  
  116.  
  117. }

Expand|Select|Wrap|Line Numbers
  1. import java.awt.event.*; 
  2. import java.util.ResourceBundle; 
  3.  
  4.  
  5. public class Menus extends javax.swing.JFrame 
  6. //ResourceBundle res = ResourceBundle.getBundle("Resources"); 
  7.  
  8.  
  9. public Menus() 
  10. setSize(500, 300); 
  11. //String title = res.getString("TITLE"); 
  12. this.setTitle("APPLICATION TITLE"); 
  13. initComponents(); 
  14.  
  15.  
  16. private void initComponents() 
  17. jmbarBarraDeMenus = new javax.swing.JMenuBar(); 
  18.  
  19. jmnuArchivo = new javax.swing.JMenu(); 
  20. String fi = res.getString("FILE"); 
  21. jmnuArchivo.setText("FILE"); 
  22. //jmbarBarraDeMenus.add(jmnuArchivo); 
  23.  
  24.  
  25. jmnuHelp = new javax.swing.JMenu(); 
  26. //String hel = res.getString("HELP"); 
  27. jmnuHelp.setText("HELP"); 
  28. jmbarBarraDeMenus.add(jmnuHelp);
  29.  
  30. jmnuLang = new javax.swing.JMenu(); 
  31. //String lang = res.getString("LANGUAGE"); 
  32. jmnuLang.setText("ABOUT"); 
  33. jmbarBarraDeMenus.add(jmnuLang);
  34.  
  35.  
  36.  
  37. jmnuAbrir = new javax.swing.JMenuItem(); 
  38. //String op = res.getString("OPEN"); 
  39. jmnuAbrir.setText("OPEN"); 
  40.  
  41.  
  42. jmnuArchivo.add(jmnuAbrir); 
  43.  
  44.  
  45. jmnuConfigura = new javax.swing.JMenuItem(); 
  46. //String co = res.getString("CONFIGURATION"); 
  47. jmnuConfigura.setText("CONFIGURATION"); 
  48. jmnuArchivo.add(jmnuConfigura); 
  49. jmnuConfigura.addActionListener(new ActionListener() { 
  50. public void actionPerformed(ActionEvent e) { 
  51. jMenuConf_actionPerformed(e); 
  52. }); 
  53.  
  54.  
  55.  
  56. getContentPane().setLayout(null); 
  57. addWindowListener(new java.awt.event.WindowAdapter() 
  58. public void windowClosing(java.awt.event.WindowEvent evt) 
  59. exitForm(evt); 
  60. }); 
  61. setJMenuBar(jmbarBarraDeMenus); 
  62. }//GEN-END:initComponents 
  63.  
  64. /** Exit the Application */ 
  65. private void exitForm(java.awt.event.WindowEvent evt) { 
  66. System.exit (0); 
  67.  
  68.  
  69. void jMenuConf_actionPerformed(ActionEvent e) { 
  70. Selector dlg = new Selector(); 
  71. dlg.setVisible(true) ; 
  72.  
  73.  
  74. public static void main (String args[]) 
  75. new Menus().setVisible(true); 
  76.  
  77. private javax.swing.JMenuBar jmbarBarraDeMenus; 
  78. public javax.swing.JMenu jmnuArchivo; 
  79. private javax.swing.JMenu jmnuHelp; 
  80. private javax.swing.JMenu jmnuLang;
  81. private javax.swing.JMenuItem jmnuAbrir; 
  82. private javax.swing.JMenuItem jmnuConfigura; 
  83.  
Aug 20 '07 #1
9 9814
praveen2gupta
201 New Member
Hi
A i got your point is that you wants the menu and menu bar should be displayed on the basis of language selected by the user.

Since the text are fixed and we set them using a method ( jmnuLang.setTex t("ABOUT"); ). In the above case you should set the labels of the menu on the basis of selection of language you can try use if -else if statement or switch statement and then place the labels on the respective language.
Aug 21 '07 #2
JosAH
11,448 Recognized Expert MVP
Hi
A i got your point is that you wants the menu and menu bar should be displayed on the basis of language selected by the user.

Since the text are fixed and we set them using a method ( jmnuLang.setTex t("ABOUT"); ). In the above case you should set the labels of the menu on the basis of selection of language you can try use if -else if statement or switch statement and then place the labels on the respective language.
No, that's not the way to go: as soon as another language needs to be supported
the if statements or switch statements in all the 'localizable' components need
to be changed and augmented.

Better turn those components to observers (or listeners) and as soon as a language
changes the observers must be notified (the Localizer object should therefor be
an observable).

The observers pass the I18N key to the Localizer and receive their new localized
text. A bit of bookkeeping takes care of the rest.

kind regards,

Jos
Aug 21 '07 #3
aleplgr
19 New Member
Yes, now I have the listener which is the Selector class I post here.
It works fine but there's a problem I can't solve:
I have a Menus class which is only a menu with 3 items: File,Help and Descriptive. when you select the File item there is the Configuration item where there is a combo box to select the language, when you select a language and click the button it changes the language of the File,Help and Descriptive items, that works fine.
But now in the Descriptive item there's the Test item where when you click it I'm trying to display another panel (the last one I post here) with 2 labels and a button that I need to also change when you select a language in the Configuration panel but it's not working, I think that the problem is at the end of class Menus, in this method the message "hello I'm hereeeeee" is printed butthe conv panel is never created

Expand|Select|Wrap|Line Numbers
  1. private void jMenuUniva_actionPerformed(ActionEvent e)
  2.    {
  3.        System.out.println("hello I'm hereeeeee");
  4.      Conver conv = new Conver(this);
  5.       res = ResourceBundle.getBundle("Resources");
  6.       updateStrings();
  7.  
  8.    }




Expand|Select|Wrap|Line Numbers
  1. import java.awt.event.*;
  2. import java.util.*;
  3. import javax.swing.*;
  4.  
  5. public class Menus extends JFrame
  6. {
  7.    public ResourceBundle res;
  8.    private JMenuBar jmbarBarraDeMenus;
  9.    private JMenu jmnuArchivo;
  10.    private JMenu jmnuHelp;
  11.     private JMenu jmnuDescriptiva;//agregué
  12.    private JMenuItem jmnuAbrir;
  13.    private JMenuItem jmnuConfigura;
  14.     private JMenuItem jmnuUniva;//agregué
  15.  
  16.         //private javax.swing.JLabel jlbGradosC;
  17.  
  18.    public Menus()
  19.    {
  20.       Locale.setDefault(new Locale("en")); //Inglés
  21.       res = ResourceBundle.getBundle("Resources");
  22.       setSize(500, 300);
  23.       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  24.       initComponents();
  25.       updateStrings();
  26.       setVisible(true);
  27.    }
  28.  
  29.    private void initComponents()
  30.    {
  31.       jmbarBarraDeMenus = new javax.swing.JMenuBar();
  32.       jmnuArchivo = new javax.swing.JMenu();
  33.         jmnuDescriptiva = new javax.swing.JMenu();//agregué 
  34.  
  35.       jmbarBarraDeMenus.add(jmnuArchivo);
  36.  
  37.       jmnuHelp = new javax.swing.JMenu();
  38.       jmbarBarraDeMenus.add(jmnuHelp);
  39.         jmbarBarraDeMenus.add(jmnuDescriptiva);
  40.  
  41.       jmnuAbrir = new javax.swing.JMenuItem();
  42.       jmnuArchivo.add(jmnuAbrir);
  43.       jmnuConfigura = new javax.swing.JMenuItem();
  44.       jmnuArchivo.add(jmnuConfigura);
  45.  
  46.         jmnuUniva = new javax.swing.JMenuItem();//agregue    
  47.       jmnuDescriptiva.add(jmnuUniva);//agregué
  48.  
  49.  
  50.         // jlbGradosC = new javax.swing.JLabel();
  51.  
  52.  
  53.       jmnuConfigura.addActionListener(
  54.          new ActionListener()
  55.          {
  56.             public void actionPerformed(ActionEvent e)
  57.             {
  58.                jMenuConf_actionPerformed(e);
  59.             }
  60.          });
  61.      jmnuUniva.addActionListener(
  62.          new ActionListener()
  63.          {
  64.             public void actionPerformed(ActionEvent e)
  65.             {
  66.                jMenuUniva_actionPerformed(e); //agregué
  67.             }
  68.          });
  69.  
  70.  
  71.  
  72.  
  73.  
  74.        getContentPane().setLayout(null);
  75.       setJMenuBar(jmbarBarraDeMenus);
  76.    }
  77.  
  78.  
  79.  
  80.  
  81.  
  82.    private void updateStrings()
  83.    {
  84.       setTitle(res.getString("TITLE"));
  85.       jmnuArchivo.setText(res.getString("FILE"));
  86.       jmnuHelp.setText(res.getString("HELP"));
  87.       jmnuAbrir.setText(res.getString("OPEN"));
  88.       jmnuConfigura.setText(res.getString("CONFIGURATION"));
  89.         jmnuDescriptiva.setText(res.getString("DESCRIPTIVE"));
  90.         jmnuUniva.setText(res.getString("UNIVARIANTE"));      
  91.    }
  92.  
  93.    private void jMenuConf_actionPerformed(ActionEvent e)
  94.    {
  95.       Selector dlg = new Selector(this);
  96.       res = ResourceBundle.getBundle("Resources");
  97.       updateStrings();
  98.    }
  99.  
  100.  private void jMenuUniva_actionPerformed(ActionEvent e)//Agregué esto
  101.    {
  102.        System.out.println("hello I'm hereeeeee");
  103.      Conver conv = new Conver(this);
  104.       res = ResourceBundle.getBundle("Resources");
  105.       updateStrings();
  106.  
  107.  
  108.    }
  109.  
  110.  
  111.  
  112.    public static void main(String args[])
  113.    {
  114.       new Menus();
  115.    }
  116. }


The Selector class

public class Selector extends JDialog implements ActionListener
{
private final static String[] LANG_STRINGS = { "Spanish", "French", "Dutch", "Chinese", "English" };
private final static String[] LOCALES = { "es", "fr", "nl", "cn", "en"};
private static int lastIndex = 4;
private JComboBox langList;
private JButton OKButton;

public Selector(JFrame owner)
{
super(owner, true);
setSize(300, 200);
setTitle("Langu age Selector");
initComponents( );
setVisible(true );
}

private void initComponents( )
{
getContentPane( ).setLayout(nul l);
addWindowListen er(
new java.awt.event. WindowAdapter()
{
public void windowClosing(W indowEvent evt)
{
dispose();
}
});
langList = new JComboBox(LANG_ STRINGS);
langList.setSel ectedIndex(last Index);
langList.setBou nds(42, 50, 204, 30);
getContentPane( ).add(langList) ;
OKButton = new JButton("OK");
OKButton.setBou nds(90, 110, 100, 30);
OKButton.setAct ionCommand("sel eccionar");
OKButton.addAct ionListener(thi s);
getContentPane( ).add(OKButton) ;
}

public void actionPerformed (ActionEvent e)
{
if (e.getActionCom mand().equals(" seleccionar"))
{
lastIndex = langList.getSel ectedIndex();
Locale.setDefau lt(new Locale(LOCALES[lastIndex]));
dispose();
}
}

public static void main(String args[])
{
new Selector(null);
}
}



dfsg

import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
import java.util.*;


public class Conver extends JFrame
{
/**Crear un nuevo formulario Conver*/
public Conver(JFrame owner)
{
setSize(500,200 );//tamaño del formulario
setTitle("Conve rsion de temperaturas");//titulo del formulario
initComponents( );//iniciar componenetes
}

/** El siguiente metodo es llamado por el constructorpara iniciar el formulario**/
private void initComponents( )
{
//Crear los objetos
jlbGradosC = new javax.swing.JLa bel();
jtfGradosC = new javax.swing.JTe xtField();
jlbGradosF = new javax.swing.JLa bel();
jtfGradosF = new javax.swing.JTe xtField();
jbtAceptar = new javax.swing.JBu tton();

getContentPane( ).setLayout(nul l);
addWindowListen er(new java.awt.event. WindowAdapter()
{
public void windowClosing(j ava.awt.event.W indowEvent evt)
{
exitForm(evt);
}
}
);
//Etiqueta "Grados centigrados"
jlbGradosC.setT ext("Grados Centigrados");
getContentPane( ).add(jlbGrados C);
jlbGradosC.setB ounds(12,28,116 ,16);

//Caja de texto para los grados centigrados
jtfGradosC.setT ext("0.00");
jtfGradosC.setH orizontalAlignm ent(javax.swing .SwingConstants .RIGHT);
getContentPane( ).add(jtfGrados C);
jtfGradosC.setB ounds(132,28,14 4,20);

//Etiqueta "Grados Fahrenheit"
jlbGradosF.setT ext("Grados fahrenheit");
getContentPane( ).add(jlbGrados F);
jlbGradosF.setB ounds(12,68,104 ,24);

//Caja de texto para los grados fahreneit
jtfGradosF.setT ext("32.00");
jtfGradosF.setH orizontalAlignm ent(javax.swing .SwingConstants .RIGHT);
getContentPane( ).add(jtfGrados F);
jtfGradosF.setB ounds(132,72,14 4,20);

//Boton Aceptar
jbtAceptar.setT ext("Aceptar");
jbtAceptar.setM nemonic('A');
getRootPane().s etDefaultButton (jbtAceptar);
getContentPane( ).add(jbtAcepta r);
jbtAceptar.setB ounds(132,120,1 44,24);


java.awt.event. KeyAdapter kl=
new java.awt.event. KeyAdapter()
{
public void keyTyped(java.a wt.event.KeyEve nt evt)
{
// jtfGradosKeyTyp ed(evt);
}
};
jtfGradosC.addK eyListener(kl);
jtfGradosF.addK eyListener(kl);


}


/**Salir de la aplicacion*/
private void exitForm(java.a wt.event.Window Event evt)
{
System.exit(0);
}

/**
*parametro args: argumentos en linea de ordenes
*/
public static void main(String args[])
{
try
{
//Aspecto de la interfaz grafica
javax.swing.UIM anager.setLookA ndFeel(
javax.swing.UIM anager.getSyste mLookAndFeelCla ssName());
}
catch (Exception e)
{
System.out.prin tln("No se pudo establecer el aspecto deseado: " + e);
}
new Conver(null).se tVisible(true);
}


private javax.swing.JLa bel jlbGradosC;
private javax.swing.JTe xtField jtfGradosC;
private javax.swing.JBu tton jbtAceptar;
private javax.swing.JLa bel jlbGradosF;
private javax.swing.JTe xtField jtfGradosF;
}
Aug 28 '07 #4
JosAH
11,448 Recognized Expert MVP
The way you're trying to accomplish this is not the 'Swing way' of doing things.
Swing uses 'bound properties', i.e. when such a property changes it notifies
everything that is interested in the property value change.

Central in you localization framework should be a 'Localizer' that can localize
strings and add listeners to itself when a Locale changes (i.e. the language of
the application is changed).

Any component that is interested in a Locale change should register itself to
that Localizer. The trouble with Swing components is that they don't exist during
the lifetime of the application (think of buttons in a dialog or the dialog itself).

Therefore, a simple solution would be a, say 'LocalizerDeleg ate' that registers
itself at the Localizer and changes the text for a Swing component whenever a
Locale changes. The Swing component refers to such a LocalizerDelega te.

If the Localizer itself keeps those interested LocalizerDelega tes in a WeakHashMap,
they will be automatically removed from that map whenever the Swing component
becomes out of scope and is a (potential) prey for the Garbage Collector.

A LocalizerHelper should know about *what* key to translate (or localize) for
the component (or part thereof) it is the delegate for. Whenever the Locale
changes, it is notified by the Localizer, the LocalizerDelega te consults the
Localizer again and sets the text in the Swing component that had delegated
that functionality.

The easiest approach is to subclass all Swing components that implement the
functionality outlined above. It seems like a lot of work (and it is) but it pays back
big times (believe me, I did just that some time ago ;-)

kind regards,

Jos
Aug 28 '07 #5
aleplgr
19 New Member
Thanks really for your time, but this looks too much for me, I'm absolutelly newbie.. is there please any example? the only one I could find is this one
http://www.demo2s.com/Code/Java/Development-Class/BigDemoforI18N. htm
and it uses the if else if approach...
Aug 28 '07 #6
JosAH
11,448 Recognized Expert MVP
Thanks really for your time, but this looks too much for me, I'm absolutelly newbie.. is there please any example? the only one I could find is this one
http://www.demo2s.com/Code/Java/Development-Class/BigDemoforI18N. htm
and it uses the if else if approach...
I'm sorry for saying so but that example sucks big times. That way is not the
way to go for I18N and L10N. Especially not if you want to change the Locale
(language) while the application is running. Don't use it. To do it properly takes
a lot more work and I don't even know if the way I did it is the 'best' way to do it.

Maybe I should write a little article series about it; I don't know yet, but most
certainly your question cannot be answered in a single reply; sorry 'bout that.

kind regards,

Jos
Aug 28 '07 #7
r035198x
13,262 MVP
Thanks really for your time, but this looks too much for me, I'm absolutelly newbie.. is there please any example? the only one I could find is this one
http://www.demo2s.com/Code/Java/Development-Class/BigDemoforI18N. htm
and it uses the if else if approach...
I don't think choosing an inferior alternative approach is the way to go here. If you're a "newbie" (I like to call it leaners because everyone is a learner) then doing this as Jos suggested will make you a learn a lot which I think is the whole point anyway.
Aug 28 '07 #8
aleplgr
19 New Member
I found a solution (I know it sucks! and it's 100000 miles away from JosAH's ) It consists of declaring the ResourceBundle variable also in the Conver panel (this is just an example panel to see how to change its labels) and in the init components method call the getBundle and the getSring in the setText of each label and button.
I think that this is working... could I try this one while find something better?




Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
  3.  
  4. public class Conver extends  JFrame
  5. {
  6. /**Crear un nuevo formulario Conver*/
  7. private  ResourceBundle res;
  8.  public Conver(JFrame owner)
  9.  { 
  10.  //super(owner, true);
  11.   setSize(500,200);//tamaño del formulario
  12.   setTitle("Conversion de temperaturas");//titulo del formulario
  13.   initComponents();//iniciar componenetes
  14.    setVisible(true);
  15.  }
  16.  
  17. /** El siguiente metodo es llamado por el constructorpara iniciar el formulario**/
  18.  private void initComponents()
  19.  {
  20.   //Crear los objetos
  21.   jlbGradosC = new javax.swing.JLabel();
  22.   jtfGradosC = new javax.swing.JTextField();
  23.   jlbGradosF = new javax.swing.JLabel();
  24.   jtfGradosF = new javax.swing.JTextField();
  25.   jbtAceptar = new javax.swing.JButton();
  26.   res = ResourceBundle.getBundle("Resources");
  27.   getContentPane().setLayout(null);
  28.   addWindowListener(new java.awt.event.WindowAdapter()
  29.    {
  30.     public void windowClosing(java.awt.event.WindowEvent evt)
  31.     {
  32.      //exitForm(evt);
  33.       dispose();
  34.    }
  35.   }
  36.   );
  37.   //Etiqueta "Grados centigrados"
  38.   jlbGradosC.setText(res.getString("GradosCentigrados"));
  39.   getContentPane().add(jlbGradosC);
  40.   jlbGradosC.setBounds(12,28,116,16);
  41.  
  42.   //Caja de texto para los grados centigrados
  43.   jtfGradosC.setText("0.00");
  44.   jtfGradosC.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
  45.   getContentPane().add(jtfGradosC);
  46.   jtfGradosC.setBounds(132,28,144,20);
  47.  
  48.   //Etiqueta "Grados Fahrenheit"
  49.   jlbGradosF.setText("Grados fahrenheit");
  50.   getContentPane().add(jlbGradosF);
  51.   jlbGradosF.setBounds(12,68,104,24);
  52.  
  53.    //Caja de texto para los grados fahreneit
  54.   jtfGradosF.setText("32.00");
  55.   jtfGradosF.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
  56.   getContentPane().add(jtfGradosF);
  57.   jtfGradosF.setBounds(132,72,144,20);
  58.  
  59.    //Boton Aceptar
  60.   jbtAceptar.setText("Aceptar");
  61.   jbtAceptar.setMnemonic('A');
  62.   getRootPane().setDefaultButton(jbtAceptar);
  63.   getContentPane().add(jbtAceptar);
  64.   jbtAceptar.setBounds(132,120,144,24);
  65.  
  66.  
  67.  java.awt.event.KeyAdapter kl=
  68.  new java.awt.event.KeyAdapter()
  69.  {
  70.  public void keyTyped(java.awt.event.KeyEvent evt)
  71.  {
  72.  // jtfGradosKeyTyped(evt);
  73.   }
  74.   };
  75.   //jtfGradosC.addKeyListener(kl);
  76.   //jtfGradosF.addKeyListener(kl); 
  77.  
  78.  
  79.  }
  80.  
  81.  
  82.  /**Salir de la aplicacion*/
  83.  private void exitForm(java.awt.event.WindowEvent evt)
  84.  {
  85.    System.exit(0);
  86.  }
  87.  
  88.  /**
  89.  *parametro args: argumentos en linea de ordenes
  90.  */
  91.  public static void main(String args[])
  92.  {
  93.    try
  94.      {
  95.       //Aspecto de la interfaz grafica
  96.       javax.swing.UIManager.setLookAndFeel(
  97.        javax.swing.UIManager.getSystemLookAndFeelClassName());
  98.     }
  99.     catch (Exception e)
  100.     {
  101.      System.out.println("No se pudo establecer el aspecto deseado: " + e);
  102.      }
  103.      new Conver(null).setVisible(true);
  104.     }
  105.  
  106.  
  107.     private javax.swing.JLabel jlbGradosC;
  108.     private javax.swing.JTextField jtfGradosC;
  109.     private javax.swing.JButton jbtAceptar;
  110.     private javax.swing.JLabel jlbGradosF;
  111.     private javax.swing.JTextField jtfGradosF;
  112.     }
  113.  
Aug 29 '07 #9
JosAH
11,448 Recognized Expert MVP
II think that this is working... could I try this one while find something better?
Sure, why not? If it works; nobody is going to forbid you to use your current solution ;-)

kind regards,

Jos
Aug 29 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

10
5979
by: Richard | last post by:
The style sheet shown below is from the suckerfish vertical menu. http://www.htmldog.com/articles/suckerfish/dropdowns/example/vertical.html I've added in a few minor changes to color code the levels. I changed the width of the first level to 8em and get an unwanted space between that and the 2nd level. I'd like their to be no gap between...
2
5286
by: RWD | last post by:
I am trying to figure out how to change the target frame in my hyperlink on a DHTML menu. The menu is in one frame and the target frame is called "main" The code is below: Thanks in advance RWD <script type='text/javascript'>
2
2961
by: Isz | last post by:
Hi Group: I would like to know if it is possible to change the name of an attribute to something else. My setup is like this: I have serveral SQL tables that I nest and join so that it all outputs into a nice XML file for the purpose of populating a flash navigation menu. <NewDataSet> <mainMenu_category menu_name="Home" menu_ID="1">...
13
4158
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture' , data type='Number' ,Display Control='Combo Box', RowSource Type = 'Value List' and Row Source = ' 0;"chair";1;"Table";2;"Bed" ' Therefore, in...
5
5044
by: Phil Schmidt | last post by:
I am making a little Tkinter GUI app that needs to be in several languages (english, french, etc.), adjustable at runtime via a menu pick to select the language. The only way I can see to change text in the menus entries is to destroy them and recreate them usiing different labels. This seems very clunky though, and there must be a better way....
4
3760
by: Hans Kesting | last post by:
Can I change the language of an existing form on the fly? Say I have two radiobuttons: "dutch" and "english". When the user selects one, the form must switch to the selected language. Is that possible and how? When I set System.Threading.Thread.CurrentThread.CurrentUICulture, any new forms will use the new language. Existing forms keep...
2
1656
by: Steve Marshall | last post by:
When I installed VS2005 on my own computer I nominated VB as the default language. I have also worked on VS2005 on another computer where C# was the default language. But sometimes I want to use C#. How do I change the IDE to work with C#? I can see a few options in the Tools/Options menu, but the result is not the same as it looked on...
3
4547
by: MLD | last post by:
PLEASE HELP! I would like to include a UL as a menu, styled by an included CSS Style Sheet. The problem I am having is how do I dynamically set the "active" page class using JavaScript to change each time I click on a new list item? I have found a bunch of examples but none that really accomplish what I need.
6
3306
by: happyse27 | last post by:
Hi All, How do I change the height of the main menu as the height is inconsistent due to some of main menu's item stretches to 2 rows while, the other main menu's items are stretched to 1 row. Code is below Cheers... Andrew
0
7560
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7758
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7998
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7844
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6098
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5401
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5126
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
800
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.