标签可以指定图标,请问怎么加图标进来呢?谢谢
我的代码如下,没有成功...
//package net.chelson.chapter10;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
import javax.swing.*;//文本区测试
public class JTextAreaTest extends JFrame{
public JTextAreaTest() {
JTextArea textArea = new JTextArea(5, 10);
textArea.setLineWrap(true);//超出宽度自动换行
//JScrollPane scrollPane = new JScrollPane(textArea);
//getContentPane().add(textArea);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(new Dimension(400, 300));
setTitle("文本区测试");
//ImageIcon icon = new ImageIcon("1.jpeg");
JLabel label = new JLabel(new ImageIcon("aaaa.JPG"), JLabel.CENTER);
//label.setEnabled(true);
setContentPane(label);
}
public static void main(String[] args) {
JTextAreaTest test = new JTextAreaTest();
test.setVisible(true);
}
}
我的代码如下,没有成功...
//package net.chelson.chapter10;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
import javax.swing.*;//文本区测试
public class JTextAreaTest extends JFrame{
public JTextAreaTest() {
JTextArea textArea = new JTextArea(5, 10);
textArea.setLineWrap(true);//超出宽度自动换行
//JScrollPane scrollPane = new JScrollPane(textArea);
//getContentPane().add(textArea);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(new Dimension(400, 300));
setTitle("文本区测试");
//ImageIcon icon = new ImageIcon("1.jpeg");
JLabel label = new JLabel(new ImageIcon("aaaa.JPG"), JLabel.CENTER);
//label.setEnabled(true);
setContentPane(label);
}
public static void main(String[] args) {
JTextAreaTest test = new JTextAreaTest();
test.setVisible(true);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货