private TransparentPanel addButtonsToPanel(String[] buttonText) {
   TransparentPanel panel = new TransparentPanel(new GridLayout(0, s1.length, 2, 2));
   for (int i = 0; i < buttonText.length; i++) {
     String s = buttonText[i];
     PosButton button = new PosButton();
     button.setText(s);
     button.setPreferredSize(pSize);
     button.addActionListener(this);
     button.setFont(buttonFont);
     buttons.add(button);
     panel.add(button);
   }
   return panel;
 }
  public NoteView() {
    setLayout(new BorderLayout(5, 5));

    // note.setFont(note.getFont().deriveFont(Font.BOLD, 18));
    note.setWrapStyleWord(true);
    note.setLineWrap(true);
    note.setDocument(new FixedLengthDocument(255));

    TransparentPanel northPanel = new TransparentPanel(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(note);
    northPanel.setPreferredSize(new Dimension(100, 60));
    northPanel.add(scrollPane);
    add(northPanel, BorderLayout.NORTH);

    TransparentPanel centerPanel = new TransparentPanel(new GridLayout(0, 1, 2, 2));
    centerPanel.add(addButtonsToPanel(s1));
    centerPanel.add(addButtonsToPanel(s2));
    centerPanel.add(addButtonsToPanel(s3));
    centerPanel.add(addButtonsToPanel(s4));
    add(centerPanel, BorderLayout.CENTER);

    JPanel eastPanel = new JPanel(new GridLayout(0, 1, 2, 2));
    PosButton button = new PosButton();
    button.setText(Messages.getString("NoteView.40")); // $NON-NLS-1$
    button.addActionListener(this);
    eastPanel.add(button);

    POSToggleButton toggleButton = new POSToggleButton();
    toggleButton.setText(Messages.getString("NoteView.41")); // $NON-NLS-1$
    toggleButton.addChangeListener(this);
    eastPanel.add(toggleButton);

    button = new PosButton();
    button.setText(com.floreantpos.POSConstants.CLEAR);
    button.addActionListener(this);
    eastPanel.add(button);

    button = new PosButton();
    button.setText(com.floreantpos.POSConstants.CLEAR_ALL);
    button.addActionListener(this);
    eastPanel.add(button);

    eastPanel.setPreferredSize(new Dimension(90, 50));
    add(eastPanel, BorderLayout.EAST);
  }
  public CookingInstructionExplorer() {
    categoryList = dao.findAll();

    tableModel = new CookingInstructionTableModel();
    table = new JTable(tableModel);
    table.setDefaultRenderer(Object.class, new PosTableRenderer());

    setLayout(new BorderLayout(5, 5));
    add(new JScrollPane(table));

    JButton addButton = new JButton(com.floreantpos.POSConstants.ADD);
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              String instruction =
                  JOptionPane.showInputDialog(
                      POSUtil.getFocusedWindow(),
                      com.floreantpos.POSConstants.ENTER_INSTRUCTION_DESCRIPTION);
              if (instruction == null) {
                BOMessageDialog.showError(
                    POSUtil.getFocusedWindow(),
                    com.floreantpos.POSConstants.INSTRUCTION_CANNOT_BE_EMPTY);
                return;
              }
              if (instruction.length() > 60) {
                BOMessageDialog.showError(
                    POSUtil.getFocusedWindow(),
                    com.floreantpos.POSConstants.LONG_INSTRUCTION_ERROR);
                return;
              }

              CookingInstruction cookingInstruction = new CookingInstruction();
              cookingInstruction.setDescription(instruction);
              dao.save(cookingInstruction);

              tableModel.add(cookingInstruction);
            } catch (Exception x) {
              BOMessageDialog.showError(com.floreantpos.POSConstants.ERROR_MESSAGE, x);
            }
          }
        });

    JButton editButton = new JButton(com.floreantpos.POSConstants.EDIT);
    editButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              int index = table.getSelectedRow();
              if (index < 0) return;

              CookingInstruction cookingInstruction = categoryList.get(index);
              String instruction =
                  JOptionPane.showInputDialog(
                      POSUtil.getFocusedWindow(),
                      com.floreantpos.POSConstants.ENTER_INSTRUCTION_DESCRIPTION,
                      cookingInstruction.getDescription());

              if (instruction == null) {
                BOMessageDialog.showError(
                    POSUtil.getFocusedWindow(),
                    com.floreantpos.POSConstants.INSTRUCTION_CANNOT_BE_EMPTY);
                return;
              }
              if (instruction.length() > 60) {
                BOMessageDialog.showError(
                    POSUtil.getFocusedWindow(),
                    com.floreantpos.POSConstants.LONG_INSTRUCTION_ERROR);
                return;
              }
              cookingInstruction.setDescription(instruction);
              dao.saveOrUpdate(cookingInstruction);
              table.repaint();
            } catch (Throwable x) {
              BOMessageDialog.showError(com.floreantpos.POSConstants.ERROR_MESSAGE, x);
            }
          }
        });
    JButton deleteButton = new JButton(com.floreantpos.POSConstants.DELETE);
    deleteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              int index = table.getSelectedRow();
              if (index < 0) return;

              if (ConfirmDeleteDialog.showMessage(
                      CookingInstructionExplorer.this,
                      com.floreantpos.POSConstants.CONFIRM_DELETE,
                      com.floreantpos.POSConstants.DELETE)
                  == ConfirmDeleteDialog.YES) {
                CookingInstruction cookingInstruction = categoryList.get(index);
                dao.delete(cookingInstruction);
                tableModel.delete(cookingInstruction, index);
              }
            } catch (Exception x) {
              BOMessageDialog.showError(com.floreantpos.POSConstants.ERROR_MESSAGE, x);
            }
          }
        });

    TransparentPanel panel = new TransparentPanel();
    panel.add(addButton);
    panel.add(editButton);
    panel.add(deleteButton);
    add(panel, BorderLayout.SOUTH);
  }
  private TransparentPanel createButtonPanel() {
    ExplorerButtonPanel explorerButton = new ExplorerButtonPanel();
    JButton editButton = explorerButton.getEditButton();
    JButton addButton = explorerButton.getAddButton();
    JButton deleteButton = explorerButton.getDeleteButton();

    editButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              int index = table.getSelectedRow();
              if (index < 0) return;

              index = table.convertRowIndexToModel(index);

              MenuItem menuItem = tableModel.getRow(index);
              menuItem = MenuItemDAO.getInstance().initialize(menuItem);

              tableModel.setRow(index, menuItem);

              MenuItemForm editor = new MenuItemForm(menuItem);
              BeanEditorDialog dialog = new BeanEditorDialog(editor);
              dialog.open();
              if (dialog.isCanceled()) return;

              table.repaint();
            } catch (Throwable x) {
              BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x);
            }
          }
        });

    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              MenuItemForm editor = new MenuItemForm();
              BeanEditorDialog dialog = new BeanEditorDialog(editor);
              dialog.open();
              if (dialog.isCanceled()) return;
              MenuItem foodItem = (MenuItem) editor.getBean();
              tableModel.addRow(foodItem);
            } catch (Throwable x) {
              BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x);
            }
          }
        });

    deleteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              int index = table.getSelectedRow();
              if (index < 0) return;

              index = table.convertRowIndexToModel(index);

              if (POSMessageDialog.showYesNoQuestionDialog(
                      MenuItemExplorer.this, POSConstants.CONFIRM_DELETE, POSConstants.DELETE)
                  != JOptionPane.YES_OPTION) {
                return;
              }
              MenuItem item = tableModel.getRow(index);
              MenuItemDAO foodItemDAO = new MenuItemDAO();
              foodItemDAO.delete(item);

              tableModel.removeRow(index);
            } catch (Throwable x) {
              BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x);
            }
          }
        });

    TransparentPanel panel = new TransparentPanel();
    panel.add(addButton);
    panel.add(editButton);
    panel.add(deleteButton);
    return panel;
  }