コード例 #1
0
ファイル: JDropDownButton.java プロジェクト: snibel/scout.rt
  public JDropDownButton(AbstractButton mainButton) {
    setOpaque(false);
    //
    m_pushButton = mainButton;
    m_pushButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
              getMenuButton().doClick();
            }
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
              getMenuButton().doClick();
            }
          }
        });
    add(m_pushButton, BorderLayout.CENTER);
    //
    enabledDownArrow = new SmallDownArrow();
    disDownArrow = new SmallDisabledDownArrow();
    m_menuButton = new JButton(enabledDownArrow);
    m_menuButton.setDisabledIcon(disDownArrow);
    m_menuButton.setFocusPainted(false);
    m_menuButton.setFocusable(false);
    add(m_menuButton, BorderLayout.EAST);

    setLayout(new DropDownButtonLayout(m_pushButton, m_menuButton, 12));
    updateUI();
  }
コード例 #2
0
  private void pintarCalle(Corredor corredor, Component[] botones) {
    String imagen = "/img/" + corredor.getFoto();

    for (int i = 0; i < botones.length; i++) {
      JButton boton = (JButton) botones[i];
      if (i == corredor.getPosicion()) {
        boton.setIcon(new ImageIcon(getClass().getResource(imagen)));
        boton.setDisabledIcon(new ImageIcon(getClass().getResource(imagen)));
      } else {
        boton.setIcon(null);
        boton.setDisabledIcon(null);
      }

      if (!corredor.equals(carrera.getCorredorActivo())) {
        boton.setEnabled(false);
      }
    }
  }
コード例 #3
0
  private void setupToolBar() {

    // setup the buttons
    buttonRecord.setIcon(imageiconRecord);
    buttonRecord.setDisabledIcon(imageiconRecordDisabled);
    buttonRecord.setPressedIcon(imageiconRecordDisabled);
    buttonRecord.setBorderPainted(false);
    buttonPause.setIcon(imageiconPause);
    buttonPause.setDisabledIcon(imageiconPauseDisabled);
    buttonPause.setPressedIcon(imageiconPauseDisabled);
    buttonPause.setBorderPainted(false);

    buttonRecord.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {

            if (model.isRecord()) {
              model.setRecord(false);
            } else {
              model.setRecord(true);
            }
          }
        });

    buttonPause.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {

            if (model.isPause()) {
              model.setPause(false);
            } else {
              model.setPause(true);
            }
          }
        });

    buttonRecord.setEnabled(!model.isRecord());
    buttonPause.setEnabled(!model.isPause());

    // add the view to the toolbar
    setLayout(new GridLayout(1, 1));
    add(panelMain);
  }
コード例 #4
0
  /**
   * setupButton
   *
   * @return
   */
  private JButton setupButton() {
    JButton btn = new JButton();
    btn.setSize(25, 22);
    btn.setVisible(true);
    btn.setIcon(icon);
    btn.setDisabledIcon(iconDisabled);
    btn.setBorder(BorderFactory.createEmptyBorder());
    btn.setOpaque(false);
    btn.setFocusPainted(false);

    return btn;
  }
コード例 #5
0
ファイル: ColorMenu.java プロジェクト: randomorz/csci201
  private void initializeComponents() {
    confirmButton = new JButton("Confirm", new ImageIcon("images/buttons/grey_button00.png"));
    confirmButton.setDisabledIcon(new ImageIcon("images/buttons/grey_button01.png"));
    confirmButton.setBorder(BorderFactory.createEmptyBorder());
    confirmButton.setHorizontalTextPosition(JButton.CENTER);
    confirmButton.setVerticalTextPosition(JButton.CENTER);
    confirmButton.setFont(kenVector16);
    confirmButton.setEnabled(false);

    colorLabel = new JLabel("Select your color");
    colorLabel.setFont(kenVector25);

    buttonGroup = new ButtonGroup();
    redButton =
        new CustomButton(
            "Red",
            new ImageIcon("images/buttons/red_button01.png"),
            new ImageIcon("images/buttons/red_button00.png"));
    buttonGroup.add(redButton);

    blueButton =
        new CustomButton(
            "Blue",
            new ImageIcon("images/buttons/blue_button01.png"),
            new ImageIcon("images/buttons/blue_button00.png"));
    buttonGroup.add(blueButton);

    greenButton =
        new CustomButton(
            "Green",
            new ImageIcon("images/buttons/green_button01.png"),
            new ImageIcon("images/buttons/green_button00.png"));
    buttonGroup.add(greenButton);

    yellowButton =
        new CustomButton(
            "Yellow",
            new ImageIcon("images/buttons/yellow_button01.png"),
            new ImageIcon("images/buttons/yellow_button00.png"));
    buttonGroup.add(yellowButton);
  }
コード例 #6
0
  public SplashScreen(Image image) {
    this.icon = new ImageIcon(image);

    Container container = getContentPane();
    container.setLayout(null);

    // Redraw the image to fix the alpha channel
    BufferedImage alphaImage =
        new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = alphaImage.createGraphics();
    g.drawImage(image, 0, 0, icon.getIconWidth(), icon.getIconHeight(), null);
    g.dispose();

    // Draw the image
    JButton background = new JButton(new ImageIcon(alphaImage));
    background.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
    background.setRolloverEnabled(true);
    background.setRolloverIcon(background.getIcon());
    background.setSelectedIcon(background.getIcon());
    background.setDisabledIcon(background.getIcon());
    background.setPressedIcon(background.getIcon());
    background.setFocusable(false);
    background.setContentAreaFilled(false);
    background.setBorderPainted(false);
    background.setOpaque(false);
    container.add(background);

    // Finalize
    setSize(icon.getIconWidth(), icon.getIconHeight() + 20);
    try {
      // Not always supported...
      this.setBackground(new Color(0, 0, 0, 0));
    } catch (UnsupportedOperationException e) {
      this.setBackground(new Color(0, 0, 0));
    }
    setLocationRelativeTo(null);
  }
コード例 #7
0
  private void jbInit() throws Exception {
    titledBorder1 = new TitledBorder("");
    this.setLayout(baseLayout);

    double[][] lower_size = {
      {TableLayout.PREFERRED, TableLayout.FILL, 25}, {25, 25, TableLayout.FILL}
    };
    mLowerPanelLayout = new TableLayout(lower_size);

    mLowerPanel.setLayout(mLowerPanelLayout);

    double[][] dir_size = {
      {TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED, TableLayout.FILL}
    };
    mDirectionsPanelLayout = new TableLayout(dir_size);
    mDirectionsPanel.setLayout(mDirectionsPanelLayout);

    // Try to get icons for the toolbar buttons
    try {
      ClassLoader loader = getClass().getClassLoader();
      mAddIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/add.gif"));
      mRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove.gif"));
      mDisabledRemoveIcon =
          new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove_disabled.gif"));

      mAddNodeBtn.setIcon(mAddIcon);
      mRemoveNodeBtn.setIcon(mRemoveIcon);
      mRemoveNodeBtn.setDisabledIcon(mDisabledRemoveIcon);
    } catch (Exception e) {
      // Ack! No icons. Use text labels instead
      mAddNodeBtn.setText("Add");
      mRemoveNodeBtn.setText("Remove");
    }

    /*
    mAddNodeBtn.setMaximumSize(new Dimension(130, 33));
    mAddNodeBtn.setMinimumSize(new Dimension(130, 33));
    mAddNodeBtn.setPreferredSize(new Dimension(130, 33));
    mAddNodeBtn.setText("Add Node");
    */
    mAddNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    /*
    mRemoveNodeBtn.setMaximumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setMinimumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setPreferredSize(new Dimension(130, 33));
    mRemoveNodeBtn.setText("Remove Node");
    */
    mRemoveNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mRemoveNode();
          }
        });
    mHostnameLabel.setHorizontalAlignment(SwingConstants.TRAILING);
    mHostnameLabel.setLabelFor(mHostnameField);
    mHostnameLabel.setText("Hostname:");

    mHostnameField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    mDirectionsPanel.setBorder(BorderFactory.createEtchedBorder());
    mTitleLabel.setFont(new java.awt.Font("Serif", 1, 20));
    mTitleLabel.setHorizontalAlignment(SwingConstants.CENTER);
    mTitleLabel.setText("Add Cluster Nodes");
    mDirectionsLabel.setText("Click on the add button to add nodes to your cluster configuration.");
    mDirectionsLabel.setLineWrap(true);
    mDirectionsLabel.setEditable(false);
    mDirectionsLabel.setBackground(mTitleLabel.getBackground());

    baseLayout.setHgap(5);
    baseLayout.setVgap(5);
    mLowerPanel.add(
        mHostnameLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mHostnameField, new TableLayoutConstraints(1, 0, 1, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mListScrollPane1,
        new TableLayoutConstraints(0, 1, 1, 2, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mAddNodeBtn, new TableLayoutConstraints(2, 0, 2, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mRemoveNodeBtn, new TableLayoutConstraints(2, 1, 2, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mLowerPanel, BorderLayout.CENTER);
    mListScrollPane1.getViewport().add(lstNodes, null);
    mDirectionsPanel.add(
        mTitleLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mDirectionsLabel,
        new TableLayoutConstraints(0, 1, 0, 1, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mIconLabel, new TableLayoutConstraints(1, 0, 1, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mDirectionsPanel, BorderLayout.NORTH);
  }
コード例 #8
0
  public RevisionAnalysisTopComponent(WorkspaceItem<RevisionAnalysisDocument> item) {
    super(item);
    setName(getDocument().getDisplayName());
    setToolTipText(Bundle.HINT_RevisionAnalysisTopComponent());

    toolBarRepresentation = NbComponents.newInnerToolbar();
    toolBarRepresentation.setFloatable(false);
    toolBarRepresentation.add(Box.createRigidArea(new Dimension(5, 0)));
    runButton =
        toolBarRepresentation.add(
            new AbstractAction("", DemetraUiIcon.COMPILE_16) {
              @Override
              public void actionPerformed(ActionEvent e) {
                start();
              }
            });
    runButton.setDisabledIcon(ImageUtilities.createDisabledIcon(runButton.getIcon()));
    runButton.setEnabled(false);

    addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(STATE_PROPERTY)) {
              onStateChange();
            }
          }
        });

    toolBarRepresentation.addSeparator();
    itemsLabel = (JLabel) toolBarRepresentation.add(new JLabel("No items"));

    inputList = new JTsList();
    inputList.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            switch (evt.getPropertyName()) {
              case JTsList.COLLECTION_PROPERTY:
                onCollectionChange();
                break;
            }
          }
        });

    toolBarRepresentation.addSeparator();
    JPopupMenu specPopup = new JPopupMenu();
    final JButton specButton =
        (JButton)
            toolBarRepresentation.add(
                DropDownButtonFactory.createDropDownButton(
                    ImageUtilities.loadImageIcon("ec/nbdemetra/sa/blog_16x16.png", false),
                    specPopup));
    specButton.setFocusPainted(false);
    specPopup
        .add(new ec.nbdemetra.ws.ui.SpecSelectionComponent())
        .addPropertyChangeListener(
            new PropertyChangeListener() {
              @Override
              public void propertyChange(PropertyChangeEvent evt) {
                String p = evt.getPropertyName();
                if (p.equals(ec.nbdemetra.ws.ui.SpecSelectionComponent.SPECIFICATION_PROPERTY)
                    && evt.getNewValue() != null) {
                  ISaSpecification spec = (ISaSpecification) evt.getNewValue();
                  curSpec.setSaSpecification(spec);
                  defSpecLabel.setText(spec == null ? "" : spec.toLongString());
                } else if (p.equals(ec.nbdemetra.ws.ui.SpecSelectionComponent.ICON_PROPERTY)
                    && evt.getNewValue() != null) {
                  specButton.setIcon(ImageUtilities.image2Icon((Image) evt.getNewValue()));
                }
              }
            });
    specPopup.addPopupMenuListener(
        new PopupMenuAdapter() {
          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            ((ec.nbdemetra.ws.ui.SpecSelectionComponent)
                    ((JPopupMenu) e.getSource()).getComponent(0))
                .setSpecification((ISaSpecification) curSpec.getSaSpecification());
          }
        });

    raView = new RevisionAnalysisTopComponent.RevisionAnalysisDocumentView();
    raView.setDocument(getDocument().getElement());

    loadingPanel = new LoadingPanel(raView);

    curSpec = getDocument().getElement().getSpecification().clone();

    defSpecLabel = (JLabel) toolBarRepresentation.add(new JLabel());
    defSpecLabel.setText(
        curSpec.getSaSpecification() == null
            ? ""
            : ((ISaSpecification) curSpec.getSaSpecification()).toLongString());

    visualRepresentation =
        NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, inputList, loadingPanel);
    visualRepresentation.setOneTouchExpandable(true);

    inputList.setTsCollection(getDocument().getElement().getInput());

    setLayout(new BorderLayout());
    add(toolBarRepresentation, BorderLayout.NORTH);
    add(visualRepresentation, BorderLayout.CENTER);

    refreshNode();
  }
コード例 #9
0
ファイル: kCodeWindow.java プロジェクト: agness/Kaleido
  /**
   * Constructor: The one we're working on right now.
   *
   * @param id
   * @param label
   * @param desktop
   */
  public kCodeWindow(String id, String label, JDesktopPane desktop) {

    this.id = id;
    this.desktop = desktop;

    // make the editor portions

    TextAreaDefaults editareaSettings = new PdeTextAreaDefaults();
    editareaSettings.rows = TEXTAREA_DEFAULT_ROWS;
    editareaSettings.cols = TEXTAREA_DEFAULT_COLS;
    textarea = new JEditTextArea(editareaSettings);
    textarea.getDocument().setTokenMarker(Editor.pdeTokenMarker);
    textarea.setEventsEnabled(
        false); // suppress JEditTextArea events (not that anyone is listening to it)
    textarea.setEditable(true);
    textarea.setHorizontalOffset(TEXTAREA_HORIZ_OFFSET);
    textarea.getPainter().setLineHighlightEnabled(false); // else looks funny
    textarea.getPainter().setBackground(kConstants.CODE_WINDOW_COLOR);
    setShortcutKeystrokes();
    JScrollPane scrollPane = new JScrollPane(textarea);
    scrollPane.setBorder(null);
    //    scrollPane.setOpaque(true);

    editFrame = new JInternalFrame(label, true, false, false, false);
    editFrame.setContentPane(textarea);
    editFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    editFrame.setSize(editFrame_DEFAULT_WIDTH, editFrame_DEFAULT_HEIGHT);
    editFrame.setBorder(null);
    editFrame.setOpaque(true);

    // make the triangle
    triangleFrame = new JInternalFrame("", false, false, false, false);
    triangleFrame.setOpaque(false);
    triangleFrame
        .getRootPane()
        .setBackground(new Color(0, 0, 0, 0)); // needs this to actually do the trick
    triangleFrame.setContentPane(
        new Triangle("SE", 0, TRIANGLE_BASE, TRIANGLE_DEFAULT_HEIGHT, TRIANGLE_BASE));
    triangleFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    triangleFrame.setSize(TRIANGLE_BASE, TRIANGLE_DEFAULT_HEIGHT);
    triangleFrame.setBorder(null);

    // remove the ability to move the triangle iframe
    MouseMotionListener[] actions =
        (MouseMotionListener[]) triangleFrame.getListeners(MouseMotionListener.class);
    for (int i = 0; i < actions.length; i++) triangleFrame.removeMouseMotionListener(actions[i]);

    // make the buttons
    moveButton = new JButton(Base.getImageIcon("codewindow-activ-move.gif", desktop));
    moveButton.setDisabledIcon(Base.getImageIcon("codewindow-inact-move.gif", desktop));
    moveButton.setVisible(true);
    moveButton.setBorder(null);
    moveButton.setOpaque(false);
    moveButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    closeButton = new JButton(Base.getImageIcon("codewindow-activ-close.gif", desktop));
    closeButton.setDisabledIcon(Base.getImageIcon("codewindow-inact-close.gif", desktop));
    closeButton.setVisible(true);
    closeButton.setBorder(null);
    closeButton.setOpaque(false);
    closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 0));
    buttonPanel.setBorder(null);
    buttonPanel.setOpaque(false);
    buttonPanel.add(moveButton);
    buttonPanel.add(closeButton);

    buttonFrame = new JInternalFrame("", false, false, false, false);
    buttonFrame.setContentPane(buttonPanel);
    buttonFrame.setOpaque(false);
    buttonFrame.getRootPane().setBackground(new Color(0, 0, 0, 0));
    buttonFrame.setSize(BUTTON_ICON_WIDTH * 2 + BUTTON_GAP, BUTTON_ICON_HEIGHT);
    buttonFrame.setBorder(null);

    // myriad event handling

    installFocusHandlers(buttonPanel);

    // hide code window when escape key is hit
    textarea.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) setVisible(false);
          }
        });
    // add dragging function of the move button,
    // reset the triangle after mouse release, and shift the editFrame
    // along with the mouse when the user is moving the window
    mxMouseControl moveListener = createMoveListener();
    moveButton.addMouseListener(moveListener);
    moveButton.addMouseMotionListener(moveListener);
    closeButton.addMouseListener(createCloseListener());
    // listens to resizing of editFrame and adjusts the position of the
    // buttons and the shape of the triangle accordingly
    editFrame.addComponentListener(createResizeListener());
    // when code windows are on top of each other, layers them correctly
    // such that when the user clicks on any part of a code window
    // all three component internal frames are brought to the top
    // so they appear "focused" also
    InternalFrameListener iframeListener =
        new InternalFrameAdapter() {
          public void internalFrameActivated(InternalFrameEvent e) {
            moveToFrontLayer();
          }

          public void internalFrameDeactivated(InternalFrameEvent e) {
            moveToBackLayer();
          }
        };
    editFrame.addInternalFrameListener(iframeListener);
    buttonFrame.addInternalFrameListener(iframeListener);
    triangleFrame.addInternalFrameListener(iframeListener);

    // add everything to desktop

    desktop.add(editFrame);
    desktop.add(buttonFrame);
    desktop.add(triangleFrame);
    moveToBackLayer();
  }
コード例 #10
0
  public JMovieControlAqua() {
    // Set the background color to the border color of the buttons.
    // This way the toolbar won't look too ugly when the buttons
    // are displayed before they have been loaded completely.
    // setBackground(new Color(118, 118, 118));
    setBackground(Color.WHITE);

    Dimension buttonSize = new Dimension(16, 16);
    GridBagLayout gridbag = new GridBagLayout();
    Insets margin = new Insets(0, 0, 0, 0);
    setLayout(gridbag);
    GridBagConstraints c;

    ResourceBundle labels = ResourceBundle.getBundle("org.monte.media.Labels");
    colorCyclingButton = new JToggleButton();
    colorCyclingButton.setToolTipText(labels.getString("colorCycling.toolTipText"));
    colorCyclingButton.addActionListener(this);
    colorCyclingButton.setPreferredSize(buttonSize);
    colorCyclingButton.setMinimumSize(buttonSize);
    colorCyclingButton.setVisible(false);
    colorCyclingButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 0;
    // c.gridy = 0;
    gridbag.setConstraints(colorCyclingButton, c);
    add(colorCyclingButton);

    audioButton = new JToggleButton();
    audioButton.setToolTipText(labels.getString("audio.toolTipText"));
    audioButton.addActionListener(this);
    audioButton.setPreferredSize(buttonSize);
    audioButton.setMinimumSize(buttonSize);
    audioButton.setVisible(false);
    audioButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 0;
    // c.gridy = 0;
    gridbag.setConstraints(audioButton, c);
    add(audioButton);

    startButton = new JToggleButton();
    startButton.setToolTipText(labels.getString("play.toolTipText"));
    startButton.addActionListener(this);
    startButton.setPreferredSize(buttonSize);
    startButton.setMinimumSize(buttonSize);
    startButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 1;
    // c.gridy = 0;
    gridbag.setConstraints(startButton, c);
    add(startButton);

    slider = new JMovieSliderAqua();
    c = new GridBagConstraints();
    // c.gridx = 2;
    // c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    gridbag.setConstraints(slider, c);
    add(slider);

    rewindButton = new JButton();
    rewindButton.setToolTipText(labels.getString("previous.toolTipText"));
    rewindButton.setPreferredSize(buttonSize);
    rewindButton.setMinimumSize(buttonSize);
    rewindButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 3;
    // c.gridy = 0;

    gridbag.setConstraints(rewindButton, c);
    add(rewindButton);
    rewindButton.addActionListener(this);

    forwardButton = new JButton();
    forwardButton.setToolTipText(labels.getString("next.toolTipText"));
    buttonSize = new Dimension(17, 16);
    forwardButton.setPreferredSize(buttonSize);
    forwardButton.setMinimumSize(buttonSize);
    forwardButton.setMargin(margin);
    c = new GridBagConstraints();
    // c.gridx = 4;
    // c.gridy = 0;
    gridbag.setConstraints(forwardButton, c);
    add(forwardButton);
    forwardButton.addActionListener(this);

    // The spacer is used when the play controls are hidden
    spacer = new JPanel(new BorderLayout());
    spacer.setVisible(false);
    spacer.setPreferredSize(new Dimension(16, 16));
    spacer.setMinimumSize(new Dimension(16, 16));
    spacer.setOpaque(false);
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    gridbag.setConstraints(spacer, c);
    add(spacer);

    Border border =
        new BackdropBorder(
            new ButtonStateBorder(
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.border.png"),
                    new Insets(1, 1, 1, 1),
                    new Insets(0, 4, 1, 4)),
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderP.png"),
                    new Insets(1, 1, 1, 1),
                    new Insets(0, 4, 1, 4))));

    Border westBorder =
        new BackdropBorder(
            new ButtonStateBorder(
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderWest.png"),
                    new Insets(1, 1, 1, 0),
                    new Insets(0, 4, 1, 4)),
                new ImageBevelBorder(
                    Images.createImage(getClass(), "images/Player.borderWestP.png"),
                    new Insets(1, 1, 1, 0),
                    new Insets(0, 4, 1, 4))));

    startButton.setBorder(westBorder);
    colorCyclingButton.setBorder(westBorder);
    audioButton.setBorder(westBorder);
    rewindButton.setBorder(westBorder);
    forwardButton.setBorder(border);
    startButton.setUI((ButtonUI) CustomButtonUI.createUI(startButton));
    colorCyclingButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton));
    audioButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton));
    rewindButton.setUI((ButtonUI) CustomButtonUI.createUI(rewindButton));
    forwardButton.setUI((ButtonUI) CustomButtonUI.createUI(forwardButton));

    colorCyclingButton.setIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png")));
    colorCyclingButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png")));
    colorCyclingButton.setDisabledIcon(
        new ImageIcon(
            Images.createImage(getClass(), "images/PlayerStartColorCycling.disabled.png")));
    audioButton.setIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.png")));
    audioButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStopAudio.png")));
    audioButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.disabled.png")));
    startButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.png")));
    startButton.setSelectedIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStop.png")));
    startButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.disabled.png")));
    rewindButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.png")));
    rewindButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.disabled.png")));
    forwardButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.png")));
    forwardButton.setDisabledIcon(
        new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.disabled.png")));

    // Automatic scrolling
    scrollHandler = new ScrollHandler();
    scrollTimer = new Timer(60, scrollHandler);
    scrollTimer.setInitialDelay(300); // default InitialDelay?
    forwardButton.addMouseListener(scrollHandler);
    rewindButton.addMouseListener(scrollHandler);
  }
コード例 #11
0
ファイル: DataPanel.java プロジェクト: Serabe/geogebra
  private void createGUI() {
    // set table and column renderers
    dataTable.setDefaultRenderer(Object.class, new MyCellRenderer());
    columnHeader = new MyColumnHeaderRenderer();
    columnHeader.setPreferredSize(
        new Dimension(preferredColumnWidth, SpreadsheetSettings.TABLE_CELL_HEIGHT));
    for (int i = 0; i < dataTable.getColumnCount(); ++i) {
      dataTable.getColumnModel().getColumn(i).setHeaderRenderer(columnHeader);
      dataTable.getColumnModel().getColumn(i).setPreferredWidth(preferredColumnWidth);
    }

    // disable row selection (for now)
    dataTable.setColumnSelectionAllowed(false);
    dataTable.setRowSelectionAllowed(false);

    // dataTable.setAutoResizeMode(JTable.);
    dataTable.setPreferredScrollableViewportSize(dataTable.getPreferredSize());
    dataTable.setMinimumSize(new Dimension(100, 50));
    // dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    dataTable.setAutoCreateColumnsFromModel(false);
    dataTable.setGridColor(TABLE_GRID_COLOR);

    // create a scrollPane for the table
    scrollPane = new JScrollPane(dataTable);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());

    // create row header
    rowHeader = new MyRowHeader(this, dataTable);
    scrollPane.setRowHeaderView(rowHeader);

    // create enableAll button and put it in the upper left corner
    CheckBoxIcon cbIcon = new CheckBoxIcon(13);
    ImageIcon iconUnChecked = cbIcon.createCheckBoxImageIcon(false, false);
    ImageIcon iconChecked = cbIcon.createCheckBoxImageIcon(true, false);

    btnEnableAll = new JButton();
    btnEnableAll.setIcon(iconUnChecked);
    btnEnableAll.setDisabledIcon(iconChecked);
    btnEnableAll.setEnabled(false);
    btnEnableAll.setBorderPainted(false);
    btnEnableAll.setBackground(
        geogebra.awt.Color.getAwtColor(GeoGebraColorConstants.TABLE_BACKGROUND_COLOR_HEADER));
    btnEnableAll.setContentAreaFilled(false);
    btnEnableAll.setHorizontalAlignment(SwingConstants.LEFT);
    btnEnableAll.addActionListener(this);

    Corner upperLeftCorner = new Corner();
    upperLeftCorner.setLayout(new BorderLayout());
    upperLeftCorner.add(btnEnableAll, BorderLayout.WEST);

    upperLeftCorner.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 1, 1, TABLE_GRID_COLOR),
            BorderFactory.createEmptyBorder(0, 5, 0, 2)));

    // set the other corners
    scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, upperLeftCorner);
    scrollPane.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, new Corner());
    scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, new Corner());

    lblHeader = new JLabel();
    lblHeader.setHorizontalAlignment(JLabel.LEFT);
    lblHeader.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(2, 5, 2, 2)));

    // finally, load up our JPanel
    this.setLayout(new BorderLayout());
    this.add(lblHeader, BorderLayout.NORTH);
    this.add(scrollPane, BorderLayout.CENTER);
    this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    this.setMinimumSize(dataTable.getPreferredSize());
  }