?? frame1.java
字號:
package ex09_07;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame { JPanel contentPane; JLabel jLabel1 = new JLabel(); ButtonGroup buttonGroup1 = new ButtonGroup(); JRadioButton jRadioButton1 = new JRadioButton(); JRadioButton jRadioButton2 = new JRadioButton(); JRadioButton jRadioButton3 = new JRadioButton(); /**Construct the frame*/ public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); jLabel1.setText("改變文字大小"); jLabel1.setBounds(new Rectangle(21, 17, 156, 27)); contentPane.setLayout(null); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); jRadioButton1.setFont(new java.awt.Font("Dialog", 0, 14)); jRadioButton1.setText("18"); jRadioButton1.setBounds(new Rectangle(41, 48, 103, 27)); jRadioButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jRadioButton1_actionPerformed(e); } }); jRadioButton2.setFont(new java.awt.Font("Dialog", 0, 14)); jRadioButton2.setText("16"); jRadioButton2.setBounds(new Rectangle(41, 77, 103, 27)); jRadioButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jRadioButton2_actionPerformed(e); } }); jRadioButton3.setFont(new java.awt.Font("Dialog", 0, 14)); jRadioButton3.setText("12"); jRadioButton3.setBounds(new Rectangle(41, 105, 103, 27)); jRadioButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jRadioButton3_actionPerformed(e); } }); contentPane.add(jLabel1, null); contentPane.add(jRadioButton1, null); contentPane.add(jRadioButton2, null); contentPane.add(jRadioButton3, null); buttonGroup1.add(jRadioButton1); buttonGroup1.add(jRadioButton2); buttonGroup1.add(jRadioButton3); } /**Overridden so we can exit when window is closed*/ protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jRadioButton1_actionPerformed(ActionEvent e) {//設置字體大小為18jLabel1.setFont(new Font("Dialog",0,18)); } void jRadioButton2_actionPerformed(ActionEvent e) {//設置字體大小為16jLabel1.setFont(new Font("Dialog",0,16)); } void jRadioButton3_actionPerformed(ActionEvent e) {//設置字體大小為12jLabel1.setFont(new Font("Dialog",0,12)); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -