示例#1
0
  protected void AddAndword(String Letter, String Andwoord, Color Kleur) {
    javax.swing.JLabel lbl;
    javax.swing.JPanel pnl;
    javax.swing.JToggleButton tcmd;

    pnl = new javax.swing.JPanel();
    tcmd = new javax.swing.JToggleButton();
    lbl = new javax.swing.JLabel();

    pnl.setBackground(Kleur);
    pnl.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    tcmd.setFont(new java.awt.Font("DejaVu Sans", 1, 36));
    lbl.setFont(new java.awt.Font("DejaVu Sans", 1, 12));

    tcmd.setText(Letter);
    tcmd.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
    tcmd.setMaximumSize(new java.awt.Dimension(30, 30));
    tcmd.setMinimumSize(new java.awt.Dimension(30, 30));
    tcmd.setPreferredSize(new java.awt.Dimension(30, 30));

    lbl.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    lbl.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    lbl.setText(Andwoord);
    lbl.setBorder(null);

    javax.swing.GroupLayout pnlALayout = new javax.swing.GroupLayout(pnl);
    pnl.setLayout(pnlALayout);

    pnlALayout.setHorizontalGroup(
        pnlALayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                pnlALayout
                    .createSequentialGroup()
                    .addComponent(
                        tcmd,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        50,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        lbl, javax.swing.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE)));

    pnlALayout.setVerticalGroup(
        pnlALayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                pnlALayout
                    .createSequentialGroup()
                    .addComponent(
                        tcmd,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        50,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(32, Short.MAX_VALUE))
            .addComponent(lbl, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE));

    Antwoorde.add(pnl);
  }
示例#2
0
 private JToggleButton createButton(Container container, String tip) {
   final JToggleButton btn = new JToggleButton();
   btn.setPreferredSize(new Dimension(40, 40));
   btn.setBorder(new EmptyBorder(2, 2, 2, 2));
   btn.setOpaque(true);
   btn.setToolTipText(tip);
   addMouseListener(btn);
   container.add(btn);
   return btn;
 }
示例#3
0
 /**
  * Creates a diminutive toggle button used for selecting the message type
  *
  * @param title the title of the button
  * @param icon the icon to use
  * @param selected whether the button is selected or not
  * @param group the group to add the button to
  * @return the instantiated button
  */
 private JToggleButton createMessageTypeButton(
     String title, ImageIcon icon, boolean selected, ButtonGroup group) {
   JToggleButton button = new JToggleButton(icon);
   group.add(button);
   button.setSelected(selected);
   button.setToolTipText(title);
   button.setFocusable(false);
   button.setFocusPainted(false);
   button.addActionListener(this);
   button.setPreferredSize(new Dimension(18, 18));
   return button;
 }
示例#4
0
  public JToggleButton createButton(String name, ImageIcon icon) {
    JToggleButton button =
        new JToggleButton() {
          @Override
          public void paintComponent(Graphics g) {
            if (!isSelected()) {
              super.paintComponent(g);
              setForeground(Theme.TEXT_COLOR.darker());
              return;
            }

            g.setColor(new Color(0x666666));
            setForeground(Theme.TEXT_COLOR);
            g.fillRect(0, 0, getWidth(), getHeight());
            super.paintComponent(g);
          }
        };

    button.setIconTextGap(8);
    button.setContentAreaFilled(false);
    button.setFocusPainted(false);
    button.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(0x454545)),
            BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(0x333333))));

    button.setHorizontalAlignment(SwingConstants.CENTER);
    button.setVerticalAlignment(SwingConstants.CENTER);
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    button.setVerticalTextPosition(SwingConstants.BOTTOM);
    button.setForeground(Theme.TEXT_COLOR.darker());

    button.setMinimumSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    button.setMaximumSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
    button.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));

    button.setAction(
        new AbstractAction(name, icon) {
          @Override
          public void actionPerformed(ActionEvent e) {
            switchToPage(e.getActionCommand());
          }
        });

    buttonGroup.add(button);

    return button;
  }
  private JToggleButton createButton(String buttonText, final BuildingType buildingType) {
    JToggleButton button;
    if (buildingType.getImage() != null)
      button = new JToggleButton(buttonText, new ImageIcon(buildingType.getImage()));
    else {
      button = new JToggleButton(buttonText);
      button.setBackground(buildingType.getColour());
    }

    button.setPreferredSize(buttonDimension);
    button.setMinimumSize(buttonDimension);
    button.setSize(buttonDimension);
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            BuildingsPanel.this.firePropertyChange(SELECTED_BUILDING, 0, buildingType);
          }
        });
    buildingButtonGroup.add(button);
    return button;
  }
  protected void initShapePane() {

    shapepn = new JPanel(new FlowLayout(FlowLayout.LEFT));
    ShapeItemListener shapelistener = new ShapeItemListener();
    shapepn.add(new JLabel("Shape:"));
    Icon icon = XmippResource.getIcon("circle.png");
    circlechb = new JToggleButton(icon);
    circlechb.setSelected(true);
    circlechb.addItemListener(shapelistener);

    rectanglechb = new JToggleButton(XmippResource.getIcon("square.png"));
    rectanglechb.setPreferredSize(null);
    rectanglechb.setSelected(true);
    rectanglechb.addItemListener(shapelistener);

    centerchb = new JToggleButton(XmippResource.getIcon("plus.png"));
    centerchb.setSelected(true);
    centerchb.addItemListener(shapelistener);

    shapepn.add(circlechb);
    shapepn.add(rectanglechb);
    shapepn.add(centerchb);
  }
示例#7
0
  public JTarget(ITarget target) {
    if (target instanceof MetaTarget) {
      this.directions = ((MetaTarget) target).getDirections();
    } else {
      this.directions = new ArrayList<RelativeCoordinate>();
      RelativeCoordinate direction = ((SingleTarget) target).getDirection();

      if (direction != null) {
        this.directions.add(direction);
      }
    }
    setLayout(new GridBagLayout());

    JPanel directionsPanel = new JPanel();
    directionsPanel.setLayout(new GridLayout(3, 3, 3, 3));
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTH;
    add(directionsPanel, c);

    JButton neighborsButton = new JButton("neighbors");
    neighborsButton.addActionListener(new AllNeighborsButtonListener());
    c.gridy = 1;
    c.insets = new Insets(5, 0, 0, 0);
    add(neighborsButton, c);

    buttonsDirections = new IdentityHashMap<JToggleButton, RelativeCoordinate>();

    ImageIcon protoIconNorth = new ImageIcon(getClass().getResource("icons/target-north.png"));

    JToggleButton btn = new JToggleButton();
    btn.setIcon(ImageRotator.createRotatedImage(btn, protoIconNorth, 315));
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.NORTH_WEST);

    btn = new JToggleButton();
    btn.setIcon(protoIconNorth);
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.NORTH);

    btn = new JToggleButton();
    btn.setIcon(ImageRotator.createRotatedImage(btn, protoIconNorth, 45));
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.NORTH_EAST);

    btn = new JToggleButton();
    btn.setIcon(ImageRotator.createRotatedImage(btn, protoIconNorth, 270));
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.WEST);

    btn = new JToggleButton();
    btn.setIcon(new ImageIcon(getClass().getResource("icons/target-self.png")));
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.CENTER);

    btn = new JToggleButton();
    btn.setIcon(ImageRotator.createRotatedImage(btn, protoIconNorth, 90));
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.EAST);

    btn = new JToggleButton();
    btn.setIcon(ImageRotator.createRotatedImage(btn, protoIconNorth, 225));
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.SOUTH_WEST);

    btn = new JToggleButton();
    btn.setIcon(ImageRotator.createRotatedImage(btn, protoIconNorth, 180));
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.SOUTH);

    btn = new JToggleButton();
    btn.setIcon(ImageRotator.createRotatedImage(btn, protoIconNorth, 135));
    directionsPanel.add(btn);
    buttonsDirections.put(btn, RelativeCoordinate.SOUTH_EAST);

    for (JToggleButton b : buttonsDirections.keySet()) {
      b.setPreferredSize(new Dimension(30, 30));
      b.setMaximumSize(b.getPreferredSize());
      b.setMinimumSize(b.getPreferredSize());
      b.addActionListener(new TargetActionListener());
      for (RelativeCoordinate rc : directions) {
        if (rc == this.buttonsDirections.get(b)) {
          b.setSelected(true);
          break;
        }
      }
    }
  }
示例#8
0
  public ToolBox(final MainFrame mf) {
    JPanel container = new JPanel();
    container.setBackground(new Color(0xF2F2F5));
    add(container);
    container.setLayout(new GridLayout(0, 3, 3, 3));
    setBackground(new Color(0xF2F2F5));

    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < 7; i++) {
      JToggleButton btn = new JToggleButton();
      buttons.add(btn);
      btn.setPreferredSize(new Dimension(35, 35));
      btn.setMinimumSize(new Dimension(35, 35));
      btn.setMaximumSize(new Dimension(35, 35));
      group.add(btn);
      container.add(btn);
    }

    final JToggleButton jButtonSelect = buttons.get(0);
    jButtonSelect.setIcon(new ImageIcon(getClass().getResource("icons/tool-select.png")));
    jButtonSelect.setEnabled(true);
    jButtonSelect.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            mf.setActiveTool(SelectCommand.class);
            mf.getShowcase().setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
          }
        });

    final JToggleButton jButtonMove = buttons.get(1);
    jButtonMove.setIcon(new ImageIcon(getClass().getResource("icons/tool-move.png")));
    jButtonMove.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            mf.setActiveTool(MoveCommand.class);
            mf.getShowcase().setCursor(new Cursor(Cursor.MOVE_CURSOR));
          }
        });

    final JToggleButton jButtonZoom = buttons.get(2);
    jButtonZoom.setIcon(new ImageIcon(getClass().getResource("icons/tool-zoom.png")));
    jButtonZoom.setEnabled(true);
    jButtonZoom.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            mf.setActiveTool(ZoomCommand.class);
            mf.getShowcase().setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
          }
        });

    final JToggleButton jButtonPaint = buttons.get(3);
    jButtonPaint.setIcon(new ImageIcon(getClass().getResource("icons/tool-paint.png")));
    jButtonPaint.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            mf.setActiveTool(PaintCommand.class);
            mf.getShowcase().setCursor(new Cursor(Cursor.HAND_CURSOR));
          }
        });
    jButtonPaint.doClick();

    final JToggleButton jButtonFill = buttons.get(4);
    jButtonFill.setIcon(new ImageIcon(getClass().getResource("icons/tool-fill.png")));
    jButtonFill.setEnabled(true);
    jButtonFill.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            mf.setActiveTool(FillSelectionCommand.class);
            mf.getShowcase().setCursor(new Cursor(Cursor.MOVE_CURSOR));
          }
        });

    final JToggleButton jButtonErase = buttons.get(5);
    jButtonErase.setIcon(new ImageIcon(getClass().getResource("icons/tool-erase.png")));
    jButtonErase.setEnabled(true);
    jButtonErase.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            mf.setActiveTool(EraseCommand.class);
            mf.getShowcase().setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
          }
        });

    final JToggleButton jButtonPick = buttons.get(6);
    jButtonPick.setIcon(new ImageIcon(getClass().getResource("icons/tool-pick.png")));
    jButtonPick.setEnabled(true);
    jButtonPick.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent e) {
            mf.setActiveTool(PickCommand.class);
            mf.getShowcase().setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
          }
        });
  }
  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);
  }