✎
编程开发网
首页
C语言
C++
面试
Linux
函数
Windows
数据库
下载
搜索
当前位置:
首页
->
AI编程基础
->
JAVA
java文本编辑器v2.0 图形用户界面(二)
2014-11-23 21:43:50
·
作者:
·
浏览:
25
标签:
java
文本
编辑器
v2.0
图形
用户界面
((String)combox_size.getSelectedItem()); Font font = ta.getFont(); //获得文本区的当前字体对象 int style = font.getStyle(); //获得字形 ta.setFont(new Font(fontname, style, size)); } }); ////////////////////字号加减按钮 button_larger=new JButton("A+"); toolbar.add(button_larger); button_larger.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String fontname = (String)combox_name.getSelectedItem();//获得字体名 Font font = ta.getFont(); //获得文本区的当前字体对象 int style = font.getStyle(); //获得字形 int size = font.getSize()+5; ta.setFont(new Font(fontname, style, size)); } }); button_smaller=new JButton("A-"); toolbar.add(button_smaller); button_smaller.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String fontname = (String)combox_name.getSelectedItem();//获得字体名 Font font = ta.getFont(); //获得文本区的当前字体对象 int style = font.getStyle(); //获得字形 int size = font.getSize()-5; ta.setFont(new Font(fontname, style, size)); } }); /////////////////J /////////////////粗体和斜体 checkb_bold = new JCheckBox("粗体"); //字形复选框 toolbar.add(checkb_bold); checkb_bold.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String fontname = (String)combox_name.getSelectedItem();//获得字体名 Font font = ta.getFont(); //获得文本区的当前字体对象 int style = font.getStyle(); //获得字形 int size = font.getSize(); style = style ^ 1; ta.setFont(new Font(fontname, style, size)); } }); checkb_italic = new JCheckBox("斜体"); toolbar.add(checkb_italic); checkb_italic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String fontname = (String)combox_name.getSelectedItem();//获得字体名 Font font = ta.getFont(); //获得文本区的当前字体对象 int style = font.getStyle(); //获得字形 int size = font.getSize(); style = style ^ 2; ta.setFont(new Font(fontname, style, size)); } }); //////////////// JRadioButton radiob_color[]; String colorstr[]={"红","绿","蓝"}; ButtonGroup bgroup_color = new ButtonGroup(); //按钮组 radiob_color = new JRadioButton[colorstr.length]; //颜色单选按钮数组 for (int i=0; i
首页
上一页
1
2
下一页
尾页
2
/2/2