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);
    }
예제 #2
0
 public void setSelectionForeground(Color newValue) {
   sourceList.setSelectionForeground(newValue);
   destList.setSelectionForeground(newValue);
 }
예제 #3
0
  private void makeFrame(String[] audioFiles) {
    // the following makes sure that our application exits when
    // the user closes its window
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(new EmptyBorder(6, 10, 10, 10));

    // Specify the layout manager with nice spacing
    contentPane.setLayout(new BorderLayout(8, 8));

    // Create the left side with combobox and scroll list
    JPanel leftPane = new JPanel();
    {
      leftPane.setLayout(new BorderLayout(8, 8));

      fileList = new JList(audioFiles);
      fileList.setForeground(new Color(140, 171, 226));
      fileList.setBackground(new Color(0, 0, 0));
      fileList.setSelectionBackground(new Color(87, 49, 134));
      fileList.setSelectionForeground(new Color(140, 171, 226));
      JScrollPane scrollPane = new JScrollPane(fileList);
      scrollPane.setColumnHeaderView(new JLabel("Audio files"));
      leftPane.add(scrollPane, BorderLayout.CENTER);
    }
    contentPane.add(leftPane, BorderLayout.CENTER);

    // Create the center with image, text label, and slider
    JPanel centerPane = new JPanel();
    {
      centerPane.setLayout(new BorderLayout(8, 8));

      infoLabel = new JLabel("  ");
      infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
      infoLabel.setForeground(new Color(140, 171, 226));
      centerPane.add(infoLabel, BorderLayout.CENTER);
    }
    contentPane.add(centerPane, BorderLayout.EAST);

    // Create the toolbar with the buttons
    JPanel toolbar = new JPanel();
    {
      toolbar.setLayout(new GridLayout(1, 0));

      JButton button = new JButton("Play");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              play();
            }
          });
      toolbar.add(button);

      button = new JButton("Stop");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              stop();
            }
          });
      toolbar.add(button);

      button = new JButton("Pause");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              pause();
            }
          });
      toolbar.add(button);

      button = new JButton("Resume");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              resume();
            }
          });
      toolbar.add(button);
    }

    contentPane.add(toolbar, BorderLayout.NORTH);

    // building is done - arrange the components
    pack();

    // place this frame at the center of the screen and show
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation(d.width / 2 - getWidth() / 2, d.height / 2 - getHeight() / 2);
    setVisible(true);
  }