예제 #1
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   JComponent c =
       (JComponent)
           render.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
   c.setBorder(null);
   JCheckBox lab = new JCheckBox();
   ListElement le = (ListElement) value;
   // if("r1-print".equals(le.getCategory()))
   //
   // lab.setIcon(ResourceManager.getIcon(com.kingdee.bos.ctrl.report.forapp.kdnote.client.ui.NoteFileDialogEx.class, "res.r1_print.gif"));
   // else
   //
   // lab.setIcon(ResourceManager.getIcon(com.kingdee.bos.ctrl.report.forapp.kdnote.client.ui.NoteFileDialogEx.class, "res/empty.gif"));
   lab.setSelected(le.isSelected());
   lab.setOpaque(true);
   lab.setBackground(c.getBackground());
   TableLayout tl = TableLayout.splitCol(2);
   tl.colStyle(0).setWidth(22);
   tl.colStyle(1).setPriX(1);
   KDPanel pan = new KDPanel(tl);
   pan.add(lab, tl.cell(0));
   pan.add(c, tl.cell(1));
   return pan;
 }
 @Override
 public Component getTreeCellRendererComponent(
     JTree tree,
     Object value,
     boolean selected,
     boolean expanded,
     boolean leaf,
     int row,
     boolean hasFocus) {
   invalidate();
   final VirtualFile file = getFile(value);
   final DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
   if (file == null) {
     if (value instanceof DefaultMutableTreeNode) {
       final Object uo = node.getUserObject();
       if (uo instanceof String) {
         myColoredRenderer.getTreeCellRendererComponent(
             tree, value, selected, expanded, leaf, row, hasFocus);
         return myColoredRenderer;
       }
     }
     return myEmpty;
   }
   myCheckbox.setVisible(true);
   final TreeNodeState state = mySelectionManager.getState(node);
   myCheckbox.setEnabled(
       TreeNodeState.CLEAR.equals(state) || TreeNodeState.SELECTED.equals(state));
   myCheckbox.setSelected(!TreeNodeState.CLEAR.equals(state));
   myCheckbox.setOpaque(false);
   myCheckbox.setBackground(null);
   setBackground(null);
   myTextRenderer.getListCellRendererComponent(myFictive, file, 0, selected, hasFocus);
   revalidate();
   return this;
 }
예제 #3
0
 @Override
 public Component prepareEditor(TableCellEditor editor, int row, int column) {
   Component c = super.prepareEditor(editor, row, column);
   if (c instanceof JCheckBox) {
     ((JCheckBox) c).setBackground(getSelectionBackground());
   }
   return c;
 }
예제 #4
0
파일: Css.java 프로젝트: k9m/simplechat
  public static JCheckBox getCustomCheckBox() {
    JCheckBox component = new JCheckBox();
    component.setBackground(CUSTOMPANEL_TOP);

    component.setCursor(CURSOR);

    return component;
  }
    @NotNull
    @Override
    public Component getTableCellRendererComponent(
        @NotNull JTable table,
        Object value,
        boolean isSelected,
        boolean hasFocus,
        int row,
        int column) {
      myTable = table;
      myRow = row;
      myColumn = column;
      boolean isEnabled = true;
      final DefaultMutableTreeNode node =
          (DefaultMutableTreeNode)
              ((TreeTable) table).getTree().getPathForRow(row).getLastPathComponent();
      Option key = null;
      if (node instanceof MyTreeNode) {
        isEnabled = ((MyTreeNode) node).isEnabled();
        key = ((MyTreeNode) node).getKey();
      }
      if (!table.isEnabled()) {
        isEnabled = false;
      }

      Color background = table.getBackground();
      if (value instanceof Boolean) {
        myCheckBox.setSelected(((Boolean) value).booleanValue());
        myCheckBox.setBackground(background);
        myCheckBox.setEnabled(isEnabled);
        return myCheckBox;
      } else if (value instanceof String) {
        /*
        myComboBox.removeAllItems();
        myComboBox.addItem(value);
        */
        myComboBox.setText((String) value);
        myComboBox.setBackground(background);
        myComboBox.setEnabled(isEnabled);
        return myComboBox;
      } else if (value instanceof Integer) {
        if (key instanceof IntOption && ((IntOption) key).isDefaultValue(value)) {
          myIntLabel.setText(((IntOption) key).getDefaultValueText());
        } else {
          myIntLabel.setText(value.toString());
        }
        return myIntLabel;
      }

      myCheckBox.putClientProperty("JComponent.sizeVariant", "small");
      myComboBox.putClientProperty("JComponent.sizeVariant", "small");

      myEmptyLabel.setBackground(background);
      return myEmptyLabel;
    }
예제 #6
0
  void initComponents() {
    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f);
    buttonPanel.setBackground(bgColor);
    Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    buttonPanel.setBorder(empty);

    textField = new JTextField(75);
    buttonPanel.add(textField);

    buttonPanel.add(Box.createHorizontalStrut(10));
    searchPHI = new JButton("Search PHI");
    searchPHI.addActionListener(this);
    buttonPanel.add(searchPHI);

    buttonPanel.add(Box.createHorizontalStrut(10));
    searchTrial = new JButton("Search Trial IDs");
    searchTrial.addActionListener(this);
    buttonPanel.add(searchTrial);

    buttonPanel.add(Box.createHorizontalStrut(20));
    buttonPanel.add(Box.createHorizontalGlue());
    saveAs = new JCheckBox("Save As...");
    saveAs.setBackground(bgColor);
    buttonPanel.add(saveAs);

    mainPanel.add(buttonPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane();
    textPane = new ColorPane();
    // textPane.setEditable(false);
    scrollPane.setViewportView(textPane);
    mainPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel footerPanel = new JPanel();
    footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS));
    footerPanel.setBackground(bgColor);
    message = new JLabel("Ready...");
    footerPanel.add(message);
    mainPanel.add(footerPanel, BorderLayout.SOUTH);

    setTitle(windowTitle);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    pack();
    centerFrame();
  }
예제 #7
0
 public FooterPanel() {
   super();
   this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   this.setBackground(Color.getHSBColor(0.58f, 0.17f, 0.95f));
   subdirectories = new JCheckBox("Include subdirectories");
   subdirectories.setBackground(background);
   this.add(subdirectories);
   this.add(Box.createHorizontalGlue());
   extensionButton = new JButton(filter.getDescription());
   this.add(extensionButton);
   this.add(Box.createHorizontalStrut(17));
   extensionButton.addActionListener(this);
 }
    private MyCheckboxTreeCellRenderer(
        final SelectionManager selectionManager,
        Map<VirtualFile, String> modulesSet,
        final Project project,
        final JTree tree,
        final Collection<VirtualFile> roots) {
      super(new BorderLayout());
      mySelectionManager = selectionManager;
      myModulesSet = modulesSet;
      myRoots = roots;
      setBackground(tree.getBackground());
      myColoredRenderer =
          new ColoredTreeCellRenderer() {
            @Override
            public void customizeCellRenderer(
                JTree tree,
                Object value,
                boolean selected,
                boolean expanded,
                boolean leaf,
                int row,
                boolean hasFocus) {
              append(value.toString());
            }
          };
      myFictive = new JBList();
      myFictive.setBackground(tree.getBackground());
      myFictive.setSelectionBackground(UIUtil.getListSelectionBackground());
      myFictive.setSelectionForeground(UIUtil.getListSelectionForeground());

      myTextRenderer =
          new WithModulesListCellRenderer(project, myModulesSet) {
            @Override
            protected void putParentPath(Object value, FilePath path, FilePath self) {
              if (myRoots.contains(self.getVirtualFile())) {
                super.putParentPath(value, path, self);
              }
            }
          };
      myTextRenderer.setBackground(tree.getBackground());

      myCheckbox = new JCheckBox();
      myCheckbox.setBackground(tree.getBackground());
      myEmpty = new JLabel("");

      add(myCheckbox, BorderLayout.WEST);
      add(myTextRenderer, BorderLayout.CENTER);
      myCheckbox.setVisible(true);
    }
예제 #9
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   JCheckBox checkbox = (JCheckBox) value;
   if (!UIUtil.isUnderNimbusLookAndFeel()) {
     checkbox.setBackground(getBackground(isSelected, checkbox));
     checkbox.setForeground(getForeground(isSelected, checkbox));
   }
   checkbox.setEnabled(isEnabled());
   checkbox.setFont(getFont(checkbox));
   checkbox.setFocusPainted(false);
   checkbox.setBorderPainted(true);
   checkbox.setBorder(isSelected ? mySelectedBorder : myBorder);
   adjustRendering(checkbox, isSelected, cellHasFocus);
   return checkbox;
 }
    @NotNull
    @Override
    public Component getTableCellRendererComponent(
        @NotNull JTable table,
        Object value,
        boolean isSelected,
        boolean hasFocus,
        int row,
        int column) {
      final RegistryValue v = ((MyTableModel) table.getModel()).getRegistryValue(row);
      myLabel.setIcon(null);
      myLabel.setText(null);
      myLabel.setHorizontalAlignment(SwingConstants.LEFT);
      Color fg = isSelected ? table.getSelectionForeground() : table.getForeground();
      Color bg = isSelected ? table.getSelectionBackground() : table.getBackground();

      if (v != null) {
        switch (column) {
          case 0:
            myLabel.setIcon(v.isRestartRequired() ? RESTART_ICON : null);
            myLabel.setHorizontalAlignment(SwingConstants.CENTER);
            break;
          case 1:
            myLabel.setText(v.getKey());
            break;
          case 2:
            if (v.asColor(null) != null) {
              myLabel.setIcon(createColoredIcon(v.asColor(null)));
            } else if (v.isBoolean()) {
              final JCheckBox box = new JCheckBox();
              box.setSelected(v.asBoolean());
              box.setBackground(bg);
              return box;
            } else {
              myLabel.setText(v.asString());
            }
        }

        myLabel.setOpaque(true);

        myLabel.setFont(
            myLabel.getFont().deriveFont(v.isChangedFromDefault() ? Font.BOLD : Font.PLAIN));
        myLabel.setForeground(fg);
        myLabel.setBackground(bg);
      }

      return myLabel;
    }
예제 #11
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    getModel().setRollover(highlighter.isHighlightableCell(row, column));

    if (isSelected) {
      setForeground(table.getSelectionForeground());
      super.setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
      // setBackground(row % 2 == 0 ? table.getBackground() : Color.WHITE); //Nimbus
    }
    setSelected(Objects.equals(value, Boolean.TRUE));
    return this;
  }
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   if (containerBox == null) {
     containerBox = Box.createHorizontalBox();
     checkBox = new JCheckBox();
     checkBox.setEnabled(isEnabled());
     checkBox.setFont(getFont());
     checkBox.setFocusPainted(false);
     checkBox.setBorderPainted(true);
     checkBox.setBorder(
         isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
     containerBox.add(checkBox);
   }
   checkBox.setBackground(isSelected ? getSelectionBackground() : getBackground());
   checkBox.setForeground(isSelected ? getSelectionForeground() : getForeground());
   if (value != null) {
     ListItem item = (ListItem) value;
     checkBox.setText(item.dataItem.toString());
     checkBox.setSelected(item.selected);
   }
   return containerBox;
 }
예제 #13
0
 @Nullable
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   myValue = ((MyTableModel) table.getModel()).getRegistryValue(row);
   if (myValue.asColor(null) != null) {
     final Color color =
         ColorChooser.chooseColor(
             table, "Choose color", ((RegistryValue) value).asColor(Color.WHITE));
     if (color != null) {
       myValue.setValue(color.getRed() + "," + color.getGreen() + "," + color.getBlue());
     }
     return null;
   } else if (myValue.isBoolean()) {
     myCheckBox.setSelected(myValue.asBoolean());
     myCheckBox.setBackground(table.getBackground());
     return myCheckBox;
   } else {
     myField.setText(myValue.asString());
     myField.setBorder(null);
     myField.selectAll();
     return myField;
   }
 }
  @Override
  public void actionPerformed(ActionEvent e) {
    final JFrame enableProtectorFrame = new JFrame("Enable Protector Bricks");
    enableProtectorFrame.setBackground(Color.DARK_GRAY);
    ImageIcon img = new ImageIcon("icons/software_logo.png");
    Image imag = img.getImage();
    enableProtectorFrame.setIconImage(imag);
    enableProtectorFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    JPanel mainPanel = new JPanel();
    mainPanel.setBackground(Color.DARK_GRAY);
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints dimensionFrameGridBagConstraints = new GridBagConstraints();
    dimensionFrameGridBagConstraints.insets = new Insets(3, 3, 3, 3);
    JLabel enableProtectorLabel =
        new JLabel("<html><style>h4{color:white;}</style><h4>Enable Protector Bricks</h4></html>");

    Icon minZProtectorCubeIcon = new ImageIcon("icons/minZProtectorCubeIcon.png");
    JLabel minZProtectorCubeIconLabel = new JLabel("", minZProtectorCubeIcon, JLabel.LEFT);
    final JCheckBox zMinPlaneProtectorCheckbox =
        new JCheckBox("<html><style>h4{color:white;}</style><h4>Min-Z Plane</h4></html>");
    zMinPlaneProtectorCheckbox.setBackground(Color.DARK_GRAY);
    if (MainFrame.isMinZProtectorPlaneEnabled) zMinPlaneProtectorCheckbox.setSelected(true);

    Icon maxZBoundaryCubeIcon = new ImageIcon("icons/maxZProtectorCubeIcon.png");
    JLabel maxZProtectorCubeIconLabel = new JLabel("", maxZBoundaryCubeIcon, JLabel.LEFT);
    final JCheckBox zMaxPlaneProtectorCheckbox =
        new JCheckBox("<html><style>h4{color:white;}</style><h4>Max-Z Plane</h4></html>");
    zMaxPlaneProtectorCheckbox.setBackground(Color.DARK_GRAY);
    if (MainFrame.isMaxZProtectorPlaneEnabled) zMaxPlaneProtectorCheckbox.setSelected(true);

    JButton okButton = new JButton("OK");
    okButton.setBackground(Color.DARK_GRAY);

    dimensionFrameGridBagConstraints.gridx = 0;
    dimensionFrameGridBagConstraints.gridy = 0;
    mainPanel.add(enableProtectorLabel, dimensionFrameGridBagConstraints);
    dimensionFrameGridBagConstraints.gridx = 0;
    dimensionFrameGridBagConstraints.gridy = 1;
    mainPanel.add(zMinPlaneProtectorCheckbox, dimensionFrameGridBagConstraints);
    dimensionFrameGridBagConstraints.gridx = 1;
    dimensionFrameGridBagConstraints.gridy = 1;
    mainPanel.add(minZProtectorCubeIconLabel, dimensionFrameGridBagConstraints);
    dimensionFrameGridBagConstraints.gridx = 0;
    dimensionFrameGridBagConstraints.gridy = 2;
    mainPanel.add(zMaxPlaneProtectorCheckbox, dimensionFrameGridBagConstraints);
    dimensionFrameGridBagConstraints.gridx = 1;
    dimensionFrameGridBagConstraints.gridy = 2;
    mainPanel.add(maxZProtectorCubeIconLabel, dimensionFrameGridBagConstraints);
    dimensionFrameGridBagConstraints.gridx = 0;
    dimensionFrameGridBagConstraints.gridy = 3;
    mainPanel.add(okButton, dimensionFrameGridBagConstraints);

    enableProtectorFrame.add(mainPanel, BorderLayout.CENTER);
    enableProtectorFrame.pack();
    enableProtectorFrame.setVisible(true);
    enableProtectorFrame.setLocation(MainFrame.screenWidth / 3, MainFrame.screenHeight / 4);

    zMaxPlaneProtectorCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (zMaxPlaneProtectorCheckbox.isSelected() == true) {
              IdentifyBoundaryAndProtectorBricks identifyMaxZProtector =
                  new IdentifyBoundaryAndProtectorBricks('p');
              Appearance ap = new Appearance();
              TransparencyAttributes transparencyAttributes =
                  new TransparencyAttributes(TransparencyAttributes.NICEST, 0.7f);
              ColoringAttributes coloringAttributes =
                  new ColoringAttributes(new Color3f(1.0f, 1.0f, 0.0f), ColoringAttributes.NICEST);
              ap.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
              ap.setTransparencyAttributes(transparencyAttributes);
              ap.setColoringAttributes(coloringAttributes);
              for (int j = 0; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
                x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
                y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
                z = CanvasActionListener.colorCubeArrayList.get(j).zCord;

                if (identifyMaxZProtector.voxelList.get(identifyMaxZProtector.ivalue[x][y][z])
                    .isTailBrick) {
                  DNAColorCube pickedCube =
                      CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
                  pickedCube.setAppearance(ap);
                }
              }
            } else {
              IdentifyBoundaryAndProtectorBricks identifyMaxZProtector =
                  new IdentifyBoundaryAndProtectorBricks('p');
              Appearance ap = new Appearance();
              for (int j = 0; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
                x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
                y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
                z = CanvasActionListener.colorCubeArrayList.get(j).zCord;

                if (identifyMaxZProtector.voxelList.get(identifyMaxZProtector.ivalue[x][y][z])
                    .isTailBrick) {
                  DNAColorCube pickedCube =
                      CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
                  pickedCube.setAppearance(ap);
                }
              }
            }
          }
        });

    zMinPlaneProtectorCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (zMinPlaneProtectorCheckbox.isSelected() == true) {
              IdentifyBoundaryAndProtectorBricks identifyMinZProtector =
                  new IdentifyBoundaryAndProtectorBricks('p');
              Appearance ap = new Appearance();
              TransparencyAttributes transparencyAttributes =
                  new TransparencyAttributes(TransparencyAttributes.NICEST, 0.7f);
              ColoringAttributes coloringAttributes =
                  new ColoringAttributes(new Color3f(1.0f, 0.0f, 0.0f), ColoringAttributes.NICEST);
              ap.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
              ap.setTransparencyAttributes(transparencyAttributes);
              ap.setColoringAttributes(coloringAttributes);
              for (int j = 0; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
                x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
                y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
                z = CanvasActionListener.colorCubeArrayList.get(j).zCord;

                if (identifyMinZProtector.voxelList.get(identifyMinZProtector.ivalue[x][y][z - 1])
                    .isHeadBrick) {
                  DNAColorCube pickedCube =
                      CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
                  pickedCube.setAppearance(ap);
                }
              }
            } else {
              IdentifyBoundaryAndProtectorBricks identifyMinZProtector =
                  new IdentifyBoundaryAndProtectorBricks('p');
              Appearance ap = new Appearance();
              for (int j = 0; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
                x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
                y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
                z = CanvasActionListener.colorCubeArrayList.get(j).zCord;

                if (identifyMinZProtector.voxelList.get(identifyMinZProtector.ivalue[x][y][z - 1])
                    .isHeadBrick) {
                  DNAColorCube pickedCube =
                      CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
                  pickedCube.setAppearance(ap);
                }
              }
            }
          }
        });

    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (zMaxPlaneProtectorCheckbox.isSelected() == true) {
              MainFrame.isMaxZProtectorPlaneEnabled = true;
              MainFrame.printLog("Protector bricks enabled in Maximum Z ", Color.CYAN);
            } else {
              MainFrame.isMaxZProtectorPlaneEnabled = false;
            }
            if (zMinPlaneProtectorCheckbox.isSelected() == true) {
              MainFrame.isMinZProtectorPlaneEnabled = true;
              MainFrame.printLog("Protector bricks enabled in Minimum Z ", Color.CYAN);
            } else {
              MainFrame.isMinZProtectorPlaneEnabled = false;
            }
            MainFrame.isCSVSaved = false;
            MainFrame.isPDFSaved = false;
            MainFrame.isCSVBoundarySaved = false;
            MainFrame.isPDFBoundarySaved = false;
            switchToOriginalColor();
            enableProtectorFrame.dispose();
          }
        });

    enableProtectorFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    enableProtectorFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosed(WindowEvent e) {
            switchToOriginalColor();
          }
        });
  }
예제 #15
0
  public TaskList() {
    GridBagLayout layout = new GridBagLayout();
    this.setLayout(layout);
    this.setBackground(Color.BLACK);

    taskListLabel = new JLabel("Task List");
    taskListLabel.setHorizontalAlignment(SwingConstants.HORIZONTAL);
    taskListLabel.setForeground(Color.WHITE);

    newTaskTextField = new JTextField();

    addButton = new JButton("Add task");
    deleteButton = new JButton("Change completeness");
    refreshButton = new JButton("Refresh");

    deleteCompletedButton = new JButton("Delete completed tasks");

    deleteButton.setBackground(Color.BLACK);
    deleteButton.setForeground(Color.ORANGE);
    deleteCompletedButton.setBackground(Color.BLACK);
    deleteCompletedButton.setForeground(Color.RED);
    addButton.setBackground(Color.BLACK);
    addButton.setForeground(Color.GREEN);
    refreshButton.setBackground(Color.BLACK);
    refreshButton.setForeground(Color.GREEN);

    completedCheckBox = new JCheckBox("Show completed tasks");
    notCompletedCheckBox = new JCheckBox("Show not completed tasks");
    completedCheckBox.setBackground(Color.BLACK);
    completedCheckBox.setForeground(Color.WHITE);
    notCompletedCheckBox.setBackground(Color.BLACK);
    notCompletedCheckBox.setForeground(Color.WHITE);
    notCompletedCheckBox.setSelected(true);

    taskTableModel = new TaskTableModel();
    taskTableView = new TaskTableView(taskTableModel);

    taskTableModel.refresh(2);

    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (newTaskTextField.getText().equals("")) {
              JOptionPane.showMessageDialog(null, "No text in the field! Write something...");
            } else {
              Date date = new Date();
              String dateString = date.toString();
              String task = newTaskTextField.getText();
              try {
                taskTableModel.add(dateString, task, false);
              } catch (FileNotFoundException e1) {
                e1.printStackTrace();
              }
              newTaskTextField.setText("");
            }
          }
        });

    deleteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int pos = taskTableView.getSelectedRow();
            if (pos > -1) {
              try {
                taskTableModel.delete(pos);
              } catch (FileNotFoundException e1) {
                e1.printStackTrace();
              }
            }
          }
        });

    deleteCompletedButton.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              taskTableModel.deleteCompleted();
            } catch (FileNotFoundException e1) {
              e1.printStackTrace();
            }
          }
        });

    refreshButton.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int count = 0;
            if ((completedCheckBox.isSelected()) && (notCompletedCheckBox.isSelected())) {
              count = 3;
            }
            if ((!completedCheckBox.isSelected()) && (notCompletedCheckBox.isSelected())) {
              count = 2;
            }
            if ((completedCheckBox.isSelected()) && (!notCompletedCheckBox.isSelected())) {
              count = 1;
            }
            if ((!completedCheckBox.isSelected()) && (!notCompletedCheckBox.isSelected())) {
              count = 0;
            }
            taskTableModel.refresh(count);
          }
        });

    this.add(
        taskListLabel,
        new GridBagConstraints(
            0,
            0,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
    this.add(
        taskTableView,
        new GridBagConstraints(
            0,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
    this.add(
        completedCheckBox,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
    this.add(
        notCompletedCheckBox,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
    this.add(
        refreshButton,
        new GridBagConstraints(
            2,
            2,
            GridBagConstraints.REMAINDER,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
    this.add(
        deleteButton,
        new GridBagConstraints(
            0,
            3,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
    this.add(
        deleteCompletedButton,
        new GridBagConstraints(
            0,
            4,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
    this.add(
        newTaskTextField,
        new GridBagConstraints(
            0,
            5,
            2,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
    this.add(
        addButton,
        new GridBagConstraints(
            3,
            5,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));
  }
예제 #16
0
 public CBRow(String name, boolean checked) {
   label = new RowLabel(name);
   cb = new JCheckBox();
   cb.setBackground(bgColor);
   cb.setSelected(checked);
 }
예제 #17
0
  private void makeMenuScreen() {
    menu = new JPanel();
    menu.setBackground(Color.BLACK);
    menu.setLayout(null);
    menu.setBounds(0, 0, width, height);

    try {
      BufferedImage menuIMG =
          ImageIO.read(this.getClass().getResource("/Resources/MenuBackground.png"));
      // BufferedImage menuIMG = ImageIO.read(new
      // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/MenuBackground.png"));
      menuIMGL =
          new JLabel(
              new ImageIcon(
                  menuIMG.getScaledInstance(
                      (int) (width * 0.8), (int) (height * 0.8), Image.SCALE_SMOOTH)));
      menuIMGL.setBounds(0, 0, width, height);
    } catch (Exception e) {
    }

    highscoreL = new JLabel(String.valueOf(highscore));
    highscoreL.setBackground(Color.darkGray);
    highscoreL.setBounds((width / 2) + 100, (height / 2) + 70, 500, 100);
    highscoreL.setForeground(Color.white);

    easy = new JButton("Easy");
    hard = new JButton("Hard");

    easy.addActionListener(this);
    hard.addActionListener(this);

    easy.setBounds((width / 2) - 60, (height / 2) - 50, 120, 20);
    hard.setBounds((width / 2) - 60, height / 2 - 10, 120, 20);

    onePlayerRB = new JRadioButton("One Player");
    twoPlayerRB = new JRadioButton("Two Player");
    mouseRB = new JRadioButton("Mouse (Player 1)");
    keyboardRB = new JRadioButton("Keyboard (Player 1)");
    keyboardSpeedS1 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50);
    keyboardSpeedS2 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50);
    musicCB = new JCheckBox("Music");

    onePlayerRB.setBackground(null);
    twoPlayerRB.setBackground(null);
    mouseRB.setBackground(null);
    keyboardRB.setBackground(null);
    keyboardSpeedS1.setBackground(null);
    keyboardSpeedS2.setBackground(null);
    musicCB.setBackground(null);

    onePlayerRB.setForeground(Color.WHITE);
    twoPlayerRB.setForeground(Color.WHITE);
    mouseRB.setForeground(Color.WHITE);
    keyboardRB.setForeground(Color.WHITE);
    keyboardSpeedS1.setForeground(Color.WHITE);
    keyboardSpeedS2.setForeground(Color.WHITE);
    musicCB.setForeground(Color.WHITE);

    ButtonGroup playerChoice = new ButtonGroup();
    playerChoice.add(onePlayerRB);
    playerChoice.add(twoPlayerRB);
    onePlayerRB.setSelected(true);

    ButtonGroup peripheralChoice = new ButtonGroup();
    peripheralChoice.add(mouseRB);
    peripheralChoice.add(keyboardRB);
    mouseRB.setSelected(true);

    musicCB.setSelected(true);

    onePlayerRB.setBounds((width / 2) + 100, (height / 2) - 50, 100, 20);
    twoPlayerRB.setBounds((width / 2) + 100, (height / 2) - 30, 100, 20);
    mouseRB.setBounds((width / 2) + 100, (height / 2), 200, 20);
    keyboardRB.setBounds((width / 2) + 100, (height / 2) + 20, 200, 20);
    keyboardSpeedS1.setBounds(width / 2 - 120, height / 2 + 100, 200, 50);
    keyboardSpeedS2.setBounds(width / 2 - 120, height / 2 + 183, 200, 50);
    musicCB.setBounds((width / 2) + 100, (height / 2) + 50, 100, 20);

    keyboardSpeedL1 = new JLabel("Keyboard Speed (Player One)");
    keyboardSpeedL1.setForeground(Color.WHITE);
    keyboardSpeedL1.setBounds(width / 2 - 113, height / 2 + 67, 200, 50);

    keyboardSpeedL2 = new JLabel("Keyboard Speed (Player Two)");
    keyboardSpeedL2.setForeground(Color.WHITE);
    keyboardSpeedL2.setBounds(width / 2 - 113, height / 2 + 150, 200, 50);

    howTo = new JButton("How To Play");
    howTo.addActionListener(this);
    howTo.setBounds((width / 2) - 60, height / 2 + 30, 120, 20);

    try {
      BufferedImage howToIMG = ImageIO.read(this.getClass().getResource("/Resources/HowTo.png"));
      // BufferedImage howToIMG = ImageIO.read(new
      // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/HowTo.png"));
      howToIMGL = new JLabel(new ImageIcon(howToIMG));
      howToIMGL.setBounds(
          width / 2 - howToIMG.getWidth() / 2,
          height / 2 - howToIMG.getHeight() / 2,
          howToIMG.getWidth(),
          howToIMG.getHeight());
    } catch (Exception e) {
    }

    howToBack = new JButton("X");
    howToBack.setBounds(
        (int) (width / 2 + width * 0.25) - 50, (int) (height / 2 - height * 0.25), 50, 50);
    howToBack.setBackground(Color.BLACK);
    howToBack.setForeground(Color.WHITE);
    howToBack.addActionListener(this);

    menu.add(easy);
    menu.add(hard);
    menu.add(howTo);
    menu.add(highscoreL);
    menu.add(onePlayerRB);
    menu.add(twoPlayerRB);
    menu.add(mouseRB);
    menu.add(keyboardRB);
    menu.add(keyboardSpeedL1);
    menu.add(keyboardSpeedL2);
    menu.add(keyboardSpeedS1);
    menu.add(keyboardSpeedS2);
    menu.add(musicCB);
    menu.add(menuIMGL);

    back = new JButton("Back");
    back.setBounds(width / 2 - 40, height / 2, 100, 20);
    back.addActionListener(this);
    back.setVisible(false);
    this.add(back);
  }