コード例 #1
0
 public synchronized void setPlayer(Player player) {
   if (this.player != null) {
     this.player.removeChangeListener(this);
     player.removePropertyChangeListener(this);
   }
   this.player = player;
   //        boundedRangeModel = player == null ? null : player.getBoundedRangeModel();
   boundedRangeModel = player == null ? null : player.getTimeModel();
   slider.setModel(boundedRangeModel);
   if (player != null) {
     if (player.getState() >= Player.REALIZED
         && boundedRangeModel != null
         && boundedRangeModel.getMaximum() == 0) {
       setPlayerControlsVisible(false);
     }
     slider.setProgressModel(player.getCachingModel());
     startButton.setSelected(player.isActive());
     player.addChangeListener(this);
     player.addPropertyChangeListener(this);
     audioButton.setVisible(player.isAudioAvailable());
     audioButton.setSelected(player.isAudioEnabled());
     colorCyclingButton.setVisible(
         (player instanceof ColorCyclePlayer)
             ? ((ColorCyclePlayer) player).isColorCyclingAvailable()
             : false);
     colorCyclingButton.setSelected(
         (player instanceof ColorCyclePlayer)
             ? ((ColorCyclePlayer) player).isColorCyclingStarted()
             : false);
     validate();
     repaint();
     BoundedRangeModel cachingControlModel = slider.getProgressModel();
   }
 }
コード例 #2
0
ファイル: CornerRadius.java プロジェクト: devmars/substance
  /** Creates the main frame for <code>this</code> sample. */
  public CornerRadius() {
    super("Toolbar button corner radius");

    this.setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar("");
    toolBar.add(new JLabel("Sample toolbar"));
    toolBar.add(new JSeparator(SwingConstants.VERTICAL));

    JToggleButton buttonDefault = new JToggleButton("radius default");
    buttonDefault.setSelected(true);
    toolBar.add(buttonDefault);

    JToggleButton button1 = new JToggleButton("radius 5");
    // set corner radius to 5 pixels
    button1.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(5.0f));
    button1.setSelected(true);
    toolBar.add(button1);

    JToggleButton button2 = new JToggleButton("radius 0");
    // set corner radius to 0 pixels (perfect rectangle)
    button2.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(0.0f));
    button2.setSelected(true);
    toolBar.add(button2);

    this.add(toolBar, BorderLayout.NORTH);

    this.setSize(400, 200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
コード例 #3
0
 private void disconnect() {
   if (session != null && session.isConnected()) {
     session.disconnect();
   }
   jToggleButtonConnect.setSelected(false);
   jToggleButtonConnect.setText("Connect");
   jToggleButtonRegister.setSelected(false);
   onlineUsers.clear();
   jToggleButtonRegister.setText("Register");
 }
コード例 #4
0
ファイル: CutPanelView.java プロジェクト: OceanAtlas/JOA
  public void actionPerformed(java.awt.event.ActionEvent event) {
    if (TRACE) System.out.println("CutPanelView actionPerformed: view: " + viewName);

    if (event.getSource() == closeButn) {
      JToggleButton jtb = (JToggleButton) event.getSource();
      jtb.setSelected(false);
      // System.out.println("Close!");
      vm.hideView(this);
      toolbarButton.setSelected(false);
    } else if (toolbarButton.isSelected()) {
      vm.showView(this);
    } else vm.hideView(this);
  }
コード例 #5
0
 @Override
 public void actionPerformed(ActionEvent e) {
   for (JToggleButton radio : radioButtons) {
     radio.setSelected(false);
     context.setCurrentOutputTool(QueryContext.TABLE_VIEW);
   }
 }
コード例 #6
0
ファイル: TracePanel.java プロジェクト: yuezixin/zorka
  public void setData(TraceDataSet dataSet) {
    this.dataSet = dataSet;
    this.errorsOnly = false;
    this.traceLabel = null;
    this.minTraceTime = 0;

    btnFilterErrors.setSelected(false);
    txtMinTime.setText("");

    tbmTraces.setDataSet(dataSet, null);

    List<String> traceNames = new ArrayList<String>();

    for (ViewerTraceRecord rec : dataSet.getRecords()) {
      String traceName = rec.getTraceName();
      if (traceName != null && !traceNames.contains(traceName)) {
        traceNames.add(traceName);
      }
    }

    Collections.sort(traceNames);
    cmbTraceType.removeAllItems();
    cmbTraceType.addItem("*");

    for (String traceName : traceNames) {
      cmbTraceType.addItem(traceName);
    }
  }
コード例 #7
0
ファイル: GUI.java プロジェクト: jhosler0793/Multiuser-Chat
 public void actionPerformed(ActionEvent event) {
   if (event.getSource() == joinButton) {
     if (joinButton.isSelected()) {
       mThread =
           new MulticastThread(
               Integer.valueOf(portField.getText()), chatIPField.getText(), chatroomArea, true);
       (new Thread(mThread)).start();
     }
   }
   if (event.getSource() == sendButton) {
     mThread.send(usernameField.getText(), chatMsgField.getText());
     chatMsgField.setText("");
   }
   if (event.getSource() == leaveButton) {
     try {
       joinButton.setSelected(false);
       mThread.leave();
       System.out.println("Disconnected from chat ");
     } catch (Exception e) {
     }
   }
   if (event.getSource() == exitButton) {
     System.exit(0);
   }
 }
コード例 #8
0
ファイル: ObjectManager.java プロジェクト: cmci/tango
 public void hide(boolean refresh) {
   container.remove(layout);
   if (showMeasurements.isSelected()) {
     container.remove(measurements);
     showMeasurements.setSelected(false);
   }
   if (refresh) core.refreshDisplay();
 }
コード例 #9
0
 private void handleConnect() {
   if (jToggleButtonConnect.isSelected() || jMenuItemServerConnect.isEnabled())
     try {
       jTextPaneDisplayMessages.setText("");
       session = new Session();
       try {
         String userid = jTextFieldUser.getText();
         if (jPasswordFieldPwd.getPassword() != null) {
           String pwd = String.valueOf(jPasswordFieldPwd.getPassword()).trim();
           if (!pwd.equals("")) {
             userid += ":" + pwd;
           }
         }
         if (session.connect(jTextFieldServer.getText(), userid)) {
           displayMessage("Connected\n", incomingMsgAttrSet);
           session.addListener(this);
           jToggleButtonConnect.setText("Disconnect");
           jMenuItemServerConnect.setEnabled(false);
           jMenuItemServerDisconnect.setEnabled(true);
         } else {
           jToggleButtonConnect.setSelected(false);
           jMenuItemServerConnect.setEnabled(true);
           jMenuItemServerDisconnect.setEnabled(false);
           displayMessage("Connection attempt failed\n", offlineClientAttrSet);
         }
       } catch (ConnectionException ex1) {
         jToggleButtonConnect.setSelected(false);
         jMenuItemServerConnect.setEnabled(true);
         jMenuItemServerDisconnect.setEnabled(false);
         displayMessage(
             "Connection attempt failed: " + ex1.getMessage() + "\n", offlineClientAttrSet);
       }
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   else {
     disconnect();
     jMenuItemServerConnect.setEnabled(true);
     jMenuItemServerDisconnect.setEnabled(false);
     displayMessage("Disconnected\n", offlineClientAttrSet);
   }
 }
コード例 #10
0
ファイル: Commands.java プロジェクト: dschachinger/colibri
 void setSelected(Object c, boolean sel) {
   if (c instanceof JToggleButton) {
     ((JToggleButton) c).setSelected(sel);
     return;
   }
   if (c instanceof JCheckBoxMenuItem) {
     ((JCheckBoxMenuItem) c).setState(sel);
     return;
   }
   // skip
 }
コード例 #11
0
  public void setValueIn(final Component comp) {
    //			SwingUtilities.invokeAndWait(new Runnable() {

    //				public void run() {
    JToggleButton fl = (JToggleButton) comp;
    if (log.isLoggable(Level.INFO)) {
      log.info("pref:" + pref + ", def=" + def + ", val=" + pr.getBoolean(pref, def));
    }
    fl.setSelected(pr.getBoolean(pref, def));
    //				}
    //			});
  }
コード例 #12
0
ファイル: GLDemo.java プロジェクト: timburrow/OpenVnmrJ
  public GLDemo() {
    super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false);

    DisplayOptions.addChangeListener(this);

    contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    gradientPanel = createGradientPanel();

    contentPane.add(gradientPanel, BorderLayout.CENTER);

    checkBox = new JCheckBox("Transparent", true);
    checkBox.setActionCommand("transparancy");
    checkBox.addActionListener(this);
    optionsPan = new JPanel();
    optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false));
    optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED));

    optionsPan.add(checkBox);

    runButton = new JToggleButton("Run");
    runButton.setActionCommand("run");
    runButton.setSelected(false);
    runButton.addActionListener(this);

    optionsPan.add(runButton);

    getContentPane().add(optionsPan, BorderLayout.SOUTH);
    setSize(300, 300);
    setLocation(300, 300);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            // Run this on another thread than the AWT event queue to
            // make sure the call to Animator.stop() completes before
            // exiting
            new Thread(
                    new Runnable() {
                      public void run() {
                        stop();
                      }
                    })
                .start();
          }
        });
    setVisible(false);
  }
コード例 #13
0
 public void propertyChange(PropertyChangeEvent evt) {
   String name = evt.getPropertyName();
   if (name.equals("audioEnabled")) {
     audioButton.setSelected(player.isAudioEnabled());
   } else if (name.equals("audioAvailable")) {
     audioButton.setVisible(player.isAudioAvailable());
     validate();
     repaint();
   } else if (name.equals("colorCyclingStarted")) {
     colorCyclingButton.setSelected(
         (player instanceof ColorCyclePlayer)
             ? ((ColorCyclePlayer) player).isColorCyclingStarted()
             : false);
   } else if (name.equals("colorCyclingAvailable")) {
     colorCyclingButton.setVisible(
         (player instanceof ColorCyclePlayer)
             ? ((ColorCyclePlayer) player).isColorCyclingAvailable()
             : false);
     validate();
     repaint();
   } else if (name.equals("cached")) {
     setPlayerControlsVisible(player.getTimeModel().getMaximum() > 0);
   }
 }
コード例 #14
0
ファイル: PanelSpec.java プロジェクト: ncrystal/josm-plugins
 public void syncPanel() {
   if (SeaMark.EntMAP.get(dlg.panelMain.mark.getObject()) == Ent.MOORING) {
     mooringButton.setBorderPainted(true);
     categoryBox.setVisible(false);
     mooringBox.setVisible(true);
     pillarButton.setEnabled(false);
     sparButton.setEnabled(false);
     beaconButton.setEnabled(false);
     towerButton.setEnabled(false);
     stakeButton.setEnabled(false);
     cairnButton.setEnabled(false);
     noticeButton.setEnabled(false);
     topmarkButton.setVisible(false);
     for (Cat cat : moorings.keySet()) {
       int item = moorings.get(cat);
       if (dlg.panelMain.mark.getCategory() == cat) mooringBox.setSelectedIndex(item);
     }
   } else {
     mooringButton.setBorderPainted(false);
     mooringBox.setVisible(false);
     categoryBox.setVisible(true);
     pillarButton.setEnabled(true);
     sparButton.setEnabled(true);
     beaconButton.setEnabled(true);
     towerButton.setEnabled(true);
     stakeButton.setEnabled(true);
     cairnButton.setEnabled(true);
     noticeButton.setEnabled(true);
     topmarkButton.setBorderPainted(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
     topmarkButton.setSelected(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
     topmarkButton.setVisible(dlg.panelMain.mark.testValid());
     for (Cat cat : categories.keySet()) {
       int item = categories.get(cat);
       if (dlg.panelMain.mark.getCategory() == cat) categoryBox.setSelectedIndex(item);
     }
   }
   for (Shp shp : shapes.keySet()) {
     JRadioButton button = shapes.get(shp);
     if (dlg.panelMain.mark.getShape() == shp) {
       button.setBorderPainted(true);
     } else button.setBorderPainted(false);
   }
   noticeButton.setBorderPainted(false);
   dlg.panelMain.mark.testValid();
 }
コード例 #15
0
  public void addColorChooserPanel(final AbstractColorChooserPanel ccp) {
    final String displayName = ccp.getDisplayName();
    if (displayName == null) {
      // Return if we haven't initialized yet
      return;
    }

    if (ccp.getClass()
        .getName()
        .equals("ch.randelshofer.quaqua.colorchooser.Quaqua15ColorPicker")) {
      northPanel.add(ccp, BorderLayout.WEST);
    } else {
      Icon displayIcon = ccp.getLargeDisplayIcon();
      JToggleButton tb = new JToggleButton(null, displayIcon);
      tb.setToolTipText(displayName);
      tb.setFocusable(false);
      tb.setHorizontalTextPosition(SwingConstants.CENTER);
      tb.setVerticalTextPosition(SwingConstants.BOTTOM);
      tb.setFont(UIManager.getFont("ColorChooser.font"));
      tb.putClientProperty("Quaqua.Button.style", "toolBarTab");
      JPanel centerView = new JPanel(new BorderLayout());
      centerView.add(ccp);
      chooserPanelHolder.add(centerView, displayName);
      toolBarButtonGroup.add(tb);
      toolBar.add(tb);

      if (toolBar.getComponentCount() == 1
          || lastSelectedChooserName != null && lastSelectedChooserName.equals(displayName)) {
        tb.setSelected(true);
        CardLayout cl = (CardLayout) chooserPanelHolder.getLayout();
        cl.show(chooserPanelHolder, displayName);
      }

      tb.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              if (evt.getStateChange() == ItemEvent.SELECTED) {
                CardLayout cl = (CardLayout) chooserPanelHolder.getLayout();
                cl.show(chooserPanelHolder, displayName);
                lastSelectedChooserName = displayName;
              }
            }
          });
    }
  }
コード例 #16
0
 private void handleRegister() {
   if (session == null || !session.isConnected()) {
     jToggleButtonRegister.setSelected(false);
     jMenuItemOptionsDeregister.setEnabled(false);
     jMenuItemOptionsRegister.setEnabled(true);
     return;
   }
   if (jToggleButtonRegister.isSelected() || jMenuItemOptionsRegister.isEnabled()) {
     register();
     jToggleButtonRegister.setText("Deregister");
     jMenuItemOptionsDeregister.setEnabled(true);
     jMenuItemOptionsRegister.setEnabled(false);
   } else {
     deregister();
     jToggleButtonRegister.setText("Register");
     jMenuItemOptionsDeregister.setEnabled(false);
     jMenuItemOptionsRegister.setEnabled(true);
   }
 }
コード例 #17
0
ファイル: ObjectManager.java プロジェクト: cmci/tango
 protected void initPanels() {
   BasicDBObject usr = Core.mongoConnector.getUser();
   splitDist = new DoubleParameter("Dist", "splitMinDistObj", 5d, DoubleParameter.nfDEC1);
   splitDist.dbGet(usr);
   splitRad = new DoubleParameter("Rad", "splitRadObj", 2d, DoubleParameter.nfDEC1);
   splitRad.dbGet(usr);
   ObjectManagerLayout lay = new ObjectManagerLayout(this);
   showObjects = lay.showROIs;
   showObjects.setSelected(true);
   splitDist.addToContainer(lay.splitDistPanel);
   showMeasurements = lay.viewMeasurements;
   measurements = new MeasurementDisplayer();
   this.listModel = new DefaultListModel();
   this.list = lay.list;
   this.list.setModel(listModel);
   this.list.setCellRenderer(new LCRenderer());
   this.list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
   this.list.setLayoutOrientation(JList.VERTICAL);
   listSelectionModel = list.getSelectionModel();
   listSelectionModel.addListSelectionListener(this);
   this.layout = lay;
 }
コード例 #18
0
 public void stateChanged(ChangeEvent event) {
   startButton.setSelected(player.isActive());
 }
コード例 #19
0
ファイル: LJ3MDApp.java プロジェクト: eskilj/mvp
  public void actionPerformed(ActionEvent e) {
    Object src = e.getSource();
    if (src == timer) {
      for (int i = 0; i < speed; i++) // integrate a few steps
      md.vv();
      repaint();
      return;
    }

    boolean adjCanvasScale = false;

    if (src == bTstat) md.thermostat = !md.thermostat;

    if (src == bPot) {
      md.ljPotential = !md.ljPotential;
      md.clearData();

      if (timer.isRunning()) timer.stop();
      bStart.setSelected(false);
      bStart.setText("Start");
      md.init(md.rho);
    }

    if (src == tTemp || src == bReset) {
      double kT = Double.parseDouble(tTemp.getText().trim());
      if (kT < 1e-8) {
        kT = 1e-8;
        tTemp.setText("  " + kT);
      }
      md.kT = kT;
      md.clearData();
    }

    if (src == tRho || src == bReset) {
      double rho = Double.parseDouble(tRho.getText().trim());
      if (rho < 1e-3) {
        rho = 1e-3;
        tRho.setText("   " + rho);
      }
      if (rho > 1.2) {
        rho = 1.2;
        tRho.setText("   " + rho);
      }
      md.setDensity(rho);
      md.clearData();
      adjCanvasScale = true;
    }

    if (src == tSpeed || src == bReset) {
      speed = Integer.parseInt(tSpeed.getText().trim());
      if (speed < 1) {
        speed = 1;
        tSpeed.setText("   " + speed);
      }
    }

    if (src == bRetime) md.clearData();

    if (src == bStart) {
      boolean on = bStart.isSelected();
      if (on) {
        timer.restart();
        bStart.setText("Pause");
      } else {
        timer.stop();
        bStart.setText("Resume");
      }
    }

    if (src == tNum) {
      int n = Integer.parseInt(tNum.getText().trim());
      if (n < 2) {
        n = 2;
        tNum.setText(" " + n);
      }
      md.N = n;
      md.init(md.rho);
      adjCanvasScale = true;
    }

    if (src == bReset) {
      if (timer.isRunning()) timer.stop();
      bStart.setSelected(false);
      bStart.setText("Start");
      md.init(md.rho);
    }

    canvas.refresh(md.getXWrap(), md.N, true, adjCanvasScale);

    repaint();
  }
コード例 #20
0
  private void guiSetup() throws IOException {
    setContentPane(root);

    // control
    commandMap.put(btnForward, Command.FORWARD);
    commandMap.put(btnBackward, Command.BACKWARD);
    commandMap.put(btnLeft, Command.TURN_LEFT);
    commandMap.put(btnRight, Command.TURN_RIGHT);
    commandMap.put(btnStop, Command.STOP);

    // Servo && Camera
    commandMap.put(btnServoDown, Command.SERVO_DOWN);
    commandMap.put(btnServoLeft, Command.SERVO_LEFT);
    commandMap.put(btnServoRight, Command.SERVO_RIGHT);
    commandMap.put(btnServoUp, Command.SERVO_UP);
    commandMap.put(btnCamera, Command.TOGGLE_CAMERA);

    // LEDs
    commandMap.put(btnLeftLed, Command.TOGGLE_LEFT_BLINK);
    commandMap.put(btnRightLed, Command.TOGGLE_RIGHT_BLINK);
    commandMap.put(btnLED, Command.TOGGLE_LED);

    // speeds
    commandMap.put(btnSpeed1, Command.SPEED);
    commandMap.put(btnSpeed2, Command.SPEED);
    commandMap.put(btnSpeed3, Command.SPEED);
    commandMap.put(btnSpeed4, Command.SPEED);
    commandMap.put(btnSpeed5, Command.SPEED);

    // debugs
    commandMap.put(btnLF, Command.LEFT_FORWARD);
    commandMap.put(btnLB, Command.LEFT_BACKWARD);
    commandMap.put(btnLP, Command.LEFT_PAUSE);
    commandMap.put(btnRF, Command.RIGHT_FORWARD);
    commandMap.put(btnRB, Command.RIGHT_BACKWARD);
    commandMap.put(btnRP, Command.RIGHT_PAUSE);

    for (AbstractButton button : commandMap.keySet()) {
      button.addActionListener(this);
    }
    btnQuit.addActionListener(this);
    btnConnection.addActionListener(this);
    btnReset.addActionListener(this);
    btnShutdown.addActionListener(this);

    /*
            btnForward.addActionListener (this);
            btnLeft.addActionListener (this);
            btnBackward.addActionListener (this);
            btnRight.addActionListener (this);
            btnStop.addActionListener (this);

            btnSpeed1.addActionListener (this);
            btnSpeed2.addActionListener (this);
            btnSpeed3.addActionListener (this);
            btnSpeed4.addActionListener (this);
            btnSpeed5.addActionListener (this);
            btnLeftLed.addActionListener (this);
            btnRightLed.addActionListener (this);
            btnServoLeft.addActionListener (this);
            btnServoUp.addActionListener (this);
            btnServoRight.addActionListener (this);
            btnServoDown.addActionListener (this);
            btnLED.addActionListener (this);
            btnCamera.addActionListener (this);
            btnLF.addActionListener (this);
            btnLB.addActionListener (this);
            btnLP.addActionListener (this);
            btnRF.addActionListener (this);
            btnRB.addActionListener (this);
            btnRP.addActionListener (this);
    */

    ButtonGroup group1 = new ButtonGroup();
    group1.add(btnSpeed1);
    group1.add(btnSpeed2);
    group1.add(btnSpeed3);
    group1.add(btnSpeed4);
    group1.add(btnSpeed5);
    btnSpeed3.setSelected(true);

    setButtonStatus(false);
  }
コード例 #21
0
ファイル: Check.java プロジェクト: charlesa101/insubstantial
  public static JToolBar getToolbar(String label, int size, boolean hasStrings) {
    JToolBar toolBar = new JToolBar();

    JButton buttonCut = new JButton(hasStrings ? "cut" : null, getIcon(size + "/edit-cut"));
    buttonCut.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    toolBar.add(buttonCut);
    JButton buttonCopy = new JButton(hasStrings ? "copy" : null, getIcon(size + "/edit-copy"));
    buttonCopy.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    buttonCopy.setEnabled(false);
    toolBar.add(buttonCopy);
    JButton buttonPaste = new JButton(getIcon(size + "/edit-paste"));
    toolBar.add(buttonPaste);
    JButton buttonSelectAll = new JButton(getIcon(size + "/edit-select-all"));
    toolBar.add(buttonSelectAll);
    JButton buttonDelete = new JButton(getIcon(size + "/edit-delete"));
    toolBar.add(buttonDelete);
    toolBar.addSeparator();

    // add an inner toolbar to check the painting of toolbar
    // gradient and drop shadows under different skins.
    JToolBar innerToolbar = new JToolBar(JToolBar.HORIZONTAL);
    innerToolbar.setFloatable(false);
    JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size + "/format-justify-center"));
    buttonFormatCenter.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 5.0f);
    innerToolbar.add(buttonFormatCenter);
    JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size + "/format-justify-left"));
    innerToolbar.add(buttonFormatLeft);
    JToggleButton buttonFormatRight = new JToggleButton(getIcon(size + "/format-justify-right"));
    innerToolbar.add(buttonFormatRight);
    JToggleButton buttonFormatFill = new JToggleButton(getIcon(size + "/format-justify-fill"));
    buttonFormatFill.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
    innerToolbar.add(buttonFormatFill);

    toolBar.add(innerToolbar);
    toolBar.addSeparator();

    if (size > 20) {
      JToolBar innerToolbar2 = new JToolBar(JToolBar.HORIZONTAL);
      innerToolbar2.setFloatable(false);

      JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
      innerToolbar2.add(innerPanel, BorderLayout.CENTER);

      final JToggleButton buttonStyleBold = new JToggleButton(getIcon(size + "/format-text-bold"));
      Set<Side> rightSide = EnumSet.of(Side.RIGHT);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);

      final JToggleButton buttonStyleItalic =
          new JToggleButton(getIcon(size + "/format-text-italic"));
      buttonStyleItalic.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleItalic.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleUnderline =
          new JToggleButton(getIcon(size + "/format-text-underline"));
      buttonStyleUnderline.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleUnderline.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleStrikethrough =
          new JToggleButton(getIcon(size + "/format-text-strikethrough"));
      buttonStyleStrikethrough.putClientProperty(
          SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(Side.LEFT));
      buttonStyleStrikethrough.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);
      buttonStyleBold.setSelected(true);

      innerPanel.add(buttonStyleBold);
      innerPanel.add(buttonStyleItalic);
      innerPanel.add(buttonStyleUnderline);
      innerPanel.add(buttonStyleStrikethrough);

      toolBar.add(innerToolbar2);
    }

    toolBar.add(Box.createGlue());
    JButton buttonExit = new JButton(getIcon(size + "/process-stop"));
    buttonExit.setToolTipText("Closes the test application");
    buttonExit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    toolBar.add(buttonExit);

    return toolBar;
  }
コード例 #22
0
ファイル: GLDemo.java プロジェクト: timburrow/OpenVnmrJ
 public void stop() {
   runButton.setSelected(false);
   runButton.repaint();
   animator.stop();
 }
コード例 #23
0
  /** Update the calendar panel to display the currently selected date. */
  private void updateCalendarComponents() {
    if ((selectedComponents & DISPLAY_DATE) > 0) {

      // Unselect all visible dates

      offScreenButton.setSelected(true);

      // Get the display date. We only need the month and year

      displayMonth = displayCalendar.get(Calendar.MONTH);
      displayYear = displayCalendar.get(Calendar.YEAR);

      // Get the localized display month name and year

      String month = formatMonth.format(displayCalendar.getTime());
      String year = Integer.toString(displayYear);

      {
        Object[] args = {month, year};
        monthYearLabel.setText(MessageFormat.format(bundle.getString("MonthYearTitle"), args));
      }

      // If the month or year have changed, we need to re-lay out
      // the days. Otherwise, we don't

      if (!month.equals(lastMonth) || !year.equals(lastYear)) {

        // Create a temporary calendar that we will use to
        // determine where day 1 goes and how many days there are
        // in this month

        Calendar temp = (Calendar) displayCalendar.clone();
        temp.set(Calendar.DATE, 1);

        int dayOfWeek = temp.get(Calendar.DAY_OF_WEEK);
        int firstDay = temp.getFirstDayOfWeek();

        // Determine how many blank slots occur before day 1 of this
        // month

        int dayPtr;
        for (dayPtr = 0; dayPtr < 7; dayPtr++) {
          int curDay = ((firstDay - 1) + dayPtr) % 7 + 1;
          if (curDay != dayOfWeek) {
            dayButtons[0][dayPtr].setText("");
            dayButtons[0][dayPtr].setEnabled(false);
          } else {
            break;
          }
        }

        // Determine the number of days in this month

        int maxDays = temp.getActualMaximum(Calendar.DATE);

        // Fill in the days

        int row = 0;
        for (int day = 1; day <= maxDays; day++) {
          dayButtons[row][dayPtr].setText(Integer.toString(day));
          dayButtons[row][dayPtr].setEnabled(true);

          // If this is the selected date, select the button;
          // otherwise, deselect it

          if (day == selectedDay && displayMonth == selectedMonth && displayYear == selectedYear) {
            dayButtons[row][dayPtr].setSelected(true);
          } else {
            dayButtons[row][dayPtr].getModel().setSelected(false);
          }

          // Wrap as needed

          dayPtr = (dayPtr + 1) % 7;
          if (dayPtr == 0) row++;
        }

        // Set the blanks slots after the last day

        while (row < 6) {
          dayButtons[row][dayPtr].setText("");
          dayButtons[row][dayPtr].setEnabled(false);
          dayButtons[row][dayPtr].getModel().setSelected(false);
          dayPtr = (dayPtr + 1) % 7;
          if (dayPtr == 0) row++;
        }
      }
    }

    // Update the time component, if displayed

    if ((selectedComponents & DISPLAY_TIME) > 0) {

      // If no date is selected, we set the date used by the time
      // field to today @ noon. We also make the field insensitive
      // -- the user must pick a non-null date before being able to
      // change the time (unless all we have is a time field)

      if (isNullDate) {
        Calendar temp = (Calendar) selectedCalendar.clone();
        temp.setTime(new Date());
        temp.set(Calendar.HOUR, 12);
        temp.set(Calendar.MINUTE, 0);
        temp.set(Calendar.SECOND, 0);
        spinnerDateModel.setValue(temp.getTime());
        spinner.setEnabled((selectedComponents & DISPLAY_DATE) == 0);
      }

      // If a date is selected, use it

      else {
        spinner.setEnabled(JCalendar.this.isEnabled());
        spinnerDateModel.setValue(selectedCalendar.getTime());
        spinnerDateModel.setStart(null);
        spinnerDateModel.setEnd(null);
        spinner.revalidate();
      }
    }
  }
コード例 #24
0
 public void doLoadData(Object from, Field field) throws IllegalAccessException {
   final Boolean value = (Boolean) field.get(from);
   myToggleButton.setSelected(value.booleanValue());
 }
コード例 #25
0
ファイル: GLDemo.java プロジェクト: timburrow/OpenVnmrJ
 public void start() {
   runButton.setSelected(true);
   runButton.repaint();
   animator.start();
 }