Beispiel #1
0
  /**
   * Constructs a JToolBar that can be added to a JFrame
   *
   * @return a JToolBar
   */
  private JToolBar toolBar() {
    JToolBar toolbar = new JToolBar();
    JButton button;

    button = new JButton(images.loadImage("Images/toolbar/add_child_icon.png"));
    button.setToolTipText(lang_model.getValue(41));
    button.setFocusPainted(false);
    button.setActionCommand("newchild");
    button.addActionListener(this);
    toolbar.add(button);

    button = new JButton(images.loadImage("Images/toolbar/add_employee_icon.png"));
    button.setToolTipText(lang_model.getValue(147));
    button.setFocusPainted(false);
    button.setActionCommand("newemployee");
    button.addActionListener(this);
    toolbar.add(button);

    button = new JButton(images.loadImage("Images/toolbar/XML_icon_large.png"));
    button.setToolTipText(lang_model.getValue(148));
    button.setFocusPainted(false);
    button.setActionCommand("openfile");
    button.addActionListener(this);
    toolbar.add(button);

    button = new JButton(images.loadImage("Images/toolbar/calendar_icon_large.png"));
    button.setToolTipText(lang_model.getValue(149));
    button.setFocusPainted(false);
    button.setActionCommand("viewcalendar");
    button.addActionListener(this);
    button.setEnabled(false);
    toolbar.add(button);

    button = new JButton(images.loadImage("Images/toolbar/database_icon_large.png"));
    button.setToolTipText(lang_model.getValue(150));
    button.setFocusPainted(false);
    button.setActionCommand("viewdatabase");
    button.addActionListener(this);
    toolbar.add(button);

    button = new JButton(images.loadImage("Images/toolbar/finances_icon_large.png"));
    button.setToolTipText(lang_model.getValue(151));
    button.setFocusPainted(false);
    button.setActionCommand("viewfinances");
    button.addActionListener(this);
    button.setEnabled(false);
    toolbar.add(button);

    toolbar.setRollover(true);
    toolbar.setFloatable(false);
    toolbar.setSize(f.getWidth(), 15);

    return toolbar;
  }
Beispiel #2
0
  public JInternalFrame employeeFrame() {
    JInternalFrame f = new JInternalFrame();

    f =
        new JInternalFrame(
            "Employee Database",
            false, // Resizable
            true, // Closable
            true, // Maximizable
            true); // Iconifiable
    f.setLayout(new BorderLayout());

    JScrollPane sp = new JScrollPane(employeeTable());
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    sp.setBorder(BorderFactory.createTitledBorder("Employees"));

    f.add(buttonPanel(false), BorderLayout.NORTH);
    f.add(sp);

    //		f.setLocation(loc);
    f.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
    f.setFrameIcon(images.loadImage("Images/menubar/database_icon.png"));
    f.addInternalFrameListener(this);

    if (osp.isLowResolution()) f.setSize(550, 282);
    else if (osp.isMidResolution()) f.setSize(550, 282);
    else f.setSize(850, 500); // Width, Height
    f.setVisible(true);

    try {
      f.setSelected(true);
    } catch (PropertyVetoException e1) {
      e1.printStackTrace();
    }

    return f;
  }
Beispiel #3
0
  /**
   * Constructs a JMenuBar that can be added to a JFrame
   *
   * @return a JMenuBar
   */
  private JMenuBar menuBar() {
    JMenuBar mb = new JMenuBar();

    JMenu fileMenu, editMenu, viewMenu, helpMenu, newEntry, viewDatabase;
    JMenuItem newChild,
        newEmployee,
        newAccount,
        openChild,
        viewFileChild,
        viewFileEmployee,
        saveChild,
        saveAs,
        printDocument,
        properties,
        viewDatabaseChild,
        viewDatabaseEmployee,
        viewFinances,
        viewCalendar,
        exit,
        cut,
        copy,
        paste,
        help,
        faq,
        report,
        about,
        checkupdate;

    // Initialize JMenu's
    fileMenu = new JMenu(lang_model.getValue(12));
    editMenu = new JMenu(lang_model.getValue(23));
    viewMenu = new JMenu(lang_model.getValue(27));
    helpMenu = new JMenu(lang_model.getValue(33));

    fileMenu.setRolloverEnabled(true);
    editMenu.setRolloverEnabled(true);
    helpMenu.setRolloverEnabled(true);

    // Initialize sub-JMenu's
    newEntry = new JMenu(lang_model.getValue(13));
    newEntry.setIcon(images.loadImage("Images/menubar/application_icon.png"));
    openChild = new JMenu(lang_model.getValue(14));
    openChild.setIcon(images.loadImage("Images/menubar/XML_icon_small.png"));
    viewDatabase = new JMenu(lang_model.getValue(29));
    viewDatabase.setIcon(images.loadImage("Images/menubar/database_icon.png"));

    // Initialize JMenuItem's
    newChild = new JMenuItem(lang_model.getValue(20));
    newEmployee = new JMenuItem(lang_model.getValue(21));
    newAccount = new JMenuItem(lang_model.getValue(22));
    saveChild =
        new JMenuItem(lang_model.getValue(15), images.loadImage("Images/menubar/save_icon.png"));
    saveAs = new JMenuItem(lang_model.getValue(16));
    printDocument =
        new JMenuItem(lang_model.getValue(18), images.loadImage("Images/menubar/print_icon.png"));
    properties =
        new JMenuItem(
            lang_model.getValue(17), images.loadImage("Images/menubar/properties_icon.png"));
    viewCalendar =
        new JMenuItem(
            lang_model.getValue(28), images.loadImage("Images/menubar/calendar_icon.png"));
    viewDatabaseChild = new JMenuItem(lang_model.getValue(31));
    viewDatabaseEmployee = new JMenuItem(lang_model.getValue(32));
    viewFileChild = new JMenuItem(lang_model.getValue(20));
    viewFileEmployee = new JMenuItem(lang_model.getValue(21));

    saveChild.setEnabled(false);
    saveAs.setEnabled(false);
    printDocument.setEnabled(false);
    viewCalendar.setEnabled(false);

    viewFinances =
        new JMenuItem(
            lang_model.getValue(30), images.loadImage("Images/menubar/finances_icon_small.png"));

    exit = new JMenuItem(lang_model.getValue(19));
    cut = new JMenuItem(lang_model.getValue(24), images.loadImage("Images/menubar/cut_icon.png"));
    copy = new JMenuItem(lang_model.getValue(25), images.loadImage("Images/menubar/copy_icon.png"));
    paste =
        new JMenuItem(lang_model.getValue(26), images.loadImage("Images/menubar/paste_icon.png"));

    viewFinances.setEnabled(false);
    cut.setEnabled(false);
    copy.setEnabled(false);
    paste.setEnabled(false);

    help = new JMenuItem(lang_model.getValue(33), images.loadImage("Images/menubar/help_icon.png"));
    faq = new JMenuItem(lang_model.getValue(34));
    report = new JMenuItem(lang_model.getValue(35));
    about =
        new JMenuItem(
            lang_model.getValue(36), images.loadImage("Images/menubar/exclamation_icon.png"));
    checkupdate = new JMenuItem(lang_model.getValue(105));

    faq.setEnabled(false);
    checkupdate.setEnabled(false);

    // Add JMenuItem's to the JMenu's
    fileMenu.add(newEntry);
    newEntry.add(newChild); // Sub-Menu of fileMenu
    newEntry.add(newEmployee); // Sub-Menu of fileMenu
    newEntry.add(newAccount); // Sub-Menu of fileMenu
    fileMenu.add(openChild);
    openChild.add(viewFileChild);
    openChild.add(viewFileEmployee);
    // fileMenu.add(view);
    fileMenu.addSeparator();
    fileMenu.add(saveChild);
    fileMenu.add(saveAs);
    fileMenu.addSeparator();
    fileMenu.add(printDocument);
    fileMenu.addSeparator();
    fileMenu.add(properties);
    fileMenu.addSeparator();
    fileMenu.add(exit);
    editMenu.add(cut);
    editMenu.add(copy);
    editMenu.add(paste);
    viewMenu.add(viewCalendar);
    viewMenu.add(viewDatabase);
    viewDatabase.add(viewDatabaseChild);
    viewDatabase.add(viewDatabaseEmployee);
    viewMenu.add(viewFinances);
    helpMenu.add(help);
    helpMenu.add(faq);
    helpMenu.add(report);
    helpMenu.add(about);
    helpMenu.add(checkupdate);

    // Add JMenu's to the MenuBar
    mb.add(fileMenu);
    mb.add(editMenu);
    mb.add(viewMenu);
    mb.add(helpMenu);

    // Mnemonics
    fileMenu.setMnemonic('F');
    newEntry.setMnemonic('N');
    editMenu.setMnemonic('E');
    viewMenu.setMnemonic('V');
    helpMenu.setMnemonic('H');

    // Accelerators
    newChild.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    newEmployee.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    saveChild.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    printDocument.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
    viewFinances.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    viewCalendar.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
    paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));

    // Action Listening
    newChild.setActionCommand("newchild");
    newChild.addActionListener(this);
    newEmployee.setActionCommand("newemployee");
    newEmployee.addActionListener(this);
    newAccount.setActionCommand("newaccount");
    newAccount.addActionListener(this);
    openChild.setActionCommand("openfile");
    openChild.addActionListener(this);
    viewFileChild.setActionCommand("viewfilechild");
    viewFileChild.addActionListener(this);
    viewFileEmployee.setActionCommand("viewfileemployee");
    viewFileEmployee.addActionListener(this);
    viewDatabaseChild.setActionCommand("viewchilddatabase");
    viewDatabaseChild.addActionListener(this);
    viewDatabaseEmployee.setActionCommand("viewemployeedatabase");
    viewDatabaseEmployee.addActionListener(this);
    viewFinances.setActionCommand("viewfinances");
    viewFinances.addActionListener(this);
    viewCalendar.setActionCommand("viewcalendar");
    viewCalendar.addActionListener(this);
    printDocument.setActionCommand("printdocument");
    printDocument.addActionListener(this);
    properties.setActionCommand("properties");
    properties.addActionListener(this);
    exit.setActionCommand("exit");
    exit.addActionListener(this);
    help.setActionCommand("help");
    help.addActionListener(this);
    faq.setActionCommand("faq");
    faq.addActionListener(this);
    report.setActionCommand("reportbug");
    report.addActionListener(this);
    about.setActionCommand("about");
    about.addActionListener(this);
    checkupdate.setActionCommand("checkupdate");
    checkupdate.addActionListener(this);

    return mb;
  }
Beispiel #4
0
  /*
   * Returns a JPanel that holds JButtons. These buttons
   * are used for various tasks such as adding a new child, deleting
   * a child, refreshing the database, etc.
   */
  private JPanel buttonPanel(boolean b) {
    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel trailPanel = new JPanel(new FlowLayout());

    if (b) {
      JButton addChildButton = new JButton(images.loadImage("Images/toolbar/add_child_icon.png"));
      addChildButton.setPreferredSize(new Dimension(30, 30));
      addChildButton.setFocusPainted(false);
      addChildButton.setToolTipText("Add New Child");
      addChildButton.setActionCommand("newchild");
      addChildButton.addActionListener(this);
      addChildButton.setEnabled(false);
      trailPanel.add(addChildButton);
    } else {
      JButton addEmployeeButton =
          new JButton(images.loadImage("Images/toolbar/add_employee_icon.png"));
      addEmployeeButton.setPreferredSize(new Dimension(30, 30));
      addEmployeeButton.setFocusPainted(false);
      addEmployeeButton.setToolTipText("Add New Employee");
      addEmployeeButton.setActionCommand("newemployee");
      addEmployeeButton.addActionListener(this);
      addEmployeeButton.setEnabled(false);
      trailPanel.add(addEmployeeButton);
    }

    // TODO: opening a file but currently selected row
    JButton openButton = new JButton(images.loadImage("Images/toolbar/XML_icon_large.png"));
    openButton.setPreferredSize(new Dimension(30, 30));
    openButton.setFocusPainted(false);
    openButton.setToolTipText("Open Selected File");
    openButton.setActionCommand("open");
    openButton.addActionListener(this);
    trailPanel.add(openButton);

    JButton refreshButton =
        new JButton(images.loadImage("Images/database/database_refresh_icon.png"));
    refreshButton.setPreferredSize(new Dimension(30, 30));
    refreshButton.setFocusPainted(false);
    refreshButton.setToolTipText("Refresh Database");
    refreshButton.setActionCommand("refresh");
    refreshButton.addActionListener(this);
    // refreshButton.setEnabled(false);
    trailPanel.add(refreshButton);

    JButton saveButton = new JButton(images.loadImage("Images/database/database_save_icon.png"));
    saveButton.setPreferredSize(new Dimension(30, 30));
    saveButton.setFocusPainted(false);
    saveButton.setToolTipText("Save Changes");
    saveButton.setActionCommand("save");
    saveButton.addActionListener(this);
    saveButton.setEnabled(false);
    trailPanel.add(saveButton);

    JButton deleteButton =
        new JButton(images.loadImage("Images/database/database_delete_icon.png"));
    deleteButton.setPreferredSize(new Dimension(30, 30));
    deleteButton.setFocusPainted(false);
    if (b) deleteButton.setToolTipText("Delete Selected Child");
    else deleteButton.setToolTipText("Delete Selected Employee");
    deleteButton.setActionCommand("delete");
    deleteButton.addActionListener(this);
    trailPanel.add(deleteButton);

    mainPanel.add(trailPanel, BorderLayout.WEST);

    return mainPanel;
  }