求JAVA高手帮我写一下这段记事本代码的注释
color.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){J...
color.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JColorChooser jColor = new JColorChooser(); // 调用颜色面板,设置前景就可更改字体颜色
Color fcolor = ja.getForeground();
ja.setForeground(jColor.showDialog(ja, "选择字体颜色", fcolor));
}
});
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fontMain.setVisible(false);
}
});
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fontMain.setVisible(false);
}
});
font.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fontJd.setLocationRelativeTo(NewProgram.this);
fontJd.setVisible(true);
int style = 0;
if (fontShape.getSelectedItem().equals("常规") == true) {
style = Font.PLAIN; // 将style设置为常规字形保存
}
if (fontShape.getSelectedItem().equals("斜体") == true) {
style = Font.ITALIC;
}
if (fontShape.getSelectedItem().equals("粗体") == true) {
style = Font.BOLD;
}
if (fontShape.getSelectedItem().equals("粗斜体") == true) {
style = Font.BOLD + Font.ITALIC;
}
// 设置字体大小的
String[] size = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10" };
for (int i = 0; i < size.length; i++) {
if (sizeList.getSelectedItem().equals(size[i]) == true) {
ja.setFont(new Font(String.valueOf(fontList
.getSelectedItem()), style, (10 - i) * 10));
fontJd.dispose();
}}}; 展开
public void actionPerformed(ActionEvent e) {
JColorChooser jColor = new JColorChooser(); // 调用颜色面板,设置前景就可更改字体颜色
Color fcolor = ja.getForeground();
ja.setForeground(jColor.showDialog(ja, "选择字体颜色", fcolor));
}
});
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fontMain.setVisible(false);
}
});
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fontMain.setVisible(false);
}
});
font.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fontJd.setLocationRelativeTo(NewProgram.this);
fontJd.setVisible(true);
int style = 0;
if (fontShape.getSelectedItem().equals("常规") == true) {
style = Font.PLAIN; // 将style设置为常规字形保存
}
if (fontShape.getSelectedItem().equals("斜体") == true) {
style = Font.ITALIC;
}
if (fontShape.getSelectedItem().equals("粗体") == true) {
style = Font.BOLD;
}
if (fontShape.getSelectedItem().equals("粗斜体") == true) {
style = Font.BOLD + Font.ITALIC;
}
// 设置字体大小的
String[] size = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10" };
for (int i = 0; i < size.length; i++) {
if (sizeList.getSelectedItem().equals(size[i]) == true) {
ja.setFont(new Font(String.valueOf(fontList
.getSelectedItem()), style, (10 - i) * 10));
fontJd.dispose();
}}}; 展开
1个回答
展开全部
color.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JColorChooser jColor = new JColorChooser(); // 调用颜色面板,设置前景就可更改字体颜色
Color fcolor = ja.getForeground(); //得到前景色
ja.setForeground(jColor.showDialog(ja, "选择字体颜色", fcolor)); //设置前景色
}
});
cancel.addActionListener(new ActionListener() { //为取消按钮添加临听器
public void actionPerformed(ActionEvent e) {
fontMain.setVisible(false); //当事件触发,把fontMain设为隐藏
}
});
ok.addActionListener(new ActionListener() { //为确定按钮添加临听器
public void actionPerformed(ActionEvent e) {
fontMain.setVisible(false); //当事件触发,把fontMain设为隐藏
}
});
font.addActionListener(new ActionListener() { //为font按钮添加临听器
public void actionPerformed(ActionEvent e) {
fontJd.setLocationRelativeTo(NewProgram.this); //设定fontJd的位置
fontJd.setVisible(true); //使fontJd为可见
int style = 0;
if (fontShape.getSelectedItem().equals("常规") == true) { //以下为设置字体的代码
style = Font.PLAIN; // 将style设置为常规字形保存
}
if (fontShape.getSelectedItem().equals("斜体") == true) {
style = Font.ITALIC;
}
if (fontShape.getSelectedItem().equals("粗体") == true) {
style = Font.BOLD;
}
if (fontShape.getSelectedItem().equals("粗斜体") == true) {
style = Font.BOLD + Font.ITALIC;
}
// 设置字体大小的 //字号
String[] size = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10" };
for (int i = 0; i < size.length; i++) {
if (sizeList.getSelectedItem().equals(size[i]) == true) { //设置字体字号
ja.setFont(new Font(String.valueOf(fontList
.getSelectedItem()), style, (10 - i) * 10));
fontJd.dispose();
}}};
public void actionPerformed(ActionEvent e) {
JColorChooser jColor = new JColorChooser(); // 调用颜色面板,设置前景就可更改字体颜色
Color fcolor = ja.getForeground(); //得到前景色
ja.setForeground(jColor.showDialog(ja, "选择字体颜色", fcolor)); //设置前景色
}
});
cancel.addActionListener(new ActionListener() { //为取消按钮添加临听器
public void actionPerformed(ActionEvent e) {
fontMain.setVisible(false); //当事件触发,把fontMain设为隐藏
}
});
ok.addActionListener(new ActionListener() { //为确定按钮添加临听器
public void actionPerformed(ActionEvent e) {
fontMain.setVisible(false); //当事件触发,把fontMain设为隐藏
}
});
font.addActionListener(new ActionListener() { //为font按钮添加临听器
public void actionPerformed(ActionEvent e) {
fontJd.setLocationRelativeTo(NewProgram.this); //设定fontJd的位置
fontJd.setVisible(true); //使fontJd为可见
int style = 0;
if (fontShape.getSelectedItem().equals("常规") == true) { //以下为设置字体的代码
style = Font.PLAIN; // 将style设置为常规字形保存
}
if (fontShape.getSelectedItem().equals("斜体") == true) {
style = Font.ITALIC;
}
if (fontShape.getSelectedItem().equals("粗体") == true) {
style = Font.BOLD;
}
if (fontShape.getSelectedItem().equals("粗斜体") == true) {
style = Font.BOLD + Font.ITALIC;
}
// 设置字体大小的 //字号
String[] size = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10" };
for (int i = 0; i < size.length; i++) {
if (sizeList.getSelectedItem().equals(size[i]) == true) { //设置字体字号
ja.setFont(new Font(String.valueOf(fontList
.getSelectedItem()), style, (10 - i) * 10));
fontJd.dispose();
}}};
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询