private void addLocaleLevelField(String locale) { cTraduction.gridy++; JTextField jtfFederationNiveauLocalise = new JTextField(40); gbcTraduction.addComponentIntoGrid(jtfFederationNiveauLocalise, cTraduction); JLabel label = new JLabel(locale); label.setOpaque(true); label.setBackground(Color.WHITE); gbcTraduction.addComponentIntoGrid(label, cTraduction); mTraduction.put(locale, jtfFederationNiveauLocalise); }
private void init() { JPanel jpPrincipal = new JPanel(); JPanel jpAction = new JPanel(); GridbagComposer gbComposer = new GridbagComposer(); GridBagConstraints c = new GridBagConstraints(); GlossPainter gloss = new GlossPainter(); jxhFederation.setBackground(new Color(200, 200, 255)); jxhFederation.setBackgroundPainter(gloss); jxhFederation.setTitleFont(jxhFederation.getTitleFont().deriveFont(16.0f)); jlFederationLocaleNiveau.setOpaque(true); jlFederationLocaleNiveau.setBackground(Color.WHITE); gbcTraduction.setParentPanel(jpTraduction); cTraduction.gridy = -1; cTraduction.anchor = GridBagConstraints.WEST; cTraduction.fill = GridBagConstraints.HORIZONTAL; String[] libelleLangues = Configuration.listLangue(); jcbAvailableLocale.setRenderer( new DefaultListCellRenderer() { /* (non-Javadoc) * @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) */ @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value != null) value = ((Locale) value).getDisplayLanguage((Locale) value); else value = ""; // $NON-NLS-1$ return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); for (int i = 0; i < libelleLangues.length; i++) { if (!new Locale(libelleLangues[i]).equals(new Locale(profile.getConfiguration().getLangue()))) jcbAvailableLocale.addItem(new Locale(libelleLangues[i])); } if (libelleLangues.length < 2) { jcbAvailableLocale.setEnabled(false); } jlAddLocaleInfo.setVisible(false); jbAddLocale.addActionListener(this); jbValider.addActionListener(this); jbAnnuler.addActionListener(this); gbComposer.setParentPanel(jpPrincipal); c.gridy = 0; c.anchor = GridBagConstraints.WEST; gbComposer.addComponentIntoGrid(jlFederationSigle, c); c.gridwidth = 2; gbComposer.addComponentIntoGrid(jtfFederatonSigle, c); c.gridy++; c.gridwidth = 1; gbComposer.addComponentIntoGrid(jlFederationName, c); c.gridwidth = 2; gbComposer.addComponentIntoGrid(jtfFederatonName, c); c.gridy++; c.gridwidth = 1; gbComposer.addComponentIntoGrid(jlCountry, c); c.gridwidth = 2; gbComposer.addComponentIntoGrid(ccbCountryFederation, c); c.gridy++; c.gridwidth = 1; gbComposer.addComponentIntoGrid(jlFederationNiveau, c); c.gridwidth = 2; gbComposer.addComponentIntoGrid(jtfFederationNiveau, c); c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; gbComposer.addComponentIntoGrid(jlFederationLocaleNiveau, c); c.gridy++; c.gridx = 1; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gbComposer.addComponentIntoGrid(jlFederationNiveauInfo, c); c.gridy++; gbComposer.addComponentIntoGrid(jpTraduction, c); c.gridy++; gbComposer.addComponentIntoGrid(jlAddLocaleInfo, c); c.gridy++; c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; gbComposer.addComponentIntoGrid(jlAddLocale, c); gbComposer.addComponentIntoGrid(jcbAvailableLocale, c); gbComposer.addComponentIntoGrid(jbAddLocale, c); jpAction.setLayout(new FlowLayout(FlowLayout.RIGHT)); jpAction.add(jbValider); jpAction.add(jbAnnuler); getContentPane().setLayout(new BorderLayout()); getContentPane().add(jxhFederation, BorderLayout.NORTH); getContentPane().add(jpPrincipal, BorderLayout.CENTER); getContentPane().add(jpAction, BorderLayout.SOUTH); }