コード例 #1
2
  public void changeLAF(int iLAFIndex) {
    try {
      // Change LAF
      if (iLAFIndex >= marrLaf.length) iLAFIndex = marrLaf.length - 1;
      UIManager.setLookAndFeel(
          (LookAndFeel) Class.forName(marrLaf[iLAFIndex].getClassName()).newInstance());

      // Update UI
      ((JMenuItem) mvtLAFItem.elementAt(iLAFIndex)).setSelected(true);
      SwingUtilities.updateComponentTreeUI(this);
      SwingUtilities.updateComponentTreeUI(mnuMain);
      WindowManager.updateLookAndField();

      // Store config
      try {
        Hashtable prt = Global.loadHashtable(Global.FILE_CONFIG);
        prt.put("LAF", String.valueOf(iLAFIndex));
        Global.storeHashtable(prt, Global.FILE_CONFIG);
      } catch (Exception e) {
      }
    } catch (Exception e) {
      e.printStackTrace();
      MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
    }
  }
コード例 #2
0
ファイル: BasicFrame.java プロジェクト: benlakey/breakout
 /** Sets the options. */
 public void setOptions() {
   _optionsDialog.setVisible(false);
   _gameOptions.put("brickCount", _optionsDialog.getBrickCount());
   _gameOptions.put("hitsToRemoveBrick", _optionsDialog.getHitsToRemoveBrick());
   _gameOptions.put("ballsPerLevel", _optionsDialog.getBallsPerLevel());
   _gameOptions.put("nextLevelSpeedJump", _optionsDialog.getLevelSpeedup());
   resetGame();
   repaint();
 }
コード例 #3
0
  public void addLayoutView(ViewI view, Object constraints) {

    // By default views are managed
    if (constraints == null) {
      viewmap.put(view, BOTH);
    } else {
      viewmap.put(view, constraints);
    }
    //  System.out.println("returned from addLayoutView");
  }
コード例 #4
0
ファイル: CGEditor.java プロジェクト: raghunayak/mico
public void AddTemplate (String menuname, Vector after,
			 String entryname, ConceptualGraph cg)
    {
	Hashtable menu = (Hashtable)menus.get (menuname);
	if (menu == null) {
	    menu = new Hashtable ();
	    menus.put (menuname, menu);
	}
	menu.put (entryname, cg);
	for (int i = 0; i < after.size(); ++i) {
	    String concept = (String)after.elementAt (i);
	    if (!menumap.containsKey (concept))
		menumap.put (concept, menuname);
	}
    }
コード例 #5
0
ファイル: Outline.java プロジェクト: ShifuCifuentes/ridixcr
  /**
   * Called to create a map the parent of each bookmark.
   *
   * @param parent top level bookmark.
   * @param parentMap map to add children to.
   * @param pagenoVector vector of page numbers.
   * @param depth object indicating bookmark depth.
   */
  protected void mapChildren(
      final Bookmark parent,
      final Hashtable parentMap,
      final Vector pagenoVector,
      final Number depth) {
    getDepthMap().put(parent, depth);

    final int pageno = parent.getPageno();

    if (pageno >= 0) {
      while (pageno >= pagenoVector.size()) {
        pagenoVector.addElement(null);
      }

      pagenoVector.setElementAt(parent, pageno);
    }

    final Enumeration e = parent.elements();

    if (e.hasMoreElements()) {
      final Number childDepth = new Integer(depth.intValue() + 1);

      do {
        final Bookmark child = (Bookmark) e.nextElement();
        parentMap.put(child, parent);
        mapChildren(child, parentMap, pagenoVector, childDepth);
      } while (e.hasMoreElements());
    }
  }
コード例 #6
0
  public void changeDictionary(String strLanguage) {
    // Change dictionary
    MonitorDictionary.setCurrentLanguage(strLanguage);
    DefaultDictionary.setCurrentLanguage(strLanguage);
    ErrorDictionary.setCurrentLanguage(strLanguage);

    // Update UI
    updateLanguage();
    WindowManager.updateLanguage();
    int iIndex = mvtLanguage.indexOf(strLanguage);
    if (iIndex >= 0) {
      JRadioButtonMenuItem mnu = (JRadioButtonMenuItem) mvtLanguageItem.elementAt(iIndex);
      mnu.setSelected(true);
    }

    // Store config
    Hashtable prt = null;
    try {
      prt = Global.loadHashtable(Global.FILE_CONFIG);
    } catch (Exception e) {
      prt = new Hashtable();
    }
    prt.put("Language", strLanguage);
    try {
      Global.storeHashtable(prt, Global.FILE_CONFIG);
    } catch (Exception e) {
    }
  }
コード例 #7
0
ファイル: GenericDialog.java プロジェクト: aschain/ImageJA
 private void saveLabel(Object component, String label) {
   if (labels == null) labels = new Hashtable();
   if (label.length() > 0) {
     if (label.charAt(0) == ' ') label = label.trim();
     labels.put(component, label);
   }
 }
コード例 #8
0
ファイル: CallManager.java プロジェクト: ymatlashenko/olyo
  /**
   * Implements CallListener.incomingCallReceived. When a call is received creates a call panel and
   * adds it to the main tabbed pane and plays the ring phone sound to the user.
   */
  public void incomingCallReceived(CallEvent event) {
    Call sourceCall = event.getSourceCall();

    CallPanel callPanel = new CallPanel(this, sourceCall, GuiCallParticipantRecord.INCOMING_CALL);

    mainFrame.addCallPanel(callPanel);

    if (mainFrame.getState() == JFrame.ICONIFIED) mainFrame.setState(JFrame.NORMAL);

    if (!mainFrame.isVisible()) mainFrame.setVisible(true);

    mainFrame.toFront();

    this.callButton.setEnabled(true);
    this.hangupButton.setEnabled(true);

    NotificationManager.fireNotification(
        NotificationManager.INCOMING_CALL,
        null,
        "Incoming call recived from: " + sourceCall.getCallParticipants().next());

    activeCalls.put(sourceCall, callPanel);

    this.setCallPanelVisible(true);
  }
コード例 #9
0
ファイル: LlamaChat.java プロジェクト: raulgq1/LlamaChat
 /**
  * creates a new channel, if the channel exists it is removed (this method doubles as a
  * removeChannel)
  *
  * @param name the name of the channel
  */
 public void newChannel(String name, boolean pass) {
   if (channels.containsKey(name)) {
     channels.remove(name);
     cboChannels.removeItem(name);
   } else {
     channels.put(name, new Boolean(pass));
     cboChannels.addItem(name);
   }
 }
コード例 #10
0
 public void addMenuItem(String text, String loc) {
   locations.put(text, loc);
   if (filenames.contains("Test Text")) {
     filenames.remove("Test Text");
     filenames.addElement(text);
   } else {
     filenames.addElement(text);
   }
   createPopupMenu();
 }
コード例 #11
0
  public void register() {
    debug.out.println("RADIOMODEL: registering radio model plugin");
    connectivityGraph = new Hashtable();

    EmpiricalModel empiricalModel = new EmpiricalModel();
    models.put("empirical", empiricalModel);
    curModel = empiricalModel;

    // User can use scaling factor to adjust
    DiscModel dm;
    dm = new DiscModel(10.0);
    models.put("disc10", dm);
    dm = new DiscModel(100.0);
    models.put("disc100", dm);
    dm = new DiscModel(1000.0);
    models.put("disc1000", dm);

    updateModel();
  }
コード例 #12
0
  /**
   * register keystrokes here which are for the WHEN_IN_FOCUSED_WINDOW case. Other types of
   * keystrokes will be handled by walking the hierarchy That simplifies some potentially hairy
   * stuff.
   */
  public void registerKeyStroke(KeyStroke k, JComponent c) {
    Container topContainer = getTopAncestor(c);
    if (topContainer == null) {
      return;
    }
    Hashtable keyMap = containerMap.get(topContainer);

    if (keyMap == null) { // lazy evaluate one
      keyMap = registerNewTopContainer(topContainer);
    }

    Object tmp = keyMap.get(k);
    if (tmp == null) {
      keyMap.put(k, c);
    } else if (tmp instanceof Vector) { // if there's a Vector there then add to it.
      Vector v = (Vector) tmp;
      if (!v.contains(c)) { // only add if this keystroke isn't registered for this component
        v.addElement(c);
      }
    } else if (tmp instanceof JComponent) {
      // if a JComponent is there then remove it and replace it with a vector
      // Then add the old compoennt and the new compoent to the vector
      // then insert the vector in the table
      if (tmp != c) { // this means this is already registered for this component, no need to dup
        Vector<JComponent> v = new Vector<JComponent>();
        v.addElement((JComponent) tmp);
        v.addElement(c);
        keyMap.put(k, v);
      }
    } else {
      System.out.println("Unexpected condition in registerKeyStroke");
      Thread.dumpStack();
    }

    componentKeyStrokeMap.put(new ComponentKeyStrokePair(c, k), topContainer);

    // Check for EmbeddedFrame case, they know how to process accelerators even
    // when focus is not in Java
    if (topContainer instanceof EmbeddedFrame) {
      ((EmbeddedFrame) topContainer).registerAccelerator(k);
    }
  }
コード例 #13
0
ファイル: Installer.java プロジェクト: suever/CTP
 private static Hashtable<String, String> getManifestAttributes(Manifest manifest) {
   Hashtable<String, String> h = new Hashtable<String, String>();
   try {
     Attributes attrs = manifest.getMainAttributes();
     Iterator it = attrs.keySet().iterator();
     while (it.hasNext()) {
       String key = it.next().toString();
       h.put(key, attrs.getValue(key));
     }
   } catch (Exception ignore) {
   }
   return h;
 }
コード例 #14
0
ファイル: BasicFrame.java プロジェクト: benlakey/breakout
 private void generateGameOptions() {
   _gameOptions = new Hashtable<String, Integer>();
   _gameOptions.put("brickCount", initialOptions.brickCount);
   _gameOptions.put("hitsToRemoveBrick", initialOptions.hitsToRemoveBrick);
   _gameOptions.put("ballsPerLevel", initialOptions.ballsPerLevel);
   _gameOptions.put("nextLevelSpeedJump", initialOptions.nextLevelSpeedJump);
   _gameOptions.put("fieldPixelWidth", initialOptions.fieldPixelWidth);
   _gameOptions.put("fieldPixelHeight", initialOptions.fieldPixelHeight);
 }
コード例 #15
0
  /**
   * Expands the sub folders and image informations under the specified node.
   *
   * @param node the node.
   */
  protected void expandNode(DefaultMutableTreeNode node) {
    try {
      Object[] paths = node.getPath();

      String path_str = "";
      Vector folder_list = new Vector();
      for (int i = 1; i < paths.length; i++) {
        String name = (String) ((DefaultMutableTreeNode) paths[i]).getUserObject();
        path_str += "/" + name;

        // Converts January...December to 1...12.
        if (mode == DATE_ORIENTED && i == 2) {
          for (int m = 1; m <= 12; m++) {
            if (JulianDay.getFullSpellMonthString(m).equals(name)) name = String.valueOf(m);
          }
        }

        folder_list.addElement(name);
      }

      // When to expand sub folders.
      Vector folders = new Vector();
      if (mode == DATE_ORIENTED) folders = db_manager.getDateOrientedFolders(folder_list);
      if (mode == PATH_ORIENTED) folders = db_manager.getPathOrientedFolders(folder_list);
      addNode(node, folders);

      // When to expand image informations.
      XmlDBAccessor accessor = null;
      if (mode == DATE_ORIENTED) accessor = db_manager.getDateOrientedAccessor(folder_list);
      if (mode == PATH_ORIENTED) accessor = db_manager.getPathOrientedAccessor(folder_list);
      if (accessor != null) {
        Vector name_list = new Vector();
        XmlInformation info = (XmlInformation) accessor.getFirstElement();
        while (info != null) {
          name_list.addElement(info.getPath());
          hash_info.put(path_str + "/" + info.getPath(), info);
          info = (XmlInformation) accessor.getNextElement();
        }
        addNode(node, name_list);
      }

      revalidate();
      repaint();
    } catch (IOException exception) {
      String message = "Failed to read the database.";
      JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
コード例 #16
0
 private Hashtable buildReverseMap(InputMap im) {
   KeyStroke k[] = im.allKeys();
   Hashtable h = new Hashtable();
   if (k != null) {
     for (int i = 0; i < k.length; i++) {
       Object nk = im.get(k[i]);
       Object cv = h.get(nk);
       if (h.containsKey(nk)) {
         ((Vector) cv).add(k[i]);
       } else {
         Vector v = new Vector();
         v.add(k[i]);
         h.put(nk, v);
       }
     }
   }
   return h;
 }
コード例 #17
0
ファイル: ControlPanel.java プロジェクト: johnperry/Geneva2
 private void load() {
   File file = new File(filename);
   if (file.exists()) {
     try {
       Document doc = XmlUtil.getDocument(file);
       Element root = doc.getDocumentElement();
       Node child = root.getFirstChild();
       while (child != null) {
         if (child.getNodeType() == Node.ELEMENT_NODE) {
           Profile p = new Profile((Element) child);
           table.put(p.name, p);
         }
         child = child.getNextSibling();
       }
     } catch (Exception ignore) {
     }
   }
 }
コード例 #18
0
  // Recalculate the loss rate for the pair of motes based on their
  // distance and the current model
  public void updateLossRate(MoteSimObject moteSender, MoteSimObject moteReceiver) {
    double distance = moteSender.getDistance(moteReceiver);
    double prob = curModel.getPacketLossRate(distance, this.scalingFactor);

    debug.out.println(
        "RADIOMODEL: "
            + moteSender
            + "->"
            + moteReceiver
            + " dist "
            + distance
            + " scale "
            + scalingFactor
            + " prob "
            + prob);

    long scaledBitLossRate = (long) (curModel.getBitLossRate(prob) * 10000);

    debug.out.println(
        "RADIOMODEL: sampleLossRate "
            + "[moteSender "
            + moteSender
            + "] 1"
            + "[moteReceiver "
            + moteReceiver
            + "] "
            + "[packetLossRate "
            + prob
            + "] "
            + "[scaledBitLossRate "
            + scaledBitLossRate
            + "]");

    connectivityGraph.put(graphKey(moteSender, moteReceiver), new Double(prob));

    if (autoPublish) {
      publishLossRate(moteSender, moteReceiver, prob);
    }
  }
コード例 #19
0
  public void registerMenuBar(JMenuBar mb) {
    Container top = getTopAncestor(mb);
    if (top == null) {
      return;
    }
    Hashtable keyMap = containerMap.get(top);

    if (keyMap == null) { // lazy evaluate one
      keyMap = registerNewTopContainer(top);
    }
    // use the menubar class as the key
    Vector menuBars = (Vector) keyMap.get(JMenuBar.class);

    if (menuBars == null) { // if we don't have a list of menubars,
      // then make one.
      menuBars = new Vector();
      keyMap.put(JMenuBar.class, menuBars);
    }

    if (!menuBars.contains(mb)) {
      menuBars.addElement(mb);
    }
  }
コード例 #20
0
 protected Hashtable registerNewTopContainer(Container topContainer) {
   Hashtable keyMap = new Hashtable();
   containerMap.put(topContainer, keyMap);
   return keyMap;
 }
コード例 #21
0
 public void setLossRate(MoteSimObject sender, MoteSimObject receiver, double prob) {
   connectivityGraph.put(graphKey(sender, receiver), new Double(prob));
 }
コード例 #22
0
ファイル: InputHandler.java プロジェクト: ieugen/squirrel-sql
	static
	{
		actions = new Hashtable();
		actions.put("backspace",BACKSPACE);
		actions.put("backspace-word",BACKSPACE_WORD);
		actions.put("delete",DELETE);
		actions.put("delete-word",DELETE_WORD);
		actions.put("end",END);
		actions.put("select-end",SELECT_END);
		actions.put("document-end",DOCUMENT_END);
		actions.put("select-doc-end",SELECT_DOC_END);
		actions.put("insert-break",INSERT_BREAK);
		actions.put("insert-tab",INSERT_TAB);
		actions.put("home",HOME);
		actions.put("select-home",SELECT_HOME);
		actions.put("document-home",DOCUMENT_HOME);
		actions.put("select-doc-home",SELECT_DOC_HOME);
		actions.put("next-char",NEXT_CHAR);
		actions.put("next-line",NEXT_LINE);
		actions.put("next-page",NEXT_PAGE);
		actions.put("next-word",NEXT_WORD);
		actions.put("select-next-char",SELECT_NEXT_CHAR);
		actions.put("select-next-line",SELECT_NEXT_LINE);
		actions.put("select-next-page",SELECT_NEXT_PAGE);
		actions.put("select-next-word",SELECT_NEXT_WORD);
		actions.put("overwrite",OVERWRITE);
		actions.put("prev-char",PREV_CHAR);
		actions.put("prev-line",PREV_LINE);
		actions.put("prev-page",PREV_PAGE);
		actions.put("prev-word",PREV_WORD);
		actions.put("select-prev-char",SELECT_PREV_CHAR);
		actions.put("select-prev-line",SELECT_PREV_LINE);
		actions.put("select-prev-page",SELECT_PREV_PAGE);
		actions.put("select-prev-word",SELECT_PREV_WORD);
		actions.put("repeat",REPEAT);
		actions.put("toggle-rect",TOGGLE_RECT);
		actions.put("insert-char",INSERT_CHAR);
	}
コード例 #23
0
  // Initializes this component.
  private void jbInit() {
    fileChooser.setFileFilter(new ScriptFileFilter());
    this.getContentPane().setLayout(null);

    Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();

    JLabel slowLabel = new JLabel("Slow");
    slowLabel.setFont(Utilities.thinLabelsFont);
    JLabel fastLabel = new JLabel("Fast");
    fastLabel.setFont(Utilities.thinLabelsFont);
    labelTable.put(1, slowLabel);
    labelTable.put(5, fastLabel);

    speedSlider.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            SpeedSlider_stateChanged(e);
          }
        });
    speedSlider.setLabelTable(labelTable);
    speedSlider.setMajorTickSpacing(1);
    speedSlider.setPaintTicks(true);
    speedSlider.setPaintLabels(true);
    speedSlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
    speedSlider.setPreferredSize(new Dimension(95, 50));
    speedSlider.setMinimumSize(new Dimension(95, 50));
    speedSlider.setToolTipText("Speed");
    speedSlider.setMaximumSize(new Dimension(95, 50));

    final Dimension buttonSize = new Dimension(39, 39);

    loadProgramButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            loadProgramButton_actionPerformed();
          }
        });
    loadProgramButton.setMaximumSize(buttonSize);
    loadProgramButton.setMinimumSize(buttonSize);
    loadProgramButton.setPreferredSize(buttonSize);
    loadProgramButton.setSize(buttonSize);
    loadProgramButton.setToolTipText("Load Program");
    loadProgramButton.setIcon(loadProgramIcon);

    ffwdButton.setMaximumSize(buttonSize);
    ffwdButton.setMinimumSize(buttonSize);
    ffwdButton.setPreferredSize(buttonSize);
    ffwdButton.setToolTipText("Run");
    ffwdButton.setIcon(ffwdIcon);
    ffwdButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ffwdButton_actionPerformed();
          }
        });

    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stopButton_actionPerformed();
          }
        });
    stopButton.setMaximumSize(buttonSize);
    stopButton.setMinimumSize(buttonSize);
    stopButton.setPreferredSize(buttonSize);
    stopButton.setToolTipText("Stop");
    stopButton.setIcon(stopIcon);

    rewindButton.setMaximumSize(buttonSize);
    rewindButton.setMinimumSize(buttonSize);
    rewindButton.setPreferredSize(buttonSize);
    rewindButton.setToolTipText("Reset");
    rewindButton.setIcon(rewindIcon);
    rewindButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rewindButton_actionPerformed();
          }
        });

    scriptButton.setMaximumSize(buttonSize);
    scriptButton.setMinimumSize(buttonSize);
    scriptButton.setPreferredSize(buttonSize);
    scriptButton.setToolTipText("Load Script");
    scriptButton.setIcon(scriptIcon);
    scriptButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            scriptButton_actionPerformed();
          }
        });

    breakButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            breakButton_actionPerformed();
          }
        });
    breakButton.setMaximumSize(buttonSize);
    breakButton.setMinimumSize(buttonSize);
    breakButton.setPreferredSize(buttonSize);
    breakButton.setToolTipText("Open breakpoint panel");
    breakButton.setIcon(breakIcon);

    breakpointWindow.addBreakpointListener(this);

    singleStepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            singleStepButton_actionPerformed();
          }
        });
    singleStepButton.setMaximumSize(buttonSize);
    singleStepButton.setMinimumSize(buttonSize);
    singleStepButton.setPreferredSize(buttonSize);
    singleStepButton.setSize(buttonSize);
    singleStepButton.setToolTipText("Single Step");
    singleStepButton.setIcon(singleStepIcon);

    stepOverButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stepOverButton_actionPerformed();
          }
        });
    stepOverButton.setMaximumSize(buttonSize);
    stepOverButton.setMinimumSize(buttonSize);
    stepOverButton.setPreferredSize(buttonSize);
    stepOverButton.setSize(buttonSize);
    stepOverButton.setToolTipText("Step Over");
    stepOverButton.setIcon(stepOverIcon);

    animationCombo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            animationCombo_actionPerformed();
          }
        });

    formatCombo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            formatCombo_actionPerformed();
          }
        });

    additionalDisplayCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            additionalDisplayCombo_actionPerformed();
          }
        });

    messageLbl.setFont(Utilities.statusLineFont);
    messageLbl.setBorder(BorderFactory.createLoweredBevelBorder());
    messageLbl.setBounds(new Rectangle(0, 667, CONTROLLER_WIDTH - 8, 25));

    toolBar = new JToolBar();
    toolBar.setSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    toolBar.setFloatable(false);
    toolBar.setLocation(0, 0);
    toolBar.setBorder(BorderFactory.createEtchedBorder());
    arrangeToolBar();
    this.getContentPane().add(toolBar, null);
    toolBar.revalidate();
    toolBar.repaint();
    repaint();

    // Creating the menu bar
    menuBar = new JMenuBar();
    arrangeMenu();
    setJMenuBar(menuBar);

    this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    this.getContentPane().add(messageLbl, null);

    setControllerSize();

    // sets the frame to be visible.
    setVisible(true);
  }
コード例 #24
0
ファイル: KeyHandler.java プロジェクト: kdeloach/kipper
 @Override
 public void keyReleased(KeyEvent e) {
   isShiftDown = e.isShiftDown();
   justReleased.put(e.getKeyCode(), true);
 }
コード例 #25
0
 public void cacheIcon(File f, Icon i) {
   if (f == null || i == null) {
     return;
   }
   iconCache.put(f, i);
 }
コード例 #26
0
  /** Loads the configuration form obtained from the chat room. */
  protected void loadConfigurationForm() {
    Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet();

    while (configurationSet.hasNext()) {
      ChatRoomConfigurationFormField formField = configurationSet.next();

      Iterator<?> values = formField.getValues();
      Iterator<String> options = formField.getOptions();

      JComponent field;
      JLabel label = new JLabel("", JLabel.RIGHT);

      if (formField.getLabel() != null) label.setText(formField.getLabel() + ": ");

      String fieldType = formField.getType();

      if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_BOOLEAN)) {
        // Create a check box when the field is of type boolean.
        field = new SIPCommCheckBox(formField.getLabel());
        label.setText("");

        if (values.hasNext()) {
          ((JCheckBox) field).setSelected((Boolean) values.next());
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) {
        field = new JLabel();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JLabel) field).setText(value);
          field.setFont(new Font(null, Font.ITALIC, 10));
          field.setForeground(Color.GRAY);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_MULTI)) {
        field = new TransparentPanel(new GridLayout(0, 1));

        field.setBorder(BorderFactory.createLineBorder(Color.GRAY));

        Hashtable<Object, JCheckBox> optionCheckBoxes = new Hashtable<Object, JCheckBox>();

        while (options.hasNext()) {
          Object option = options.next();
          JCheckBox checkBox = new SIPCommCheckBox(option.toString());

          field.add(checkBox);
          optionCheckBoxes.put(option, checkBox);
        }

        while (values.hasNext()) {
          Object value = values.next();

          (optionCheckBoxes.get(value)).setSelected(true);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_SINGLE)) {
        field = new JComboBox();

        while (options.hasNext()) {
          ((JComboBox) field).addItem(options.next());
        }

        if (values.hasNext()) {
          ((JComboBox) field).setSelectedItem(values.next());
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_MULTI)) {
        field = new JEditorPane();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JEditorPane) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_SINGLE)
          || fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_SINGLE)) {
        field = new JTextField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JTextField) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_PRIVATE)) {
        field = new JPasswordField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JPasswordField) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) {
        StringBuffer buff = new StringBuffer();

        while (values.hasNext()) {
          String value = values.next().toString();
          buff.append(value);

          if (values.hasNext()) buff.append(System.getProperty("line.separator"));
        }
        field = new JTextArea(buff.toString());
      } else {
        if (label.getText() == null) continue;

        field = new JTextField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JTextField) field).setText(value);
        }
      }

      // If the field is not fixed (i.e. could be changed) we would like
      // to save it in a list in order to use it later when user saves
      // the configuration data.
      if (!fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) {
        uiFieldsTable.put(formField.getName(), field);
      }

      JPanel fieldPanel = new TransparentPanel(new GridLayout(1, 2));
      fieldPanel.setOpaque(false);

      if (!(field instanceof JLabel))
        fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
      else fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0));

      fieldPanel.add(label);
      fieldPanel.add(field);

      this.mainPanel.add(fieldPanel);
    }
  }
コード例 #27
0
ファイル: Client.java プロジェクト: scopeInfinity/stockmart
 public void run() {
   while (connected) {
     try {
       Object obj = in.readObject();
       if (obj.toString().equals("-101")) {
         connected = false;
         in.close();
         out.close();
         socket.close();
         SwingUtilities.invokeLater(
             new Runnable() {
               public void run() {
                 Cashier.closee = true;
                 JOptionPane.showMessageDialog(
                     null,
                     "Disconnected from server. Please Restart",
                     "Error:",
                     JOptionPane.PLAIN_MESSAGE);
                 try {
                   m.stop();
                 } catch (Exception w) {
                 }
               }
             });
       } else if (obj.toString().split("::")[0].equals("broadcast")) {
         // System.out.println("braodcast received");
         bc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else if (obj.toString().split("::")[0].equals("chat")) {
         // System.out.println("chat received:
         // "+obj.toString().substring(obj.toString().indexOf("::")+2));
         cc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else if (obj.toString().split("::")[0].equals("rankings")) {
         String hhh = obj.toString().split("::")[1];
         final JDialog jd = new JDialog();
         jd.setUndecorated(false);
         JPanel pan = new JPanel(new BorderLayout());
         JLabel ppp = new JLabel();
         ppp.setFont(new Font("Arial", Font.BOLD, 20));
         ppp.setText(
             "<html><pre>Thanks for playing !!!<br/>1st: "
                 + hhh.split(":")[0]
                 + "<br/>2nd: "
                 + hhh.split(":")[1]
                 + "<br/>3rd: "
                 + hhh.split(":")[2]
                 + "</pre></html>");
         pan.add(ppp, BorderLayout.CENTER);
         JButton ok = new JButton("Ok");
         ok.addActionListener(
             new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                 jd.setVisible(false);
                 try {
                   m.stop();
                 } catch (Exception w) {
                 }
               }
             });
         pan.add(ok, BorderLayout.SOUTH);
         jd.setContentPane(pan);
         jd.setModalityType(JDialog.ModalityType.APPLICATION_MODAL);
         jd.pack();
         jd.setLocationRelativeTo(null);
         jd.setVisible(true);
       } else if (obj.toString().split("::")[0].equals("rank")) {
         rc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else {
         User hhh = null;
         try {
           hhh = (User) obj;
           /*if(usrD==1)
           {
               reply=obj;
               ccl.interrupt();
           }
           else*/
           {
             try {
               m.ur.changeData((User) obj);
             } catch (Exception w) {
               try {
                 maain.ur.changeData((User) obj);
               } catch (Exception ppp) {
                 ppp.printStackTrace();
               }
             }
           }
         } catch (Exception p) {
           int iid = -1;
           try {
             iid = Integer.parseInt(obj.toString());
             obj = in.readObject();
             if (obj.toString().equals("-102")) {
               // ccl.interrupt();
               SwingUtilities.invokeLater(
                   new Runnable() {
                     public void run() {
                       Cashier.closee = true;
                       JOptionPane.showMessageDialog(
                           null, "Server Not Running.", "Error:", JOptionPane.PLAIN_MESSAGE);
                     }
                   });
             }
             // Thread th = ((Thread)rev.remove(iid));
             rev2.put(iid, obj);
             // System.out.println("Put: "+iid+"   :   "+obj.toString()+"   :
             // "+Thread.currentThread());
             // th.interrupt();
             // ccl.interrupt();
           } catch (Exception ppp) {
               /*ppp.printStackTrace();*/
             System.out.println(
                 "Shit: "
                     + iid
                     + "   :   "
                     + obj.toString()
                     + "   :   "
                     + Thread.currentThread());
           }
         }
       }
       try {
         Thread.sleep(500);
       } catch (Exception n) {
       }
     } catch (Exception m) {
     }
   }
 }
コード例 #28
0
    private void makeComponents() {
      this.getWwd().setPreferredSize(new Dimension(1024, 768));

      JPanel panel = new JPanel(new BorderLayout());
      {
        panel.setBorder(new EmptyBorder(10, 0, 10, 0));

        JPanel controlPanel = new JPanel(new BorderLayout(0, 10));
        controlPanel.setBorder(new EmptyBorder(20, 10, 20, 10));

        JPanel btnPanel = new JPanel(new GridLayout(5, 1, 0, 5));
        {
          JButton btn = new JButton("Zoom to Matterhorn");
          btn.setActionCommand(ACTION_COMMAND_BUTTON1);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO getElevations()");
          btn.setActionCommand(ACTION_COMMAND_BUTTON2);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO getElevation()");
          btn.setActionCommand(ACTION_COMMAND_BUTTON3);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO new getElevations");
          btn.setActionCommand(ACTION_COMMAND_BUTTON4);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          //                    btn = new JButton("Button 5");
          //                    btn.setActionCommand(ACTION_COMMAND_BUTTON5);
          //                    btn.addActionListener(this.controller);
          //                    btnPanel.add(btn);
        }
        controlPanel.add(btnPanel, BorderLayout.NORTH);

        JPanel vePanel = new JPanel(new BorderLayout(0, 5));
        {
          JLabel label = new JLabel("Vertical Exaggeration");
          vePanel.add(label, BorderLayout.NORTH);

          int MIN_VE = 1;
          int MAX_VE = 8;
          int curVe = (int) this.getWwd().getSceneController().getVerticalExaggeration();
          curVe = curVe < MIN_VE ? MIN_VE : (curVe > MAX_VE ? MAX_VE : curVe);
          JSlider slider = new JSlider(MIN_VE, MAX_VE, curVe);
          slider.setMajorTickSpacing(1);
          slider.setPaintTicks(true);
          slider.setSnapToTicks(true);
          Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
          labelTable.put(1, new JLabel("1x"));
          labelTable.put(2, new JLabel("2x"));
          labelTable.put(4, new JLabel("4x"));
          labelTable.put(8, new JLabel("8x"));
          slider.setLabelTable(labelTable);
          slider.setPaintLabels(true);
          slider.addChangeListener(
              new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                  double ve = ((JSlider) e.getSource()).getValue();
                  ActionEvent ae = new ActionEvent(ve, 0, ACTION_COMMAND_VERTICAL_EXAGGERATION);
                  controller.actionPerformed(ae);
                }
              });
          vePanel.add(slider, BorderLayout.SOUTH);
        }
        controlPanel.add(vePanel, BorderLayout.SOUTH);

        panel.add(controlPanel, BorderLayout.SOUTH);

        this.layerPanel = new LayerPanel(this.getWwd(), null);
        panel.add(this.layerPanel, BorderLayout.CENTER);
      }
      getContentPane().add(panel, BorderLayout.WEST);
    }
コード例 #29
0
ファイル: ControlPanel.java プロジェクト: johnperry/Geneva2
 public void add(Profile profile) {
   table.put(profile.name, profile);
   save();
 }
コード例 #30
0
 public void setLossRate(int senderID, int receiverID, double prob) {
   connectivityGraph.put(graphKey(senderID, receiverID), new Double(prob));
 }