搞了一天了,还是没有弄出来,请各位看看,先谢谢了。package Firstpanel;import java.awt.*; //import java.awt.event.ActionEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; //import java.awt.event.KeyEvent;
//import java.awt.event.WindowAdapter;
//import java.awt.event.WindowEvent;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.table.*;
@SuppressWarnings("serial")
public class MainWindow extends JFrame implements ActionListener {
// private static final Component JPanel = null;
private JTabbedPane tabbedPane;
private JLabel label1, label2, label3;
private JPanel panel1,panel2,panel3;
private JButton button1, button2, button3, button4, button5, button6,
button7, button8;
private JTextField cTxt1;
private JComboBox c1, c2, c3, c4, c5;
//private JScrollPane j1, j2, j3;public MainWindow() {
super("管理界面");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
// TODO: handle exception
}setSize(700, 500);
setResizable(false);
centerJFrame();
Container container = getContentPane();
tabbedPane = new JTabbedPane();panel1 = new JPanel();
panel1.setBackground(Color.cyan);
panel2 = new JPanel();
panel3 = new JPanel();label1 = new JLabel("员工工号:");
label1.setBounds(60, 15, 90, 28);JTable table = new JTable(100, 5);
table.setBounds(40, 70, 620, 300);
table.setShowVerticalLines(true);
panel1.add(table);cTxt1 = new JTextField(12);
cTxt1.setBounds(120, 20, 100, 23);button1 = new JButton("查询");
button1.setBounds(270, 20, 90, 28);
button2 = new JButton("添加");
button2.setBounds(410, 20, 90, 28);
button3 = new JButton("删除");
button3.setBounds(550, 20, 90, 28);
button4 = new JButton("查询");
button4.setBounds(270, 20, 90, 28);
button5 = new JButton("添加");
button5.setBounds(410, 20, 90, 28);
button6 = new JButton("删除");
button6.setBounds(550, 20, 90, 28);
button7 = new JButton("密码修改");
button7.setBounds(270, 20, 90, 28);
button8 = new JButton("退出");
button8.setBounds(410, 20, 90, 28);panel1.add(cTxt1);
panel1.add(label1);
panel1.add(button1);
panel1.add(button2);
panel1.add(button3);
panel2.add(button4);
panel2.add(button5);
panel2.add(button6);
panel3.add(button7);
panel3.add(button8);tabbedPane.addTab("人事管理", null, panel1, "人事管理");
tabbedPane.addTab("财务管理", null, panel2, "财务管理");
tabbedPane.addTab("系统管理", null, panel3, "系统管理");
tabbedPane.setBackground(Color.BLUE);panel1.setLayout(null);
panel2.setLayout(null);
panel3.setLayout(null);container.add(tabbedPane);
container.setBackground(Color.WHITE);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}public void centerJFrame() {
int screenwidth = Toolkit.getDefaultToolkit().getScreenSize().width;
int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
setLocation((screenwidth - getWidth()) / 2,
(screenHeight - getHeight()) / 2);
}public static void main(String[] args) {
new MainWindow();
}@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub}
}

解决方案 »

  1.   

    你的代码写的很不规范,我帮你改了一下,你去试运行一下看看:import java.awt.*; 
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener; 
    import javax.swing.*;
    import javax.swing.table.*;public class MainWindow extends JFrame implements ActionListener {
    private JTabbedPane tabbedPane;
    private JScrollPane jScrollPane;
    private JLabel label1, label2, label3;
    private JPanel panel1, panel2, panel3;
    private JButton button1, button2, button3, button4, button5, button6,
    button7, button8;
    private JTextField cTxt1;
    private JComboBox c1, c2, c3, c4, c5;

    public MainWindow(){
    initialize();
    }

    private void initialize() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("管理系统");
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    // TODO: handle exception
    }
    setSize(700, 500);
    setResizable(false);
    setLocationRelativeTo(null);
    Container container = getContentPane();
    tabbedPane = new JTabbedPane();
    panel1 = new JPanel();
    panel2 = new JPanel();
    panel3 = new JPanel(); label1 = new JLabel("员工工号:");
    label1.setBounds(60, 15, 90, 28); JTable table = new JTable(100, 5);

    panel1.add(table);
    jScrollPane = new JScrollPane();
    jScrollPane.setViewportView(table);
    jScrollPane.setBounds(40, 70, 620, 300);

    panel1.add(jScrollPane);
    cTxt1 = new JTextField(12);
    cTxt1.setBounds(120, 20, 100, 23); button1 = new JButton("查询");
    button1.setBounds(270, 20, 90, 28);
    button2 = new JButton("添加");
    button2.setBounds(410, 20, 90, 28);
    button3 = new JButton("删除");
    button3.setBounds(550, 20, 90, 28);
    button4 = new JButton("查询");
    button4.setBounds(270, 20, 90, 28);
    button5 = new JButton("添加");
    button5.setBounds(410, 20, 90, 28);
    button6 = new JButton("删除");
    button6.setBounds(550, 20, 90, 28);
    button7 = new JButton("密码修改");
    button7.setBounds(270, 20, 90, 28);
    button8 = new JButton("退出");
    button8.setBounds(410, 20, 90, 28); panel1.add(cTxt1);
    panel1.add(label1);
    panel1.add(button1);
    panel1.add(button2);
    panel1.add(button3);
    panel2.add(button4);
    panel2.add(button5);
    panel2.add(button6);
    panel3.add(button7);
    panel3.add(button8); tabbedPane.addTab("人事管理", null, panel1, "人事管理");
    tabbedPane.addTab("财务管理", null, panel2, "财务管理");
    tabbedPane.addTab("系统管理", null, panel3, "系统管理");
    tabbedPane.setBackground(Color.BLUE); panel1.setLayout(null);
    panel2.setLayout(null);
    panel3.setLayout(null); container.add(tabbedPane);
    container.setBackground(Color.WHITE);

    }
    public static void main(String[] args) {
    MainWindow mw = new MainWindow();
    mw.setVisible(true);
    }

    public void actionPerformed(ActionEvent e) { }
    }