示例#1
0
  private void initUI() {
    // Create tabbed pane with commands in it
    tabbedPane = new JTabbedPane();
    getContentPane().add(tabbedPane, BorderLayout.NORTH);

    tabbedPane.addTab("Book", null, createBookPane(), "View book information");
    tabbedPane.addTab("Author", null, createAuthorPane(), "View author information");
    tabbedPane.addTab("Customer", null, createCustomerPane(), "View customer information");
    tabbedPane.addTab("Borrow Book", null, createBorrowPane(), "Borrow books for a customer");
    tabbedPane.addTab("Return Book", null, createReturnPane(), "Return books for a customer");

    // Create output area with scrollpane
    outputArea = new JTextArea();
    // outputArea.setFont(new Font("Monospaced",Font.PLAIN,12));
    outputArea.setFont(new Font("Monospaced", Font.ROMAN_BASELINE, 12));
    outputArea.setEditable(false);
    outputArea.setFocusable(false);
    outputArea.setTabSize(2);
    JScrollPane sp = new JScrollPane(outputArea);
    sp.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS);

    getContentPane().add(sp, BorderLayout.CENTER);

    // Create menus
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');

    JMenuItem clearTextMenuItem = new JMenuItem(clearTextAction);
    JMenuItem exitMenuItem = new JMenuItem(exitAction);

    fileMenu.add(clearTextMenuItem);
    fileMenu.addSeparator();
    fileMenu.add(exitMenuItem);

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    setJMenuBar(menuBar);

    // Pack it all
    pack();
  }