📄 wordtextframe.java
字号:
else if(e.getSource()==jmi15)
{
try
{
Runtime.getRuntime().exec("cmd /c start http://yuzhixun2008.51.com");
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
else if(e.getSource()==jmi17)
{
jta.copy();
}
else if(e.getSource()==jmi18)
{
jta.paste();
}
else if(e.getSource()==jmi19)
{
jta.cut();
}
else if(e.getSource()==jmi20)
{
}
else if(e.getSource()==jmi21)
{
music = null;
int ijp = 0;
try
{
music = new AudioStream(new FileInputStream("60531.wav"));
AudioPlayer.player.start(music);
ijp = JOptionPane.showConfirmDialog(null,"你确认要清空所有内容???","确认",
JOptionPane.WARNING_MESSAGE,JOptionPane.YES_NO_CANCEL_OPTION);
AudioPlayer.player.stop(music);
music.close();
}
catch (Exception exa)
{
exa.printStackTrace();
}
if(ijp == JOptionPane.YES_OPTION)
jta.setText("");
}
else if(e.getSource()==but_n)
{
}
else if(e.getSource()==but_o)
{
dakai();
}
else if(e.getSource()==but_s)
{
baocun();
}
else if(e.getSource()==but_c)
{
jta.copy();
}
else if(e.getSource()==but_x)
{
jta.cut();
}
else if(e.getSource()==but_p)
{
jta.paste();
}
else if(e.getSource()==but_cu)
{
if(zi_bc==0)
{
fons = jta.getFont();
}
if(zi_c==0)
{
Font fon = fons.deriveFont(Font.BOLD);
jta.setFont(fon);zi_c = 1;zi_bc=1;
}
else
{
jta.setFont(fons);zi_c = 0;zi_bc=0;
}
}
else if(e.getSource()==but_xie)
{
if(zi_bx==0)
{fons = jta.getFont();}
if(zi_x==0)
{Font fon = fons.deriveFont(Font.ITALIC);
jta.setFont(fon);zi_x=1;zi_bx=1;}
else
{jta.setFont(fons);zi_x=0;zi_bx=0;}
}
else if(e.getSource()==but_xhx)
{
jta.setText("<html><u>"+jta.getText()+"</u></html>");
}
}
public void itemStateChanged(ItemEvent e)
{
str01 = cho01.getItem(cho01.getSelectedIndex());
str02 = cho02.getItem(cho02.getSelectedIndex());
if(cho03.getItem(cho03.getSelectedIndex()).equals("正体"))
{
Font f = new Font(str01,Font.PLAIN,Integer.parseInt(str02));
jta.setFont(f);
}
else if(cho03.getItem(cho03.getSelectedIndex()).equals("粗体"))
{
Font f = new Font(str01,Font.BOLD,Integer.parseInt(str02));
jta.setFont(f);
}
else if(cho03.getItem(cho03.getSelectedIndex()).equals("斜体"))
{
Font f = new Font(str01,Font.ITALIC,Integer.parseInt(str02));
jta.setFont(f);
}
else if(cho03.getItem(cho03.getSelectedIndex()).equals("粗体加斜体"))
{
Font f = new Font(str01,Font.BOLD+Font.ITALIC,Integer.parseInt(str02));
jta.setFont(f);
}
else if(cho03.getItem(cho03.getSelectedIndex()).equals("正体加粗体"))
{
Font f = new Font(str01,Font.PLAIN+Font.BOLD,Integer.parseInt(str02));
jta.setFont(f);
}
else
{
Font f = new Font(str01,Font.PLAIN+Font.ITALIC,Integer.parseInt(str02));
jta.setFont(f);
}
if(cho04.getItem(cho04.getSelectedIndex()).equals("黑色"))
{
jta.setForeground(Color.BLACK);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("白色"))
{
jta.setForeground(Color.WHITE);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("红色"))
{
jta.setForeground(Color.RED);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("绿色"))
{
jta.setForeground(Color.GREEN);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("黄色"))
{
jta.setForeground(Color.YELLOW);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("蓝色"))
{
jta.setForeground(Color.BLUE);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("青色"))
{
jta.setForeground(Color.CYAN);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("深灰色"))
{
jta.setForeground(Color.DARK_GRAY);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("浅灰色"))
{
jta.setForeground(Color.LIGHT_GRAY);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("洋红色"))
{
jta.setForeground(Color.MAGENTA);
}
else if(cho04.getItem(cho04.getSelectedIndex()).equals("桔黄色"))
{
jta.setForeground(Color.ORANGE);
}
else //if(cho04.getItem(cho04.getSelectedIndex()).equals("粉红色"))
{
jta.setForeground(Color.PINK);
}
}
public void mouseClicked(MouseEvent e) {
// TODO: Add your code here
}
public void mousePressed(MouseEvent e) {
// TODO: Add your code here
if(e.isPopupTrigger())
jpm.show(e.getComponent(),e.getX(),e.getY());
}
public void mouseReleased(MouseEvent e) {
// TODO: Add your code here
if(e.isPopupTrigger())
jpm.show(e.getComponent(),e.getX(),e.getY());
}
public void mouseEntered(MouseEvent e) {
// TODO: Add your code here
}
public void mouseExited(MouseEvent e) {
// TODO: Add your code here
}
private void dakai()
{
jfc = new JFileChooser();
int se = jfc.showOpenDialog(this);
if(se==JFileChooser.APPROVE_OPTION)
{
try
{
file01=jfc.getSelectedFile();
FileReader fr = new FileReader(file01);
BufferedReader rd = new BufferedReader(fr);
String s = null;
Byte []buf = new Byte[64];
String open = null;
while((s=rd.readLine())!=null)
{
jta.append(s+"\n");
}
}
catch(IOException exx)
{
exx.printStackTrace();
}
}
}
private void baocun()
{
jfc = new JFileChooser();
int se = jfc.showSaveDialog(this);
if(se==JFileChooser.APPROVE_OPTION)
{
try
{
String sr_s = jfc.getSelectedFile().getAbsolutePath();
FileOutputStream fos = new FileOutputStream(new File(sr_s));
OutputStreamWriter osw = new OutputStreamWriter(fos);
String saveString=jta.getText().replaceAll("\n","\r\n");
osw.write(saveString);
osw.flush();
osw.close();
}
catch(IOException es)
{
es.printStackTrace();
}
}
}
public void chuan()
{
if(k==1)
{
try
{
AudioPlayer.player.start(music_bei);
music_bei.close();
}
catch (Exception exa){}
}
if(bei_boo==true)
{
try
{
music_bei = new AudioStream(new FileInputStream("bg.mid"));
AudioPlayer.player.start(music_bei);
music_bei.close();
}
catch (Exception exa)
{
exa.printStackTrace();
}
}
else
{
AudioPlayer.player.stop(music_bei);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -