public static void deSelect(JPanel layer) {

    Component[] components = layer.getComponents();
    int i = 0;
    while (i < components.length) {

      if (components[i].getClass().getName().equals("javax.swing.JLabel")) {
        if (components[i].getBackground().equals(SELECT)) {
          JLabel temp = (JLabel) components[i];
          temp.setOpaque(false);
          components[i].setBackground(DESELECT);
        }
      }

      if (components[i].getClass().getName().equals("Display.TextBox")) {
        if (components[i].getBackground().equals(SELECT)) {
          components[i].setBackground(DESELECT);
        }
      }

      // If panel is selected, de-select all components nested on panel
      if (components[i].getClass().getName().equals("javax.swing.JPanel")) {
        if (components[i].getBackground().equals(SELECT)) {
          components[i].setBackground(DESELECT);
        }
        deSelect((JPanel) components[i]);
      }

      i++;
    }
  }
 public Collection<String> getSelectedTracks() {
   List<String> selectedTracks = new ArrayList<String>();
   for (Component c : listPanel.getComponents()) {
     if (c instanceof JCheckBox && ((JCheckBox) c).isSelected()) {
       selectedTracks.add(((JCheckBox) c).getText());
     }
   }
   return selectedTracks;
 }
 /** Reloads icon. */
 public void loadSkin() {
   if (messagePanel != null) {
     for (Component component : messagePanel.getComponents()) {
       if (component instanceof ImageCanvas) {
         ImageCanvas cmp = (ImageCanvas) component;
         cmp.setImage(ImageLoader.getImage(ImageLoader.RENAME_DIALOG_ICON));
       }
     }
   }
 }
示例#4
0
 /**
  * method to check whether a mouse click was over an icon
  *
  * @param p
  * @return
  */
 private Component getImageLabel(Point p) {
   Rectangle r1 = activePanel.getBounds();
   Rectangle r;
   Component[] c = activePanel.getComponents();
   for (int j = 0; j < c.length; j++) {
     r = c[j].getBounds();
     if (r.contains(p.x - r1.x, p.y - r1.y)) return c[j];
   }
   return null;
 }
示例#5
0
 public void actionPerformed(ActionEvent e) {
   String command = e.getActionCommand();
   if (command.startsWith("start")) {
     discard_all = true;
   } else if (command.startsWith("stop")) {
     discard_all = false;
     Component[] comps = checkboxes.getComponents();
     for (Component c : comps) {
       if (c instanceof JCheckBox) {
         ((JCheckBox) c).setSelected(false);
       }
     }
     ignoredMembers.clear();
   }
 }
示例#6
0
    void handleView(Collection<Address> mbrs) {
      checkboxes.removeAll();
      for (final Address addr : mbrs) {
        final MyCheckBox box = new MyCheckBox("discard traffic from " + addr, addr);
        box.addActionListener(
            e -> {
              if (box.isSelected()) ignoredMembers.add(addr);
              else ignoredMembers.remove(addr);
            });
        checkboxes.add(box);
      }

      for (Component comp : checkboxes.getComponents()) {
        MyCheckBox box = (MyCheckBox) comp;
        if (ignoredMembers.contains(box.mbr)) box.setSelected(true);
      }
      pack();
    }
示例#7
0
  /** Creating buttons with coordinates and action listeners */
  private MyButton createButton() {
    // The new buttons counters -
    // will be translates to coordinates
    if (counterX >= size) {
      counterX = 0;
      counterY++;
    }

    MyButton button = new MyButton();

    // set buttons coordinates
    button.x = counterX++;
    button.y = counterY;

    // The buttons properties adjustment
    button.setPreferredSize(new Dimension(50, 50));
    button.setFont(new Font("Dialog", Font.PLAIN, 72));

    // Action listener
    button.addActionListener(
        e -> {
          game.move(new Move(button.x, button.y));
          game.isGameOver();
          button.setText(game.getField()[button.x][button.y] > 0 ? "X" : "O");
          button.setEnabled(false);
          statusStr.setText(game.getState().toString());

          // If the game is over
          // disable all unselected buttons
          if (game.getState().equals(GameState.X_WINS)
              || game.getState().equals(GameState.O_WINS)) {

            for (Component b : gameField.getComponents()) {
              b.setEnabled(false);
            }
          }
        });

    // System.out.println("button " + button.x + " " + button.y);

    return button;
  }
  private JPanel getMixerOptionsPanel() {
    if (mixerOptionsPanel == null) {
      mixerOptionsPanel = new JPanel();
      mixerOptionsPanel.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Mixer"));

      mixerOptionsPanel.setLayout(new GridBagLayout());
      GridBagConstraints c = new GridBagConstraints();

      c.anchor = GridBagConstraints.NORTHWEST;
      c.fill = GridBagConstraints.NONE;
      c.weightx = 1;

      c.insets = new Insets(8, 4, 0, 0);
      mixerOptionsPanel.add(new JLabel("Select mixer:"), c);

      c.gridy = 1;
      mixerOptionsPanel.add(getMixerComboBox(), c);

      c.gridy = 2;
      mixerOptionsPanel.add(getMixerDefaultButton(), c);

      c.insets = new Insets(16, 4, 0, 0);
      c.gridy = 3;
      mixerOptionsPanel.add(new JLabel("Enable mixer features:"), c);

      c.insets = new Insets(6, 0, 0, 0);
      c.gridy = 4;
      mixerOptionsPanel.add(getEnableMixerVolumeCheckBox(), c);

      c.insets = new Insets(0, 0, 0, 0);
      c.gridy = 5;
      mixerOptionsPanel.add(getEnableMixerPanCheckBox(), c);

      if (AudioSystem.getMixerInfo().length == 0) {
        for (Component child : mixerOptionsPanel.getComponents()) {
          child.setEnabled(false);
        }
      }
    }
    return mixerOptionsPanel;
  }
  private JPanel getSoundOptionsPanel() {
    if (soundOptionsPanel == null) {
      soundOptionsPanel = new JPanel();
      soundOptionsPanel.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Sound Effects"));

      soundOptionsPanel.setLayout(new GridBagLayout());
      GridBagConstraints c = new GridBagConstraints();

      c.fill = 1;
      c.weightx = 1;
      c.anchor = GridBagConstraints.NORTHWEST;

      c.gridwidth = GridBagConstraints.REMAINDER;
      soundOptionsPanel.add(getEnableSoundCheckBox(), c);
      soundOptionsPanel.add(getEnableGunshotCheckBox(), c);
      soundOptionsPanel.add(getEnableBulletHitCheckBox(), c);
      soundOptionsPanel.add(getEnableRobotDeathCheckBox(), c);
      soundOptionsPanel.add(getEnableWallCollisionCheckBox(), c);
      soundOptionsPanel.add(getEnableRobotCollisionCheckBox(), c);

      c.insets = new Insets(10, 0, 0, 10);
      c.gridwidth = 1;
      c.fill = 0;
      c.weighty = 1;
      c.weightx = 0;
      soundOptionsPanel.add(getEnableAllSoundsButton(), c);
      c.weightx = 1;
      c.gridwidth = GridBagConstraints.REMAINDER;
      soundOptionsPanel.add(getDisableAllSoundsButton(), c);

      if (AudioSystem.getMixerInfo().length == 0) {
        for (Component child : soundOptionsPanel.getComponents()) {
          child.setEnabled(false);
        }
      }
    }
    return soundOptionsPanel;
  }
示例#10
0
  public SwingUpdaterUI(String oldBuildDesc, String newBuildDesc, InstallOperation operation) {
    myOperation = operation;

    myProcessTitle = new JLabel(" ");
    myProcessProgress = new JProgressBar(0, 100);
    myProcessStatus = new JLabel(" ");

    myCancelButton = new JButton(CANCEL_BUTTON_TITLE);

    myConsole = new JTextArea();
    myConsole.setLineWrap(true);
    myConsole.setWrapStyleWord(true);
    myConsole.setCaretPosition(myConsole.getText().length());
    myConsole.setTabSize(1);
    myConsolePane = new JPanel(new BorderLayout());
    myConsolePane.add(new JScrollPane(myConsole));
    myConsolePane.setBorder(BUTTONS_BORDER);
    myConsolePane.setVisible(false);

    myCancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doCancel();
          }
        });

    myFrame = new JFrame();
    myFrame.setTitle(TITLE);

    myFrame.setLayout(new BorderLayout());
    myFrame.getRootPane().setBorder(FRAME_BORDER);
    myFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    myFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            doCancel();
          }
        });

    JPanel processPanel = new JPanel();
    processPanel.setLayout(new BoxLayout(processPanel, BoxLayout.Y_AXIS));
    processPanel.add(myProcessTitle);
    processPanel.add(myProcessProgress);
    processPanel.add(myProcessStatus);

    processPanel.add(myConsolePane);
    for (Component each : processPanel.getComponents()) {
      ((JComponent) each).setAlignmentX(Component.LEFT_ALIGNMENT);
    }

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setBorder(BUTTONS_BORDER);
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(myCancelButton);

    myProcessTitle.setText("<html>Updating " + oldBuildDesc + " to " + newBuildDesc + "...");

    myFrame.add(processPanel, BorderLayout.CENTER);
    myFrame.add(buttonsPanel, BorderLayout.SOUTH);

    myFrame.setMinimumSize(new Dimension(500, 50));
    myFrame.pack();
    myFrame.setLocationRelativeTo(null);

    myFrame.setVisible(true);

    myQueue.add(
        new UpdateRequest() {
          @Override
          public void perform() {
            doPerform();
          }
        });

    startRequestDispatching();
  }
 private void setEnableStatusOfComponentsOfPanel(JPanel parentPanel, boolean enableStatus) {
   Component[] components = parentPanel.getComponents();
   for (Component component : components) {
     component.setEnabled(enableStatus);
   }
 }
示例#12
0
  @Override
  public void actionPerformed(ActionEvent actionEvent) {
    Object obj = actionEvent.getSource();

    if (obj == btFindPat) {

      testpanel.removeAll();
      validate();
      repaint();
      if (taDictionary.getText().isEmpty()) {
        JOptionPane.showMessageDialog(
            frame, "Please load words so they appear in Text Area before Finding Path. ");

      } else if ((tfSourc.getText().isEmpty()) || (tfSourc_6.getText().isEmpty())) {
        JOptionPane.showMessageDialog(
            frame, "Please enter Source and Destination words before Finding Path. ");
      } else if (testpanel.getComponents().length != 0) {
        JOptionPane.showMessageDialog(frame, "Please clear results before continuing.");
      } else {
        wordLadder.findPath(
            tfSourc.getText(), tfSourc_6.getText(), Integer.parseInt(tfWordSize.getText()));
        lblFindPat.setText(
            "Time to find Path: " + String.valueOf(wordLadder.getTimeForPath()) + " milliseconds");
        lblCos.setText("Cost of Path: " + String.valueOf(wordLadder.g.getCost()));
        results = wordLadder.getResults();
        Collections.reverse(results);
        int x = 10;
        int y = 20;

        for (String s : results) {
          x += 20;
          y += 20;
          JLabel _lbl = new JLabel(s);
          _lbl.setLocation(x, y);
          _lbl.setSize(100, 26);

          if (results.indexOf(s) == 0) {
            _lbl.setForeground(new Color(-14646771));
          } else if (results.indexOf(s) == (results.size() - 1)) {
            _lbl.setForeground(new Color(-8254711));
          } else {
            _lbl.setForeground(new Color(-16777216));
          }
          testpanel.add(_lbl);
          testpanel.repaint();
        }
        if (wordLadder.g.getCost() == 0) {
          // if (wordLadder.g.getGraphError() != null){
          JLabel _lbl = new JLabel(wordLadder.g.getGraphError());
          _lbl.setLocation(x, y);
          _lbl.setSize(100, 26);
          testpanel.add(_lbl);
          testpanel.repaint();
          // }

        }
      }
      /*if (taDictionary.getText().isEmpty()){
      wordLadder = new WordLadder(tfFilePat.getText(), tfSourc.getText(), tfSourc_6.getText());
       }else if (!taDictionary.getText().isEmpty()){
          ArrayList<String> taList = new ArrayList<String>();
          StringTokenizer stringTokenizer = new StringTokenizer(taDump, "\t\n\r\f,\"");
          while (stringTokenizer.hasMoreTokens()) {
              String token = stringTokenizer.nextToken();
              taList.add(token);
          }
        */
      // }
    }

    if (obj == btLoadFil) {
      clearData();
      // wordLadder.setWords_size(Integer.parseInt(tfWordSize.getText()));
      // String size = tfWordSize.getText();
      // int intSize = Integer.parseInt(size);
      // WordLadderGUI.showMessage("Loading words of" + tfWordSize.getText() + " characters from
      // file: " + tfFilePat.getText(), Color.GREEN, Color.GREEN);
      lblIndexing1.setText("Indexing...");
      System.out.println(
          "Loading words of "
              + tfWordSize.getText()
              + " characters from file: "
              + tfFilePat.getText());
      wordLadder = new WordLadder(tfFilePat.getText(), Integer.parseInt(tfWordSize.getText()));
      // wordLadder.
      guiDictionary = new WordCollection(wordLadder.getWordList());
      WordLadderGUI.showMessage(
          "Displaying "
              + wordLadder.getWordList().size()
              + " words from file with length of "
              + tfWordSize.getText(),
          Color.GREEN,
          Color.GREEN);
      System.out.println(
          "Displaying "
              + wordLadder.getWordList().size()
              + " words from file with length of "
              + tfWordSize.getText());
      taDictionary.setText(guiDictionary.toString());
      lblIndexing1.setText("Indexing... done.");
      lblDictCoun.setText("Words in Dictionary = " + wordLadder.getWordList().size() + " words");
      wordLadder.buildGraph();
      System.out.println("Graph Built");
      lblProgres.setText("Time to Build Graph: " + wordLadder.getTimeForGraph() + " milliseconds");
    }

    if (obj == btLoadTextFiel) {
      wordLadder.setWords_size(Integer.parseInt(tfWordSize.getText()));
      String taDump = taDictionary.getText();
      System.out.println("Loading Words from Text Area");
      lblIndexing1.setText("Indexing...");
      ArrayList<String> taList = new ArrayList<String>();
      StringTokenizer stringTokenizer = new StringTokenizer(taDump, "\t\n\r\f,\"");
      while (stringTokenizer.hasMoreTokens()) {
        String token = stringTokenizer.nextToken();
        taList.add(token);
      }
      guiDictionary = new WordCollection();
      guiDictionary.setWords(taList);
      wordLadder = new WordLadder(taList);
      WordLadderGUI.showMessage(
          "Loading " + wordLadder.getWordList().size() + " words from Text Field",
          Color.GREEN,
          Color.GREEN);
      lblIndexing1.setText("Indexing... done.");
      lblDictCoun.setText("Words in Dictionary = " + wordLadder.getWordList().size() + " words");
      wordLadder.buildGraph();
      System.out.println("Graph Built");
      lblProgres.setText("Time to Build Graph: " + wordLadder.getTimeForGraph() + " milliseconds");
    }
    if (obj == btClear) {
      testpanel.removeAll();
      testpanel.validate();
      testpanel.repaint();
      wordLadder = null;
      lblCos.setText("Cost of Path: 0.0");
      lblCos.repaint();
      lblDictCoun.setText("Words in Dictionary = 0 words");
      lblFindPat.setText("Time to find Path: 0 milliseconds");
      tfSourc.setText("");
      tfSourc_6.setText("");
      taDictionary.setText("");
      results = null;
      lblProgres.setText("Time to Build Graph: 0 milliseconds");
    }
  }
  public CustomizePluginsStepPanel() {
    myCardLayout = new JBCardLayout();
    setLayout(myCardLayout);
    JPanel gridPanel = new JPanel(new GridLayout(0, COLS));
    myCustomizePanel = new IdSetPanel();
    JBScrollPane scrollPane =
        new JBScrollPane(
            gridPanel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    add(scrollPane, MAIN);
    add(myCustomizePanel, CUSTOMIZE);

    // PluginManager.loadDisabledPlugins(new File(PathManager.getConfigPath()).getPath(),
    // myDisabledPluginIds);
    // for (IdeaPluginDescriptor pluginDescriptor : myAllPlugins) {
    //  if (pluginDescriptor.getPluginId().getIdString().equals("com.intellij")) {
    ////    skip 'IDEA CORE' plugin
    // continue;
    // }
    //  //PluginManager.initClassLoader(PluginGroups.class.getClassLoader(),
    // (IdeaPluginDescriptorImpl)pluginDescriptor);
    // }
    Map<String, List<String>> groups = PluginGroups.getInstance().getTree();
    for (Map.Entry<String, List<String>> entry : groups.entrySet()) {
      final String group = entry.getKey();
      if (PluginGroups.CORE.equals(group)) continue;

      JPanel groupPanel = new JPanel(new GridBagLayout());
      GridBagConstraints gbc = new GridBagConstraints();
      gbc.insets = new Insets(0, 0, 10, 0);
      gbc.fill = GridBagConstraints.BOTH;
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      gbc.weightx = 1;
      JLabel titleLabel =
          new JLabel(
              "<html><body><h2 style=\"text-align:left;\">" + group + "</h2></body></html>") {
            @Override
            public boolean isEnabled() {
              return isGroupEnabled(group);
            }
          };
      groupPanel.add(titleLabel, gbc);
      JLabel descriptionLabel =
          new JLabel(PluginGroups.getInstance().getDescription(group)) {
            @Override
            public Dimension getPreferredSize() {
              Dimension size = super.getPreferredSize();
              size.width = Math.min(size.width, 200);
              return size;
            }

            @Override
            public boolean isEnabled() {
              return isGroupEnabled(group);
            }

            @Override
            public Color getForeground() {
              return ColorUtil.withAlpha(UIManager.getColor("Label.foreground"), .75);
            }
          };
      groupPanel.add(descriptionLabel, gbc);
      gbc.weighty = 1;
      groupPanel.add(Box.createVerticalGlue(), gbc);
      gbc.weighty = 0;
      if (PluginGroups.getInstance().getSets(group).size() == 1) {
        groupPanel.add(
            createLink(SWITCH_COMMAND + ":" + group, getGroupSwitchTextProvider(group)), gbc);
      } else {
        JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 10, 5));
        LinkLabel customizeButton =
            createLink(CUSTOMIZE_COMMAND + ":" + group, CUSTOMIZE_TEXT_PROVIDER);
        buttonsPanel.add(customizeButton);
        LinkLabel disableAllButton =
            createLink(SWITCH_COMMAND + ":" + group, getGroupSwitchTextProvider(group));
        buttonsPanel.add(disableAllButton);
        groupPanel.add(buttonsPanel, gbc);
      }
      gridPanel.add(groupPanel);
    }

    int cursor = 0;
    Component[] components = gridPanel.getComponents();
    int rowCount = components.length / COLS;
    for (Component component : components) {
      ((JComponent) component)
          .setBorder(
              new CompoundBorder(
                  new CustomLineBorder(
                      ColorUtil.withAlpha(JBColor.foreground(), .2),
                      0,
                      0,
                      cursor / 3 < rowCount - 1 ? 1 : 0,
                      cursor % COLS != COLS - 1 ? 1 : 0) {
                    @Override
                    protected Color getColor() {
                      return ColorUtil.withAlpha(JBColor.foreground(), .2);
                    }
                  },
                  BorderFactory.createEmptyBorder(GAP, GAP, GAP, GAP)));
      cursor++;
    }
  }
示例#14
0
 /**
  * method to check whether a panel contains a specific component
  *
  * @param p
  * @param comp
  * @return
  */
 private boolean contains(JPanel p, Component comp) {
   Component[] c = p.getComponents();
   for (int j = 0; j < c.length; j++) if (c[j] == comp) return true;
   return false;
 }