User interface 得到错误的flowLayout
可能我的流程布局有问题,这将是错误的。我怎样才能修好它?请帮帮我 该错误似乎无法解析符号类FlowLayoutUser interface 得到错误的flowLayout,user-interface,User Interface,可能我的流程布局有问题,这将是错误的。我怎样才能修好它?请帮帮我 该错误似乎无法解析符号类FlowLayout import java.io.*; import javax.swing.*; public class qwe extends JFrame { private JButton but; private JLabel lab; private JTextField tex; public qwe() { lab = n
import java.io.*;
import javax.swing.*;
public class qwe extends JFrame
{
private JButton but;
private JLabel lab;
private JTextField tex;
public qwe()
{
lab = new JLabel("I am a label");
add(lab);
tex = new JTextField(15);
add(tex);
but = new JButton("Click me!");
add(but);
}
public static void main(String args [])
{
qwe gui = new qwe();
gui.setLayout(new FlowLayout());
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setSize(200,125);
gui.setVisible(true);
}
}
您需要导入FlowLayout类
导入java.awt.FlowLayout代码>
我还有一个建议:
仔细观察编程逻辑。您必须设置qwe框架的布局,然后向其中添加其他组件 很可能在类路径中未设置FlowLayout类。@SasiKathimanda我需要做什么?是否确实要扩展JFrame??为什么不创建新的JFrame呢。