?? fontdialog.java
字號(hào):
import java.awt.*;
import java.awt.event.*;
import javax.swing.JTextArea;
import java.awt.datatransfer.*;
import java.io.*;
import java.awt.datatransfer.*;
import javax.swing.*;
import javax.swing.border.*;
class FontDialog extends Dialog implements ActionListener
{
static final int YES=1,NO=0;
int message=1;
Button yes,no;
Image im;
FontPanel fontPanel;
Panel panel;
Button okButton;
Button cancelButton;
static int tempsize=20;
JTextArea mytext;
FontDialog(Frame f,JTextArea text)
{
super(f);
mytext=text;
this.setTitle("字體對(duì)話框");
this.setModal(true);
this.setLayout(new FlowLayout());
this.setBounds(350,280,340,230);
okButton=new Button("確定");
cancelButton=new Button("取消");
okButton.addActionListener(this);
cancelButton.addActionListener(this);
panel=new Panel(new GridLayout(1,2));
panel.add(okButton);
panel.add(cancelButton);
this.setLayout(new BorderLayout());
fontPanel=new FontPanel();
add(panel,BorderLayout.SOUTH);
add(fontPanel,BorderLayout.CENTER);
// im=Toolkit.getDefaultToolkit().createImage("d:\\help.jpg");
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
}
});
}
public void actionPerformed(ActionEvent e1)
{
String name;
int size=20;
if(e1.getSource()==okButton)
{
name=fontPanel.fontList.getSelectedItem();
Font f=new Font(name,Font.PLAIN,fontPanel.tempsize);
mytext.setFont(f);
MyFrame.font=f;
this.setVisible(false);
}
if(e1.getSource()==cancelButton)
{
mytext.setFont(MyFrame.font);
this.setVisible(false);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -