Oracle9i查询器.用jdbc实现().用了swing..(主面板)

时间:2021-10-27 11:31:42

package client;
import javax.swing.*;
import javax.swing.border.EmptyBorder;

import java.awt.*;
import java.awt.event.*;


 /*
  * @sqlclient panel
  */
public class MainPanel extends JPanel{
 
 private JComboBox serverbox;
 private JComboBox ipbox;
 
 private JTextField serverfield;
 private JTextField ipfield;
 private JTextField namefield;
 private JPasswordField passfield;
 private JButton okbutton;
 private JButton exitbutton;
 
 
 public JComboBox getIpbox() {
  return ipbox;
 }
 public JComboBox getServerbox() {
  return serverbox;
 }
 public JButton getExitbutton() {
  return exitbutton;
 }
 public JTextField getIpfield() {
  return ipfield;
 }
 public JTextField getNamefield() {
  return namefield;
 }
 public JButton getOkbutton() {
  return okbutton;
 }
 public JTextField getPassfield() {
  return passfield;
 }
 public JTextField getServerfield() {
  return serverfield;
 }
 public MainPanel(){
  
  serverbox= new JComboBox();
  serverbox.addItem("Oracle");
  serverbox.addItem("MySql");
//  ipbox=new JComboBox();
//  ipbox.addItem("jdbc:oracle:thin:@192.168.0.206:1521:tarena");
//  ipbox.addItem("jdbc:mysql://localhost:3306/");
  
  serverfield=new JTextField(15);
  ipfield=new JTextField(15);
  namefield =new JTextField(15);
  passfield =new JPasswordField(15);
  passfield.setEchoChar('*');
  okbutton =new JButton("确认");
  exitbutton=new JButton("退出");
  this.setBorder(new EmptyBorder(10,0,0,20));
  //this.setLayout(new BorderLayout());
  
  JPanel p=new JPanel();
  p.setLayout(new GridLayout(4,2,0,10));
  //p.add(new JLabel("SQL命令简易查询"));
  p.add(new JLabel("选择数据库驱动",SwingConstants.CENTER));
  //p.add(serverfield);
  p.add(serverbox);
  p.add(new JLabel("请输IP地址",SwingConstants.CENTER));
  p.add(ipfield);
  p.add(new JLabel("账号名",SwingConstants.CENTER));
  p.add(namefield);
  p.add(new JLabel("密码",SwingConstants.CENTER));
  p.add(passfield);
  
  this.add(p);
  JPanel p2=new JPanel();
  p2.add(okbutton);
  p2.add(exitbutton);
  this.add(p2,"South");
  
  
 }