package mytestmain;
import javaawtEventQueue;
import javaawteventActionEvent;
import javaawteventActionListener;
import javaxswingJButton;
import javaxswingJFrame;
import javaxswingJPanel;
import javaxswingborderEmptyBorder;
public class TestFrame extends JFrame {
private JPanel contentPane;
/
Launch the application
/
public static void main(String[] args) {
EventQueueinvokeLater(new Runnable() {
public void run() {
try {
TestFrame frame = new TestFrame();
framesetVisible(true);
} catch (Exception e) {
eprintStackTrace();
}
}
});
}
/
Create the frame
/
public TestFrame() {
setTitle("带标题的窗体");
setDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPanesetBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPanesetLayout(null);
final JButton btnNewButton = new JButton("请点击我");
btnNewButtonsetBounds(172, 114, 120, 23);
btnNewButtonaddActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ("请点击我"equals(btnNewButtongetText()))
btnNewButtonsetText("已经被点击");
else
btnNewButtonsetText("请点击我");
}
});
contentPaneadd(btnNewButton);
}
}
以上就是关于java程序怎样在点击按钮后在当前窗体的布局中d出一个新窗体全部的内容,包括:java程序怎样在点击按钮后在当前窗体的布局中d出一个新窗体、关于窗体的java程序设计怎么设计、java 一个简单的窗体程序(看我哪里错了)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)