📄 totaljframe.java
字号:
exitMenuItem.setText("\u9000\u51fa");
exitMenuItem.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
exitMenuItemMousePressed(evt);
}
});
operateMenu.add(exitMenuItem);
operateMenuBar.add(operateMenu);
helpMenu.setText("\u5e2e\u52a9");
showMenuItem.setText("\u663e\u793a");
showMenuItem.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
showMenuItemMousePressed(evt);
}
});
helpMenu.add(showMenuItem);
aboutMenuItem.setText("\u5173\u4e8e");
aboutMenuItem.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
aboutMenuItemMousePressed(evt);
}
});
helpMenu.add(aboutMenuItem);
operateMenuBar.add(helpMenu);
setJMenuBar(operateMenuBar);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(newBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(findBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(editBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 92, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(deleteBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 91, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(showallBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(exitBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 26, Short.MAX_VALUE)
.add(jScrollPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 447, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(72, 72, 72)
.add(findBtn)
.add(38, 38, 38)
.add(newBtn)
.add(38, 38, 38)
.add(editBtn)
.add(42, 42, 42)
.add(deleteBtn)
.add(42, 42, 42)
.add(showallBtn)
.add(43, 43, 43)
.add(exitBtn)
.addContainerGap(129, Short.MAX_VALUE))
.add(jScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void showallBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_showallBtnMouseClicked
cpy.Sconnection();
try{
Statement s=cpy.con.createStatement();
ResultSet rs=s.executeQuery("select * from 职工信息");
int row=0;
while(rs.next()){
showTable.setValueAt(rs.getString("职工号"),row,0);
showTable.setValueAt(rs.getString("姓名"),row,1);
showTable.setValueAt(rs.getString("性别"),row,2);
showTable.setValueAt(rs.getInt("年龄"),row,3);
showTable.setValueAt(rs.getString("籍贯"),row,4);
showTable.setValueAt(rs.getString("婚姻状况"),row,5);
showTable.setValueAt(rs.getInt("工龄"),row,6);
showTable.setValueAt(rs.getInt("工资"),row,7);
showTable.setValueAt(rs.getString("职位"),row,8);
row++;
}
s.close();
cpy.con.close();
}catch(SQLException e){ System.out.println(e.getMessage());}
jScrollPane.setViewportView(showPanel);
showPanel.setVisible(true);
firstPanel.setVisible(false);
}//GEN-LAST:event_showallBtnMouseClicked
private void findBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_findBtnMouseClicked
partJFrame pf=new partJFrame("查找");
pf.show();
op="查找";
}//GEN-LAST:event_findBtnMouseClicked
private void exitBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exitBtnMouseClicked
this.dispose();
}//GEN-LAST:event_exitBtnMouseClicked
private void deleteBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_deleteBtnMouseClicked
partJFrame pf=new partJFrame("查找");
pf.show();
op="删除";
}//GEN-LAST:event_deleteBtnMouseClicked
private void editBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editBtnMouseClicked
partJFrame pf=new partJFrame("查找");
pf.show();
op="编辑";
}//GEN-LAST:event_editBtnMouseClicked
private void newBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newBtnMouseClicked
allJFrame af=new allJFrame("新增");
af.show();
op="新增";
}//GEN-LAST:event_newBtnMouseClicked
private void showMenuItemMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_showMenuItemMousePressed
cpy.Sconnection();
try{
Statement s=cpy.con.createStatement();
ResultSet rs=s.executeQuery("select * from 职工信息");
int row=0;
while(rs.next()){
showTable.setValueAt(rs.getString("职工号"),row,0);
showTable.setValueAt(rs.getString("姓名"),row,1);
showTable.setValueAt(rs.getString("性别"),row,2);
showTable.setValueAt(rs.getInt("年龄"),row,3);
showTable.setValueAt(rs.getString("籍贯"),row,4);
showTable.setValueAt(rs.getString("婚姻状况"),row,5);
showTable.setValueAt(rs.getInt("工龄"),row,6);
showTable.setValueAt(rs.getInt("工资"),row,7);
showTable.setValueAt(rs.getString("职位"),row,8);
row++;
}
s.close();
cpy.con.close();
}catch(SQLException e){ System.out.println(e.getMessage());}
jScrollPane.setViewportView(showPanel);
showPanel.setVisible(true);
firstPanel.setVisible(false);
}//GEN-LAST:event_showMenuItemMousePressed
private void editMenuItemMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editMenuItemMousePressed
partJFrame pf=new partJFrame("查找");
pf.show();
op="编辑";
}//GEN-LAST:event_editMenuItemMousePressed
private void addMenuItemMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_addMenuItemMousePressed
allJFrame af=new allJFrame("新增");
af.show();
op="新增";
}//GEN-LAST:event_addMenuItemMousePressed
private void deleteMenuItemMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_deleteMenuItemMousePressed
partJFrame pf=new partJFrame("查找");
pf.show();
op="删除";
}//GEN-LAST:event_deleteMenuItemMousePressed
private void findMenuItemMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_findMenuItemMousePressed
partJFrame pf=new partJFrame("查找");
pf.show();
op="查找";
}//GEN-LAST:event_findMenuItemMousePressed
private void aboutMenuItemMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_aboutMenuItemMousePressed
aboutFrame af=new aboutFrame();
af.show();
}//GEN-LAST:event_aboutMenuItemMousePressed
private void exitMenuItemMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exitMenuItemMousePressed
this.dispose();// TODO 将在此处添加您的处理代码:
}//GEN-LAST:event_exitMenuItemMousePressed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new totalJFrame().setVisible(true);
}
});
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JMenuItem aboutMenuItem;
private javax.swing.JMenuItem addMenuItem;
private javax.swing.JButton deleteBtn;
private javax.swing.JMenuItem deleteMenuItem;
private javax.swing.JButton editBtn;
private javax.swing.JMenuItem editMenuItem;
private javax.swing.JButton exitBtn;
private javax.swing.JMenuItem exitMenuItem;
private javax.swing.JButton findBtn;
private javax.swing.JMenuItem findMenuItem;
private javax.swing.JPanel firstPanel;
private javax.swing.JMenu helpMenu;
private javax.swing.JScrollPane jScrollPane;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JButton newBtn;
private javax.swing.JMenu operateMenu;
private javax.swing.JMenuBar operateMenuBar;
private javax.swing.JMenuItem showMenuItem;
private javax.swing.JPanel showPanel;
private javax.swing.JTable showTable;
private javax.swing.JButton showallBtn;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -