📄 main.java
字号:
package gui;import com.cloudgarden.layout.AnchorLayout;import javax.swing.DefaultComboBoxModel;import javax.swing.JButton;import javax.swing.JOptionPane;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ComboBoxModel;import javax.swing.JComboBox;import com.cloudgarden.layout.AnchorConstraint;import javax.swing.JLabel;import javax.swing.WindowConstants;/*** This code was generated using CloudGarden's Jigloo* SWT/Swing GUI Builder, which is free for non-commercial* use. If Jigloo is being used commercially (ie, by a corporation,* company or business for any purpose whatever) then you* should purchase a license for each developer using Jigloo.* Please visit www.cloudgarden.com for details.* Use of Jigloo implies acceptance of these licensing terms.* ************************************** A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED* for this machine, so Jigloo or this code cannot be used legally* for any corporate or commercial purpose.* **************************************/public class main extends javax.swing.JFrame { private JLabel jLabel1; private JLabel jLabel2; private JButton jButton2; private JButton jButton1; private JComboBox jComboBox1; private static main inst; private JsJFrame js; /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { inst = new main(); inst.setVisible(true); inst.setLocation((1024-400)/2, (768-300)/2); } public main() { super(); initGUI(); } public void setInst(main inst){ this.inst=inst; inst.setLocation((1024-400)/2, (768-300)/2); } private void initGUI() { try { AnchorLayout thisLayout = new AnchorLayout(); this.getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jButton2 = new JButton(); this.getContentPane().add( jButton2, new AnchorConstraint( 659, 684, 772, 531, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jButton2.setText("\u9000\u51fa"); jButton2.setPreferredSize(new java.awt.Dimension(60, 30)); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JOptionPane.showMessageDialog(null, "谢谢使用,再见!"); System.exit(3); } }); } { jButton1 = new JButton(); this.getContentPane().add( jButton1, new AnchorConstraint( 663, 335, 776, 182, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jButton1.setText("\u786e\u5b9a"); jButton1.setPreferredSize(new java.awt.Dimension(60, 30)); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(jComboBox1.getSelectedItem().equals("学生")) { XsJFrame xs=new XsJFrame(); xs.setInst(xs); xs.setVisible(true); inst.setVisible(false); } else { js=new JsJFrame(); js.setInst(js); js.setVisible(true); inst.setVisible(false); } } }); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel( new String[] { "学生", "教师" }); jComboBox1 = new JComboBox(); this.getContentPane().add( jComboBox1, new AnchorConstraint( 385, 651, 498, 440, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jComboBox1.setModel(jComboBox1Model); jComboBox1.setPreferredSize(new java.awt.Dimension(83, 30)); } { jLabel2 = new JLabel(); this.getContentPane().add( jLabel2, new AnchorConstraint( 377, 419, 490, 52, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jLabel2.setText("\u8bf7\u9009\u62e9\u4f60\u767b\u9646\u7684\u8eab\u4efd\uff1a"); jLabel2.setPreferredSize(new java.awt.Dimension(144, 30)); } { jLabel1 = new JLabel(); this.getContentPane().add( jLabel1, new AnchorConstraint( 118, 674, 231, 332, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jLabel1.setText("\u5b66\u751f\u9009\u8bfe\u7cfb\u7edf"); jLabel1.setPreferredSize(new java.awt.Dimension(134, 30)); jLabel1.setFont(new java.awt.Font("Dialog",1,18)); } pack(); setSize(400, 300); } catch (Exception e) { e.printStackTrace(); } } /** * Auto-generated method for setting the popup menu for a component */ private void setComponentPopupMenu(final java.awt.Component parent, final javax.swing.JPopupMenu menu) {parent.addMouseListener(new java.awt.event.MouseAdapter() {public void mousePressed(java.awt.event.MouseEvent e) {if(e.isPopupTrigger())menu.show(parent, e.getX(), e.getY());}public void mouseReleased(java.awt.event.MouseEvent e) {if(e.isPopupTrigger())menu.show(parent, e.getX(), e.getY());}}); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -