⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orientationexample1.java

📁 一个用java开发界面的程序集(jfc核心编程)
💻 JAVA
字号:
package JFCBook.Chapter3.jdk12;

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

public class OrientationExample1 extends JPanel {
	public OrientationExample1() {
		setLayout(new BorderLayout());
		JPanel buttonPanel = new JPanel();
		add(buttonPanel, BorderLayout.CENTER);

		buttonPanel.setLayout(new GridLayout(2, 1, 4, 4));
		
		ok = new JButton("OK", new ImageIcon(getClass().getResource(
										"images/ok_inactive.gif")));
		cancel = new JButton("Cancel", new ImageIcon(getClass().getResource(
										"images/cancel_inactive.gif")));

		ok.setFont(new Font("Dialog", Font.BOLD, 14));
		cancel.setFont(new Font("Dialog", Font.BOLD, 14));
		
		Icon okIcon = new ImageIcon(getClass().getResource(
												"images/ok.gif"));
		Icon cancelIcon = new ImageIcon(getClass().getResource(
												"images/cancel.gif"));
		
		ok.setPressedIcon(okIcon);
		ok.setRolloverIcon(okIcon);
		cancel.setPressedIcon(cancelIcon);
		cancel.setRolloverIcon(cancelIcon);

		buttonPanel.add(ok);
		buttonPanel.add(cancel);   
	}

	public static void main(String[] args) {
		if (args.length != 1) {
			System.out.println("Please supply a locale");
			System.exit(1);
		}

		String lang;
		String country;
		try {
			int index = args[0].indexOf("_");
			if  (index != -1) {
				lang = args[0].substring(0, index);
				country = args[0].substring(index + 1);
			} else {
				lang = args[0];
				country = "";
			}
			Locale locale = new Locale(lang, country);
			System.out.println("Country: " + locale.getDisplayCountry() +
								", language: " + locale.getDisplayLanguage());

			JFrame f = new JFrame("Orientation #1");
			f.getContentPane().add(new OrientationExample1());

			// Get the resource bundle for the selected locale
			// and apply the orientation to the frame.
			ResourceBundle rb = ResourceBundle.getBundle(
					"java.text.resources.LocaleElements", locale);
			f.applyResourceBundle(rb);
			
			f.pack();
			f.setVisible(true);
			f.addWindowListener(new WindowAdapter() {
				public void windowClosing(WindowEvent e) {
					System.exit(0);
				}
			});
		} catch (Exception e) {
			System.out.println("Invalid locale: " + args[0]);
		}
	}

	JButton ok;
	JButton cancel;
	JButton switchButton;
	boolean isLTR = true;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -