⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frame1.java

📁 这是自己做的图书馆信息管理系统
💻 JAVA
字号:
package infomanagement;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
import com.borland.dx.dataset.TableDataSet;
import java.awt.BorderLayout;
import java.awt.Font;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;





public class Frame1 extends JFrame {

  public JFrame jfa;
  private JPanel contentPane;
  private BorderLayout borderLayout1 = new BorderLayout();
  private JPanel jPanel1 = new JPanel();
  //设置jPanel1的布局方式为xylayout,任意布局
  private XYLayout xYLayout1 = new XYLayout();
  private JLabel jLabel1 = new JLabel();
  private TitledBorder titledBorder1;
  private JRadioButton rdbInputScnAch = new JRadioButton();
  //理科成绩查询
  private JRadioButton rdbQqueryScnAch = new JRadioButton();
  //文科成绩录入
  private JRadioButton rdbInputArtAch = new JRadioButton();
  //文科成绩查询
  private JRadioButton rdbQueryArtAch = new JRadioButton();
  JMenuBar jMenuBar1 = new JMenuBar();
  JMenu mm=new JMenu("登陆");
  JMenu mn=new JMenu("关于");
  JMenuItem m1=new JMenuItem("高级管理员");
  String query="select 书名,出版社 from book where 出版社='qlsc' ";



  JMenuItem m2=new JMenuItem("普通管理员");
  JMenuItem m3=new JMenu("学生");
  TableDataSet tableDataSet1 = new TableDataSet();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel4 = new JLabel();
  JRadioButton jRadioButton1 = new JRadioButton();
  JRadioButton jRadioButton2 = new JRadioButton();
  JRadioButton jRadioButton3 = new JRadioButton();
  JLabel jLabel5 = new JLabel();
  public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
     // m1.addActionListener(this);
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception  {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    titledBorder1 = new TitledBorder("");
    contentPane.setLayout(borderLayout1);
    this.setJMenuBar(jMenuBar1);
    this.setSize(new Dimension(399, 288));
    this.setTitle("图书馆管理系统登陆窗口");
    jPanel1.setLayout(xYLayout1);
    jLabel1.setFont(new java.awt.Font("Dialog", 0, 23));
    jLabel1.setForeground(Color.green);
    jLabel1.setBorder(titledBorder1);
    //输入项目标题
    jLabel1.setText("              请选择您登陆的方式");
    rdbInputScnAch.setForeground(Color.red);
    //rdbInputScnAch的标题 理科成绩录入
    rdbInputScnAch.setText("理科成绩录入");
    //加入jRadioButton事件,rdbInputScnAch(理科成绩录入)
    rdbInputScnAch.addMouseListener(new java.awt.event.MouseAdapter() {
      //添加鼠标单击事件
      public void mouseClicked(MouseEvent e) {
        rdbInputScnAch_mouseClicked(e);
      }
    });
    jLabel2.setForeground(Color.red);
    jLabel2.setText("高级管理员");
    jLabel3.setForeground(Color.red);
    jLabel3.setText("普通管理员");
    jLabel4.setForeground(Color.red);
    jLabel4.setText("学生");
    jRadioButton1.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jRadioButton1_actionPerformed(e);
      }
    });
    jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
    jLabel5.setForeground(Color.green);
    jLabel5.setText("请选择你要登陆的方式");
    mm.add(m1);
    mm.add(m2);
    mm.add(m3);
    //jMenuBar1.add(mm);
    //jMenuBar1.add(mn);
    setJMenuBar(jMenuBar1);
    // m2.addActionListener(new ActionListener(){
       //System.out.println("aghfhgalsfj");
       try{
       //Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     }
     catch(ClassNotFoundException e){
       System.out.println(e);
     }
     try{

       String url="jdbc:odbc:nn";
       String user="";
       String password="";
       Connection conn=DriverManager.getConnection(url,user,password);
       Statement stmt=conn.createStatement();
       ResultSet rs=stmt.executeQuery(query);
        ResultSetMetaData rsmd=rs.getMetaData();
        int numberOfColumns=rsmd.getColumnCount();
        int rowCount=1;
        while(rs.next())
        {
          //System.out.println("Row"+rowCount+":");
          for(int i=1;i<=numberOfColumns;i++)
          {
            //System.out.print("Column  "+i+":");
            //System.out.println(rs.getString(i));
          }
          rowCount++;
        }
        stmt.close();
        conn.close();

     }
     catch(SQLException e)
     {
        System.err.print("SQLException:");
        System.err.println(e.getMessage());
     }


       jRadioButton1.addMouseListener(new java.awt.event.MouseAdapter() {

     public void mouseClicked(MouseEvent e) {

       gaoji_mouseClicked(e);
     }
   });

   jRadioButton2.addMouseListener(new java.awt.event.MouseAdapter() {
      //添加鼠标单击事件
      public void mouseClicked(MouseEvent e) {
       putong_mouseClicked(e);
      }
    });

     jRadioButton3.addMouseListener(new java.awt.event.MouseAdapter() {
     //添加鼠标单击事件
     public void mouseClicked(MouseEvent e) {
       xuesheng_mouseClicked(e);
     }
   });







    //将文字颜色设为红色
    rdbQqueryScnAch.setForeground(Color.red);
    //rdbQqueryScnAch的标题 理科成绩查询
    rdbQqueryScnAch.setText("理科成绩查询");
     //加入jRadioButton事件 rdbQqueryScnAch("理科成绩查询")
    rdbQqueryScnAch.addMouseListener(new java.awt.event.MouseAdapter() {
      //添加鼠标单击事件
      public void mouseClicked(MouseEvent e) {
        rdbQqueryScnAch_mouseClicked(e);
      }
    });
    //将文字颜色设为红色
    rdbInputArtAch.setForeground(Color.red);
    //rdbInputArtAch的标题 文科成绩录入
    rdbInputArtAch.setText("文科成绩录入");
     //加入jRadioButton事件 rdbInputArtAch("文科成绩录入")
    rdbInputArtAch.addMouseListener(new java.awt.event.MouseAdapter() {
      //添加鼠标单击事件
      public void mouseClicked(MouseEvent e) {
        rdbInputArtAch_mouseClicked(e);
      }
    });

    //将文字颜色设为红色
    rdbQueryArtAch.setForeground(Color.red);
    //rdbQueryArtAch的标题 文科成绩查询
    rdbQueryArtAch.setText("文科成绩查询");
     //加入jRadioButton事件 rdbQueryArtAch("文科成绩查询")
    rdbQueryArtAch.addMouseListener(new java.awt.event.MouseAdapter() {
      //添加鼠标单击事件
      public void mouseClicked(MouseEvent e) {
        rdbQueryArtAch_mouseClicked(e);
      }
    });
    jPanel1.add(jLabel5, new XYConstraints(87, 19, -1, -1));
    jPanel1.add(jLabel3, new XYConstraints(219, 89, -1, -1));
    jPanel1.add(jLabel2, new XYConstraints(87, 87, -1, -1));
    jPanel1.add(jRadioButton1, new XYConstraints(57, 83, -1, -1));
    jPanel1.add(jRadioButton2, new XYConstraints(199, 84, -1, -1));
    jPanel1.add(jLabel4, new XYConstraints(89, 134, -1, -1));
    jPanel1.add(jRadioButton3, new XYConstraints(58, 132, -1, -1));
    contentPane.add(jPanel1, java.awt.BorderLayout.CENTER);
  }
  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
//显示理科成绩录入界面
   void putong_mouseClicked(MouseEvent e)
  {
    putong dlg = new putong();
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 +
                    loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.pack();

    dlg.setVisible(true);

  }


    void xuesheng_mouseClicked(MouseEvent e)
    {
      xuesheng dlg = new xuesheng();
      Dimension dlgSize = dlg.getPreferredSize();
      Dimension frmSize = getSize();
      Point loc = getLocation();
      dlg.setLocation((frmSize.width - dlgSize.width) / 2 +
                      loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
      dlg.setModal(true);
      dlg.pack();

      dlg.setVisible(true);

  }

  void gaoji_mouseClicked(MouseEvent e) {

    gaoji dlg = new gaoji();
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 +
                    loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.pack();

    dlg.setVisible(true);
  }






  void rdbInputScnAch_mouseClicked(MouseEvent e) {
    //调用理科成绩录入界面对话框
    ScienceAchievement dlg = new ScienceAchievement();
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 +
                    loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.pack();
    dlg.setVisible(true);
  }
//显示理科成绩查询界面
  void rdbQqueryScnAch_mouseClicked(MouseEvent e) {
    //调用理科成绩查询界面对话框
    ScienceQuery dlg = new ScienceQuery();
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.pack();
    dlg.setVisible(true);
  }
//显示文科成绩录入界面
  void rdbInputArtAch_mouseClicked(MouseEvent e) {
    //调用文科成绩录入界面对话框
    ArtsAchievement dlg = new ArtsAchievement();
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.pack();
    dlg.setVisible(true);
  }
//显示文科成绩查询界面
  void rdbQueryArtAch_mouseClicked(MouseEvent e) {
    //调用文科成绩查询界面对话框
    ArtsQuery dlg = new ArtsQuery();
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.pack();
    dlg.setVisible(true);
  }

  public void jRadioButton1_actionPerformed(ActionEvent e) {

  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -