コード例 #1
4
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
コード例 #2
1
  private JPanel createDynamicCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) {
    final JTable theTable = new JTable();
    PrimitiveFormPropertyPair pfpPair =
        new PrimitiveFormPropertyPair(primitiveForm.getName(), property);
    _dynamicTables.put(pfpPair, theTable);
    DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType();
    final DynamicDOTItemManager tableModel =
        (DynamicDOTItemManager) dotPoint.getTableModel(primitiveForm, property);
    theTable.setModel(tableModel);

    class NumberComparator implements Comparator<Number> {

      public int compare(Number o1, Number o2) {
        final double d1 = o1.doubleValue();
        final double d2 = o2.doubleValue();
        if (d1 < d2) {
          return -1;
        }
        if (d1 == d2) {
          return 0;
        }
        return 1;
      }
    }
    TableRowSorter<DynamicDOTItemManager> tableRowSorter =
        new TableRowSorter<DynamicDOTItemManager>();
    tableRowSorter.setModel(tableModel);
    tableRowSorter.setComparator(4, new NumberComparator());
    tableRowSorter.setComparator(5, new NumberComparator());
    theTable.setRowSorter(tableRowSorter);

    JButton newDOTItemButton = new JButton("Neue Zeile");
    newDOTItemButton.setEnabled(_dotDefinitionDialogFrame.isEditable());
    JButton deleteDOTItemButton = new JButton("Zeile löschen");
    deleteDOTItemButton.setEnabled(false);
    JButton showConflictsButton = new JButton("Zeige Konflikte");

    addButtonListeners(
        primitiveForm, property, newDOTItemButton, deleteDOTItemButton, showConflictsButton);
    addListSelectionListener(theTable, deleteDOTItemButton);

    JPanel dotButtonsPanel = new JPanel();
    dotButtonsPanel.setLayout(new SpringLayout());

    dotButtonsPanel.add(newDOTItemButton);
    dotButtonsPanel.add(deleteDOTItemButton);
    dotButtonsPanel.add(showConflictsButton);

    dotButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    SpringUtilities.makeCompactGrid(dotButtonsPanel, 1, 5, 20);

    JPanel thePanel = new JPanel();
    thePanel.setLayout(new SpringLayout());
    thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK));
    thePanel.add(new JScrollPane(theTable));
    thePanel.add(dotButtonsPanel);
    SpringUtilities.makeCompactGrid(thePanel, 2, 20, 5);

    return thePanel;
  }
コード例 #3
0
ファイル: ButtonNavigator.java プロジェクト: saeg/experiments
  public ButtonNavigator(ResourceManager resources) {
    _resources = resources;
    setLayout(new FlowLayout(FlowLayout.RIGHT));

    _back = new JButton(_resources.getString(BACK));
    _next = new JButton(_resources.getString(NEXT));
    _finish = new JButton(_resources.getString(FINISH));
    _cancel = new JButton(_resources.getString(CANCEL));

    _back.setActionCommand(BACK);
    _next.setActionCommand(NEXT);
    _finish.setActionCommand(FINISH);
    _cancel.setActionCommand(CANCEL);

    _back.addActionListener(_handler);
    _next.addActionListener(_handler);
    _finish.addActionListener(_handler);
    _cancel.addActionListener(_handler);

    _back.setEnabled(false);
    _next.setEnabled(false);
    _finish.setEnabled(false);
    _cancel.setEnabled(true);

    add(_back);
    add(_next);
    add(_finish);
    add(_cancel);
  }
コード例 #4
0
 /** Enalbe all the view history related toolbar icons. */
 public void enableHistoryButtons() {
   pbBack.setEnabled(history.canGoBack());
   pbShowBackHistory.setEnabled(history.canGoBack());
   pbForward.setEnabled(history.canGoForward());
   pbShowForwardHistory.setEnabled(history.canGoForward());
   tbrToolBar.repaint();
 }
コード例 #5
0
 /** Stop talking to the server */
 public void stop() {
   if (socket != null) {
     // Close all the streams and socket
     if (out != null) {
       try {
         out.close();
       } catch (IOException ioe) {
       }
       out = null;
     }
     if (in != null) {
       try {
         in.close();
       } catch (IOException ioe) {
       }
       in = null;
     }
     if (socket != null) {
       try {
         socket.close();
       } catch (IOException ioe) {
       }
       socket = null;
     }
   } else {
     // Already stopped
   }
   // Make sure the right buttons are enabled
   start_button.setEnabled(true);
   stop_button.setEnabled(false);
   setStatus(STATUS_STOPPED);
 }
コード例 #6
0
ファイル: NavigatorBar.java プロジェクト: nutsh/oswing
 /** Method called by grid component each time a row is selected. */
 public void setFirstRow(boolean isFirstRecord) {
   firstButton.setEnabled(!isFirstRecord);
   prevPgButton.setEnabled(!isFirstRecord);
   prevButton.setEnabled(!isFirstRecord);
   controlPageNr.setEnabled(true);
   //    controlPageNr.setEnabled(resultSetController.getTotalResultSetLength()!=-1);
 }
コード例 #7
0
  /**
   * Shows given list of reading lists.
   *
   * @param lists lists.
   */
  protected void setReadingLists(ReadingList[] lists) {
    tblReadingLists.setEnabled(lists != null);
    btnAddReadingList.setEnabled(lists != null);
    btnRemoveList.setEnabled(lists != null);

    readingListsModel.setLists(lists);
  }
コード例 #8
0
 /** Start talking to the server */
 public void start() {
   String codehost = getCodeBase().getHost();
   if (socket == null) {
     try {
       // Open the socket to the server
       socket = new Socket(codehost, port);
       // Create output stream
       out = new ObjectOutputStream(socket.getOutputStream());
       out.flush();
       // Create input stream and start background
       // thread to read data from the server
       in = new ObjectInputStream(socket.getInputStream());
       new Thread(this).start();
     } catch (Exception e) {
       // Exceptions here are unexpected, but we can't
       // really do anything (so just write it to stdout
       // in case someone cares and then ignore it)
       System.out.println("Exception! " + e.toString());
       e.printStackTrace();
       setErrorStatus(STATUS_NOCONNECT);
       socket = null;
     }
   } else {
     // Already started
   }
   if (socket != null) {
     // Make sure the right buttons are enabled
     start_button.setEnabled(false);
     stop_button.setEnabled(true);
     setStatus(STATUS_ACTIVE);
   }
 }
コード例 #9
0
ファイル: NavigatorBar.java プロジェクト: nutsh/oswing
 /** Method called by grid component each time a row is selected. */
 public void setLastRow(boolean isLastRecord) {
   lastButton.setEnabled(!isLastRecord);
   nextButton.setEnabled(!isLastRecord);
   nextPgButton.setEnabled(!isLastRecord);
   controlPageNr.setEnabled(true);
   //    controlPageNr.setEnabled(resultSetController.getTotalResultSetLength()!=-1);
 }
コード例 #10
0
 /** Listener to handle service list selection changes */
 public void valueChanged(ListSelectionEvent e) {
   if (service_list.getSelectedIndex() == -1) {
     remove_service_button.setEnabled(false);
   } else {
     remove_service_button.setEnabled(true);
   }
 }
コード例 #11
0
ファイル: StartChess.java プロジェクト: Vitvicky/java
  public void JudgeWhoIsWinner() // 判断胜负
      {
    String winner = "";

    if (white == 0) {
      JOptionPane.showMessageDialog(null, "黑方胜!" + black + ":" + white);
      //			JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
      submit.setEnabled(false);
      winner = "黑";
    }
    if (black == 0) {
      JOptionPane.showMessageDialog(null, "白方胜!" + white + ":" + black);
      //			JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
      submit.setEnabled(false);
      winner = "白";
    }
    if (black + white == 64) {
      if (white > black) {
        JOptionPane.showMessageDialog(null, "白方胜!" + white + ":" + black);
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        submit.setEnabled(false);
        winner = "白";
      } else if (black > white) {
        JOptionPane.showMessageDialog(null, "黑方胜!" + black + ":" + white);
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        submit.setEnabled(false);
        winner = "白";
      } else if (black == white) {
        JOptionPane.showMessageDialog(null, "和局!");
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        winner = "";
      }
    }
  }
コード例 #12
0
 /** Requests the list of all lost packages */
 private void buttonShowLostActionPerformed(ActionEvent event) {
   this.packages = DataAdapter.getLostPackages();
   this.jListPackages.setListData(new Vector(this.packages));
   jButtonSetLost.setEnabled(false);
   jButtonSetFound.setEnabled(this.packages.size() > 0);
   jListScans.setListData(new Vector());
 }
コード例 #13
0
ファイル: FrameServer.java プロジェクト: Jasi2169/EDMIS
 public void jButtonStop_actionPerformed(ActionEvent e) {
   jButtonStart.setEnabled(true);
   server.interrupt();
   connections(0);
   statusBar.setText("Server stopped!");
   jButtonStop.setEnabled(false);
   jButtonConfig.setEnabled(false);
 }
コード例 #14
0
 /** Handle changes to the text field */
 public void changedUpdate(DocumentEvent e) {
   String text = add_service_field.getText();
   if ((text != null) && (text.length() > 0)) {
     add_service_button.setEnabled(true);
   } else {
     add_service_button.setEnabled(false);
   }
 }
コード例 #15
0
  /** Updates the menu when a new database project is opened. */
  public void onDatabaseOpen() {

    if (pbOpen != null) pbOpen.setEnabled(false);
    if (pbClose != null) pbClose.setEnabled(true);
    if (pbHelp != null) pbHelp.setEnabled(true);
    if (pbSearch != null) pbSearch.setEnabled(true);
    if (pbImageRollover != null) pbImageRollover.setEnabled(true);
  }
コード例 #16
0
 private void setStepButtonStates(final boolean allDisabled) {
   firstStepButton.setEnabled(!allDisabled && this.currentStep > 1);
   previousStepButton.setEnabled(!allDisabled && this.currentStep > 1);
   nextStepButton.setEnabled(!allDisabled && this.currentStep < this.timeController.getEndTime());
   lastStepButton.setEnabled(!allDisabled && this.currentStep < this.timeController.getEndTime());
   final int endTime = (int) this.timeController.getEndTime();
   this.stepPositionLabel.setText(this.currentStep + "/" + endTime);
 }
コード例 #17
0
ファイル: Sorter.java プロジェクト: Acejhm/OmniProgram
  public Sorter() throws FileNotFoundException {
    // Same as set title
    super("Sort and Search");

    // Set initial values for the frame.
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setLocationRelativeTo(null);
    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);

    // Initialize all the various components and panels.
    mainPanel = new JPanel();
    buttonPanel = new JPanel();
    textPanel = new JPanel();

    fileChooser = new JFileChooser();

    text =
        new JLabel(
            "<html>Click the button below to choose the file you wish to sort and then click \"Sort\".<br>If you already have a file that is sorted, "
                + "choose the file and click \"Continue\"</html>");

    // Disable the two buttons, next and sort, so that the user HAS to chose a file before
    // continuing.  Otherwise, NullPointerExceptions get thrown everywhere.
    sort = new JButton("Sort");
    sort.setEnabled(false);
    sort.addActionListener(this);

    next = new JButton("Continue");
    next.setEnabled(false);
    next.addActionListener(this);

    chooseFile = new JButton("Choose File...");
    chooseFile.addActionListener(this);

    exit = new JButton("Exit");
    exit.addActionListener(this);

    search = new JButton("Search");
    search.addActionListener(this);

    // Add components to panels.
    buttonPanel.add(chooseFile);
    buttonPanel.add(sort);
    buttonPanel.add(next);
    buttonPanel.add(exit);

    textPanel.add(text);

    mainPanel.add(textPanel);
    mainPanel.add(buttonPanel);

    // Add the mainPanel to  the frame.
    add(mainPanel);

    // Make sure everything is visible.
    setVisible(true);
  }
コード例 #18
0
 private void setButtonStates(final boolean allDisabled) {
   final boolean enabled = !allDisabled && (this.diagramView.getDiagram() != null);
   addStaticTransitionsButton.setEnabled(enabled);
   removeTransitionsButton.setEnabled(enabled);
   startSteppingButton.setEnabled(enabled);
   animateTransitionsButton.setEnabled(enabled);
   exportImagesButton.setEnabled(enabled && this.diagramExportSettings != null);
   setStepButtonStates(!enabled);
 }
コード例 #19
0
  /**
   * Refreshes the undo/redo icons with the last action performed.
   *
   * @param oUndoManager, the manager to use to check for undo/redo possibilities.
   */
  public void refreshUndoRedo(UndoManager oUndoManager) {

    // refresh undo
    pbUndo.setToolTipText(oUndoManager.getUndoPresentationName());
    pbUndo.setEnabled(oUndoManager.canUndo());

    // refresh redo
    pbRedo.setToolTipText(oUndoManager.getRedoPresentationName());
    pbRedo.setEnabled(oUndoManager.canRedo());
  }
コード例 #20
0
ファイル: ChatClient.java プロジェクト: renetbutler/Online
  // 部屋に入室している状態のコンポーネント設定
  private void enteredRoom(String roomName) {
    this.roomName = roomName;
    setTitle(APPNAME + " " + roomName);

    msgTextField.setEnabled(true);
    submitButton.setEnabled(true);

    addRoomButton.setEnabled(false);
    enterRoomButton.setText("退室");
    enterRoomButton.setActionCommand("exitRoom");
  }
コード例 #21
0
  public static void refreshCalendar(int month, int year) {
    // instantiation
    String[] months = {
      "January",
      "February",
      "March",
      "April",
      "May",
      "June",
      "July",
      "August",
      "September",
      "October",
      "November",
      "December"
    };
    int numoday, startom; // Number Of Days, Start Of Month

    // Allow/disallow buttons
    prev.setEnabled(true);
    next.setEnabled(true);
    if (month == 0 && year <= ryear) {
      prev.setEnabled(false);
    } // Cannot set an appointment back in time
    if (month == 11 && year >= ryear + 50) {
      next.setEnabled(false);
    } // Too early to set an appointment
    lmonth.setText(months[month]); // Refresh the month label (at the top)
    lmonth.setBounds(
        160 - lmonth.getPreferredSize().width / 2, 25, 180, 25); // Re-align label with calendar
    cyear.setSelectedItem(String.valueOf(year)); // Select the correct year in the combo box

    // deletes current table
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 7; j++) {
        mcal.setValueAt(null, i, j);
      }
    }

    // Get first day of month and number of days
    GregorianCalendar cal = new GregorianCalendar(year, month, 1);
    numoday = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
    startom = cal.get(GregorianCalendar.DAY_OF_WEEK);

    // Create calendar
    for (int i = 1; i <= numoday; i++) {
      int row = new Integer((i + startom - 2) / 7);
      int column = (i + startom - 2) % 7;
      mcal.setValueAt(i, row, column);
    }

    // Apply renderers
    Cal.setDefaultRenderer(Cal.getColumnClass(0), new tblCalendarRenderer());
  }
コード例 #22
0
 /** Requests and displays all packages older than the date in the text field */
 private void buttonOldPackagesActionPerformed(ActionEvent event) {
   try {
     queryTime.setTime(dateFormatter.parse(jTextDate.getText().replace("-", "") + "2359"));
     this.packages = DataAdapter.getOlderPackages(queryTime);
     jListPackages.setListData(new Vector(this.packages));
     jButtonSetLost.setEnabled(this.packages.size() > 0);
     jButtonSetFound.setEnabled(false);
     jListScans.setListData(new Vector());
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(this, "Invalid date entered");
   }
 }
コード例 #23
0
ファイル: ChatClient.java プロジェクト: renetbutler/Online
  // 部屋に入室していない状態のコンポーネント設定
  private void exitedRoom() {
    roomName = null;
    setTitle(APPNAME);

    msgTextField.setEnabled(false);
    submitButton.setEnabled(false);

    addRoomButton.setEnabled(true);
    enterRoomButton.setText("入室");
    enterRoomButton.setActionCommand("enterRoom");
    userList.setModel(new DefaultListModel());
  }
コード例 #24
0
  /**
   * Set the current panel
   *
   * @param panel the panel
   */
  protected void setCurrentPanel(WizardPanel panel) {

    currentPanel = panel;
    currentPanel.prepare();

    cardLayout.show(cardPanel, currentPanel.toString());

    backButton.setEnabled(currentPanel != firstPanel);
    cancelButton.setText("Cancel");
    nextButton.setText("Next");
    cancelButton.setEnabled(true);
  }
コード例 #25
0
 /** Constructor */
 public ServiceFilterPanel(String text, Vector list) {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   service_box = new JCheckBox(text);
   service_box.addActionListener(this);
   service_data = new Vector();
   if (list != null) {
     service_box.setSelected(true);
     service_data = (Vector) list.clone();
   }
   service_list = new JList(service_data);
   service_list.setBorder(new EtchedBorder());
   service_list.setVisibleRowCount(5);
   service_list.addListSelectionListener(this);
   service_list.setEnabled(service_box.isSelected());
   service_scroll = new JScrollPane(service_list);
   service_scroll.setBorder(new EtchedBorder());
   remove_service_button = new JButton("Remove");
   remove_service_button.addActionListener(this);
   remove_service_button.setEnabled(false);
   remove_service_panel = new JPanel();
   remove_service_panel.setLayout(new FlowLayout());
   remove_service_panel.add(remove_service_button);
   service_area = new JPanel();
   service_area.setLayout(new BorderLayout());
   service_area.add(service_scroll, BorderLayout.CENTER);
   service_area.add(remove_service_panel, BorderLayout.EAST);
   service_area.setBorder(indent_border);
   add_service_field = new JTextField();
   add_service_field.addActionListener(this);
   add_service_field.getDocument().addDocumentListener(this);
   add_service_field.setEnabled(service_box.isSelected());
   add_service_button = new JButton("Add");
   add_service_button.addActionListener(this);
   add_service_button.setEnabled(false);
   add_service_panel = new JPanel();
   add_service_panel.setLayout(new BorderLayout());
   JPanel dummy = new JPanel();
   dummy.setBorder(empty_border);
   add_service_panel.add(dummy, BorderLayout.WEST);
   add_service_panel.add(add_service_button, BorderLayout.EAST);
   add_service_area = new JPanel();
   add_service_area.setLayout(new BorderLayout());
   add_service_area.add(add_service_field, BorderLayout.CENTER);
   add_service_area.add(add_service_panel, BorderLayout.EAST);
   add_service_area.setBorder(indent_border);
   setLayout(new BorderLayout());
   add(service_box, BorderLayout.NORTH);
   add(service_area, BorderLayout.CENTER);
   add(add_service_area, BorderLayout.SOUTH);
   setBorder(empty_border);
 }
コード例 #26
0
ファイル: TokenLabUI.java プロジェクト: xdy/TokenLab
  public void setDefaults() throws IOException {

    herolabsXMLChooser = new JFileChooser(prefs.get(HEROLABS_XML_DIR, ""));

    importButton.setEnabled(true);
    configurePortfolioButton.setEnabled(true);
    exportAllButton.setEnabled(false);
    exportSelectedButton.setEnabled(false);

    setXMLChooserFileFilter(herolabsXMLChooser);

    IconListRenderer listRenderer = new IconListRenderer(config, this);
    herolabsCharacterList.setCellRenderer(listRenderer);
  }
コード例 #27
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  /**
   * Call this to set a custom gradle executor. We'll enable all fields appropriately and setup the
   * foundation settings. We'll also fire off a refresh.
   *
   * @param file the file to use as a custom executor. Null not to use one.
   */
  private void setCustomGradleExecutor(File file) {
    String storagePath;
    boolean isUsingCustom = false;
    if (file == null) {
      isUsingCustom = false;
      storagePath = null;
    } else {
      isUsingCustom = true;
      storagePath = file.getAbsolutePath();
    }

    // set the executor in the foundation
    if (gradlePluginLord.setCustomGradleExecutor(file)) {
      // refresh the tasks only if we actually changed the executor
      gradlePluginLord.addRefreshRequestToQueue();
    }

    // set the UI values
    useCustomGradleExecutorCheckBox.setSelected(isUsingCustom);
    customGradleExecutorField.setText(storagePath);

    // enable the UI appropriately.
    browseForCustomGradleExecutorButton.setEnabled(isUsingCustom);
    customGradleExecutorField.setEnabled(isUsingCustom);

    // store the settings
    settingsNode.setValueOfChild(CUSTOM_GRADLE_EXECUTOR, storagePath);
  }
コード例 #28
0
ファイル: Notepad.java プロジェクト: ArcherSys/ArcherSysRuby
  /**
   * Create a button to go inside of the toolbar. By default this will load an image resource. The
   * image filename is relative to the classpath (including the '.' directory if its a part of the
   * classpath), and may either be in a JAR file or a separate file.
   *
   * @param key The key in the resource file to serve as the basis of lookups.
   */
  protected JButton createToolbarButton(String key) {
    URL url = getResource(key + imageSuffix);
    JButton b =
        new JButton(new ImageIcon(url)) {

          @Override
          public float getAlignmentY() {
            return 0.5f;
          }
        };
    b.setRequestFocusEnabled(false);
    b.setMargin(new Insets(1, 1, 1, 1));

    String astr = getProperty(key + actionSuffix);
    if (astr == null) {
      astr = key;
    }
    Action a = getAction(astr);
    if (a != null) {
      b.setActionCommand(astr);
      b.addActionListener(a);
    } else {
      b.setEnabled(false);
    }

    String tip = getResourceString(key + tipSuffix);
    if (tip != null) {
      b.setToolTipText(tip);
    }

    return b;
  }
コード例 #29
0
 private void updateComponents() {
   boolean archetypesEnabled = myUseArchetypeCheckBox.isSelected();
   myAddArchetypeButton.setEnabled(archetypesEnabled);
   myArchetypesTree.setEnabled(archetypesEnabled);
   myArchetypesTree.setBackground(
       archetypesEnabled ? UIUtil.getListBackground() : UIUtil.getPanelBackground());
 }
コード例 #30
0
 public void reset() {
   mySelectedSchema = new CustomActionsSchema();
   mySelectedSchema.copyFrom(CustomActionsSchema.getInstance());
   patchActionsTreeCorrespondingToSchema(
       (DefaultMutableTreeNode) myActionsTree.getModel().getRoot());
   myRestoreAllDefaultButton.setEnabled(mySelectedSchema.isModified(new CustomActionsSchema()));
 }