我是 JTextArea 和 JScrollPane 的新手,每当我编译时都会收到此错误,Project3.java:95: cannot find symbol symbol : class Dimension location: class Project3 scroll.setPreferredSize(new Dimension(200, 400));
有人可以帮帮我吗?
JTextArea listBox = new JTextArea(input);
JScrollPane scroll = new JScrollPane(listBox);
listBox.setLineWrap(true);
listBox.setWrapStyleWord(true);
scroll.setPreferredSize(new Dimension(200, 400));
JOptionPane.showMessageDialog(null, scroll, "Dictionary enteries" JOptionPane.PLAIN_MESSAGE);
return aLineFromFile;
这是完整的方法。
public static String listDictionary()throws IOException
{
String input = "";
BufferedReader br = new BufferedReader(new FileReader("dictionary.txt"));
String aLineFromFile = null;
while((aLineFromFile = br.readLine()) != null)
{
input += aLineFromFile + "\n";
}
br.close();
JTextArea listBox = new JTextArea(input);
JScrollPane scroll = new JScrollPane(listBox);
listBox.setLineWrap(true);
listBox.setWrapStyleWord(true);
scroll.setPreferredSize(new Dimension(200, 400));
JOptionPane.showMessageDialog(null, scroll, "Dictionary enteries", JOptionPane.PLAIN_MESSAGE);
return aLineFromFile;
}
我已经导入,导入java.io。; 导入 javax.swing。; 导入 java.util.*;