기본적으로 AWT/Swing Component에서 제공되는 기본 Component(JFileChooser, JColorChooserㆍㆍ)들의
Text는 Default Locale로 표현된다. 영어로 Component를 사용하려면 아래와 같이 Default Locale을 변경하면 되겠다.
import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Locale; import javax.swing.JButton; import javax.swing.JColorChooser; import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; class MySwing extends JFrame implements ActionListener { /** * */ private static final long serialVersionUID = -5148305495409346518L; private static final int APP_FRAME_WIDTH = 500; private static final int APP_FRAME_HEIGHT = 300; private static Dimension theScreenSize = createScreenSize(); public MySwing(String title) { super(title); setSize(APP_FRAME_WIDTH, APP_FRAME_HEIGHT); Dimension theFrameSize = getSize(); int x = (int) (theScreenSize.getWidth() - theFrameSize.getWidth()) / 2; int y = (int) (theScreenSize.getHeight() - theFrameSize.getHeight()) / 2; setLocation(x, y); JPanel panel = new JPanel(); JButton fileChooserButton = new JButton("JFileChooser"); fileChooserButton.addActionListener(this); JButton colorChooserButton = new JButton("JColorChooser"); colorChooserButton.addActionListener(this); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); panel.add(fileChooserButton); panel.add(colorChooserButton); add(panel); setVisible(true); } private static Dimension createScreenSize() { return Toolkit.getDefaultToolkit().getScreenSize(); } @Override public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); if (actionCommand.equals("JFileChooser")) { JFileChooser fileChooser = new JFileChooser(); fileChooser.showOpenDialog(this); } else if (actionCommand.equals("JColorChooser")) { JColorChooser.showDialog(this, "MySwing ColorChooser", Color.WHITE); } } } public class SwingTest { public static void main(String[] args) { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { e.printStackTrace(); } JComponent.setDefaultLocale(Locale.ENGLISH); // Locale.setDefault(Locale.ENGLISH); new MySwing("MySwing App"); } }
'JAVA Platform > JAVA' 카테고리의 다른 글
[JAVA] - Swing Progress JWindow Example (0) | 2015.08.21 |
---|---|
[JAVA] - SQL_Server JDBC 드라이버 sqljdbc.jar 와 sqljdbc4.jar 차이점 (0) | 2015.07.23 |
[JAVA] - 환경변수 목록 가져오기 (0) | 2015.04.28 |
[JAVA] - Swing Component Font 설정하기 (0) | 2015.04.11 |
[JAVA] - Swing Look And Feel 적용하기 (0) | 2015.04.01 |