idea图形界面开发插件

idea图形界面开发插件

/* * Created by JFormDesigner on Tue Dec 28 15:24:42 CST 2021 */ package cn.huanzi.qch.view; import java.awt.*; import java.awt.event.*; import javax.swing.*; / * 测试 */ public class TestFrame extends javax.swing.JFrame{ public TestFrame() { initComponents(); setVisible(true);// 显示 setLocationRelativeTo(null);// JFrame 窗口居中显示  } public static void main(String[] args) { java.awt.EventQueue.invokeLater(() -> { new TestFrame(); System.out.println("启动成功!"); }); } private void SubmitActionPerformed(ActionEvent e) { // TODO add your code here System.out.println("---------------------------"); System.out.println("姓名:"+userNameTestField.getText()); String sex = ""; if (xyRadioButton.isSelected()) { sex = "男"; } else if (xxRadioButton.isSelected()) { sex = "女"; }else if (yyRadioButton.isSelected()) { sex = "不确定"; } System.out.println("性别:"+sex); String hobby = ""; if (singCheckBox.isSelected()) { hobby += "唱、"; } if (skipCheckBox.isSelected()) { hobby += "跳、"; } if (rapCheckBox.isSelected()) { hobby += "rap、"; } System.out.println("爱好:"+hobby); System.out.println("自我评价:"+selfTextArea.getText()); } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents label1 = new JLabel(); userNameTestField = new JTextField(); label2 = new JLabel(); label3 = new JLabel(); submit = new JButton(); reset = new JButton(); xxRadioButton = new JRadioButton(); xyRadioButton = new JRadioButton(); yyRadioButton = new JRadioButton(); scrollPane1 = new JScrollPane(); selfTextArea = new JTextArea(); label4 = new JLabel(); label5 = new JLabel(); singCheckBox = new JCheckBox(); skipCheckBox = new JCheckBox(); rapCheckBox = new JCheckBox(); //======== this ========  setBackground(Color.gray); setTitle("Test GUI"); setForeground(SystemColor.windowText); setMinimumSize(new Dimension(300, 200)); setResizable(false); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); Container contentPane = getContentPane(); contentPane.setLayout(null); //---- label1 ---- label1.setText("姓名:"); contentPane.add(label1); label1.setBounds(34, 55, 65, 30); contentPane.add(userNameTestField); userNameTestField.setBounds(119, 55, 200, userNameTestField.getPreferredSize().height);  idea图形界面开发插件//---- label2 ---- label2.setText("性别:"); contentPane.add(label2); label2.setBounds(34, 95, 65, 30); //---- label3 ---- label3.setText("自我评价:"); contentPane.add(label3); label3.setBounds(34, 165, 65, 30); //---- submit ---- submit.setText("提交"); submit.addActionListener(e -> SubmitActionPerformed(e)); contentPane.add(submit); submit.setBounds(new Rectangle(new Point(64, 271), submit.getPreferredSize())); //---- reset ---- reset.setText("重置"); contentPane.add(reset); reset.setBounds(new Rectangle(new Point(219, 271), reset.getPreferredSize())); //---- xxRadioButton ---- xxRadioButton.setText("女"); contentPane.add(xxRadioButton); xxRadioButton.setBounds(new Rectangle(new Point(184, 100), xxRadioButton.getPreferredSize())); //---- xyRadioButton ---- xyRadioButton.setText("男"); contentPane.add(xyRadioButton); xyRadioButton.setBounds(new Rectangle(new Point(129, 100), xyRadioButton.getPreferredSize())); //---- yyRadioButton ---- yyRadioButton.setText("不确定"); contentPane.add(yyRadioButton); yyRadioButton.setBounds(new Rectangle(new Point(239, 100), yyRadioButton.getPreferredSize())); //======== scrollPane1 ========  { scrollPane1.setViewportView(selfTextArea); } contentPane.add(scrollPane1); scrollPane1.setBounds(117, 165, 202, 71); //---- label4 ---- label4.setText("测试表单"); label4.setFont(label4.getFont().deriveFont(22f)); contentPane.add(label4); label4.setBounds(124, 0, 100, 45); //---- label5 ---- label5.setText("爱好:"); contentPane.add(label5); label5.setBounds(34, 130, 65, 30); //---- singCheckBox ---- singCheckBox.setText("唱"); contentPane.add(singCheckBox); singCheckBox.setBounds(new Rectangle(new Point(129, 135), singCheckBox.getPreferredSize())); //---- skipCheckBox ---- skipCheckBox.setText("跳"); contentPane.add(skipCheckBox); skipCheckBox.setBounds(new Rectangle(new Point(184, 135), skipCheckBox.getPreferredSize())); //---- rapCheckBox ---- rapCheckBox.setText("rap"); contentPane.add(rapCheckBox); rapCheckBox.setBounds(239, 135, 50, rapCheckBox.getPreferredSize().height); { // compute preferred size Dimension preferredSize = new Dimension(); for(int i = 0; i < contentPane.getComponentCount(); i++) { Rectangle bounds = contentPane.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = contentPane.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; contentPane.setMinimumSize(preferredSize); contentPane.setPreferredSize(preferredSize); } setSize(400, 365); setLocationRelativeTo(null); //---- buttonGroup2 ---- ButtonGroup buttonGroup2 = new ButtonGroup(); buttonGroup2.add(xxRadioButton); buttonGroup2.add(xyRadioButton); buttonGroup2.add(yyRadioButton); // JFormDesigner - End of component initialization //GEN-END:initComponents  } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables private JLabel label1; private JTextField userNameTestField; private JLabel label2; private JLabel label3; private JButton submit; private JButton reset; private JRadioButton xxRadioButton; private JRadioButton xyRadioButton; private JRadioButton yyRadioButton; private JScrollPane scrollPane1; private JTextArea selfTextArea; private JLabel label4; private JLabel label5; private JCheckBox singCheckBox; private JCheckBox skipCheckBox; private JCheckBox rapCheckBox; // JFormDesigner - End of variables declaration //GEN-END:variables }

今天的文章
idea图形界面开发插件分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/140448.html

(0)
编程小号编程小号
上一篇 2024-08-27 09:11
下一篇 2024-08-27 09:30

相关推荐