Java 为什么赢了';JFrame是否显示输出?
我已经在applet中声明了JFrame。JFrame似乎打开了(我只能看到打开、关闭和最大化按钮),但没有显示输出Java 为什么赢了';JFrame是否显示输出?,java,swing,jframe,Java,Swing,Jframe,我已经在applet中声明了JFrame。JFrame似乎打开了(我只能看到打开、关闭和最大化按钮),但没有显示输出 public class LaunchListener implements ActionListener { public void actionPerformed(ActionEvent event) { String input; int coInput; input = integer
public class LaunchListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
String input;
int coInput;
input = integerInput.getText();
coInput = Integer.parseInt(input);
JTextArea textArea = new JTextArea();
JFrame frame=new JFrame("Add JTextArea into JFrame");
if (convInput == 2)
{
String output = "Show output";
frame.add(textArea);
textArea.setText(output);
frame.setVisible(true);
你忘了方法
setBounds(x,y,width,height);
实际上,setBounds
可以分为两种方法
setSize(w,h);
setLocation(x,y);
哇,这就是问题所在。谢谢你,你的简单解释帮助我解决了这个问题。
pack
和setLocationByPlatform
可能是更好的选择