WelcomeFrame.java~27~
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:3k
源码类别:

Java编程

开发平台:

Java

  1. package stumanage;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import sun.awt.image.*;
  5. /**
  6.  * <p>Title: </p>
  7.  * <p>Description: </p>
  8.  * <p>Copyright: Copyright (c) 2003</p>
  9.  * <p>Company: </p>
  10.  * @author not attributable
  11.  * @version 1.0
  12.  */
  13. public class WelcomeFrame
  14.     extends JFrame {
  15.   JPanel jPanel1 = new MyPanel();
  16.   ImageIcon imageIcon1 = new ImageIcon("beautiful.jpg");
  17.   BorderLayout borderLayout1 = new BorderLayout();
  18.   JPanel jPanel2 = new JPanel();
  19.   GridBagLayout gridBagLayout1 = new GridBagLayout();
  20.   JButton jButton1 = new JButton();
  21.   JButton jButton2 = new JButton();
  22.   JButton jButton3 = new JButton();   JButton jButton4 = new JButton();
  23.   public WelcomeFrame() {
  24.     try {
  25.       jbInit();
  26.     }
  27.     catch (Exception e) {
  28.       e.printStackTrace();
  29.     }
  30.   }
  31.   public static void main(String[] args) {
  32.     WelcomeFrame welcomeFrame = new WelcomeFrame();
  33.     welcomeFrame.pack();
  34.     welcomeFrame.show();
  35.   }
  36.   private void jbInit() throws Exception {
  37.     imageIcon1.setDescription("beautiful.jpg");
  38.     imageIcon1.setImageObserver(this);
  39.     jPanel1.setLayout(borderLayout1);
  40.     jPanel1.setMinimumSize(new Dimension(600, 400));
  41.     jPanel1.setPreferredSize(new Dimension(600, 420));
  42.     this.setLocale(java.util.Locale.getDefault());
  43.     this.setResizable(true);
  44.     this.setSize(new Dimension(0, 0));
  45.     this.setState(Frame.NORMAL);     jPanel2.setBackground(UIManager.getColor("RadioButtonMenuItem.selectionBackground"));     jPanel2.setForeground(Color.black);     jPanel2.setMinimumSize(new Dimension(100, 30));
  46.     jPanel2.setPreferredSize(new Dimension(100, 400));
  47.     jPanel2.setLayout(gridBagLayout1);
  48.     jButton1.setToolTipText(" 个人信息管理");     jButton1.setText(" 个人信息管理");
  49.     jButton2.setToolTipText(" 选课信息管理");     jButton2.setText(" 选课信息管理");
  50.     jButton3.setToolTipText("奖励信息管理");     jButton3.setText("奖励信息管理");
  51.     jButton4.setToolTipText("职务信息管理");     jButton4.setText("职务信息管理");     this.getContentPane().add(jPanel1, BorderLayout.CENTER);
  52.     jPanel1.add(jPanel2, BorderLayout.EAST);
  53.     jPanel2.add(jButton1,                        new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  54.     jPanel2.add(jButton2,                  new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(9, 0, 0, 0), 0, 0));
  55.     jPanel2.add(jButton3,            new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0));     jPanel2.add(jButton4,      new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 0), -1, 0));
  56.   }
  57.   class MyPanel
  58.       extends JPanel {
  59.     public void paintComponent(Graphics g) {
  60.       super.paintComponent(g);
  61.       imageIcon1.paintIcon(this, g, 0, 0);
  62.      }
  63.   }
  64. }