/** 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();
   }
 }
Esempio n. 2
0
 // サーバーから送られてきたメッセージの処理
 public void reachedMessage(String name, String value) {
   // チャットルームのリストに変更が加えられた
   if (name.equals("rooms")) {
     if (value.equals("")) {
       roomList.setModel(new DefaultListModel());
     } else {
       String[] rooms = value.split(" ");
       roomList.setListData(rooms);
     }
   }
   // ユーザーが入退室した
   else if (name.equals("users")) {
     if (value.equals("")) {
       userList.setModel(new DefaultListModel());
     } else {
       String[] users = value.split(" ");
       userList.setListData(users);
     }
   }
   // メッセージが送られてきた
   else if (name.equals("msg")) {
     msgTextArea.append(value + "\n");
   }
   // 処理に成功した
   else if (name.equals("successful")) {
     if (value.equals("setName")) msgTextArea.append(">名前を変更しました\n");
   }
   // エラーが発生した
   else if (name.equals("error")) {
     msgTextArea.append("ERROR>" + value + "\n");
   }
 }
Esempio n. 3
0
 public void update() {
   setLabels();
   hallList.setListData(getHalls());
   roomItemsList.setListData(getRoomItems());
   Object[] items = (model.getPlayer().getItemList().toArray());
   playerItemsList.setListData(items);
   if (model.playerDied()) endGame("You Lose!");
 }
 /** 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");
   }
 }
 /** 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());
 }
 /** adds a found scan to a seleceted lost package */
 private void buttonSetFoundActionPerformed(ActionEvent event) {
   int index = jListPackages.getSelectedIndex();
   if (index >= 0) {
     Package p = this.packages.get(index);
     if (p.lastScan().event == ScanEvents.lost) {
       p.scan(ScanEvents.found, this.user);
       this.packages.remove(p);
       this.jListPackages.setListData(new Vector(this.packages));
       jListScans.setListData(new Vector());
     }
   }
 }
Esempio n. 7
0
  private void assembleAction() {
    String line;
    messages = new Vector();

    mainFrame.resetExecWindow();

    save();

    assembleFailed = false;
    haveAssemblyErrors = false;

    if (Assembler.version()) {
      while ((line = Assembler.output()) != null) {
        messages.addElement(line);
      }

      Assembler.setPaths(baseName, sourcePath);

      if (Assembler.assemble()) {
        while ((line = Assembler.output()) != null) {
          System.out.println(line);

          messages.addElement(line);

          if (line.startsWith(" [ERROR:")) {
            haveAssemblyErrors = true;
          }
        }

        messageList.setListData(messages);
        messageList.ensureIndexIsVisible(0);

        mainFrame.showExecWindow(baseName);
      } else {
        assembleFailed = true;
      }
    } else {
      assembleFailed = true;
    }

    if (assembleFailed) {
      String message =
          String.format(
              "Autocoder failed!\nVerify the correctness of autocoder path\n%s",
              AssemblerOptions.assemblerPath);
      System.out.println(message);

      JOptionPane.showMessageDialog(this, message, "ROPE", JOptionPane.ERROR_MESSAGE);
    }
  }
  private void updateList() {
    ActionSet actionSet = (ActionSet) combo.getSelectedItem();
    EditAction[] actions = actionSet.getActions();
    Vector listModel = new Vector(actions.length);

    for (int i = 0; i < actions.length; i++) {
      EditAction action = actions[i];
      String label = action.getLabel();
      if (label == null) continue;

      listModel.addElement(new ToolBarOptionPane.Button(action.getName(), null, null, label));
    }

    MiscUtilities.quicksort(listModel, new ToolBarOptionPane.ButtonCompare());
    list.setListData(listModel);
  }
  /// Constructor of WindowApplication class
  public WindowApplication(String title) throws IOException {
    /// Add title and specify size of window
    super(title);
    setSize(850, 700);
    addWindowListener(new WindowDestroyer());

    /// Initialize list and data
    String S[] = {"Source 1", "Source 2", "Source 3"};
    String D[] = {"Dest. 1", "Dest. 2", "Dest. 3", "Dest. 4"};
    String R[] = new String[13];
    String P[] = {"Audio", "Video", "Text"};

    for (int i = 0; i < 13; i++) {
      R[i] = "Router" + String.valueOf(i + 1);
    }

    /// Initialize variables for displaying data on window
    src = new JLabel("Select Source");
    dst = new JLabel("Select Destination");
    rter = new JLabel("Select Router");

    /// List display
    sourceList = new JList();
    routerList = new JList();
    destList = new JList();
    Source = new JScrollPane(sourceList);
    Dest = new JScrollPane(destList);
    Router = new JScrollPane(routerList);

    sourceList.setListData(S);
    destList.setListData(D);
    routerList.setListData(R);

    /// Router info display
    changePrior = new JLabel("Change Priority (0: Highest - 2: Lowest)");
    audio = new JLabel("AUDIO");
    audioVal = new JTextField("");
    aPlus = new JButton("+");
    aMinus = new JButton("-");
    video = new JLabel("VIDEO");
    videoVal = new JTextField("");
    vPlus = new JButton("+");
    vMinus = new JButton("-");
    text = new JLabel("TEXT");
    textVal = new JTextField("");
    tPlus = new JButton("+");
    tMinus = new JButton("-");

    /// Packet type display
    packTypeLabel = new JLabel("Packet Type");
    packTypeList = new JList();
    packType = new JScrollPane(packTypeList);
    packTypeList.setListData(P);

    /// Loss, delay, throughput display
    lossLabel = new JLabel("Loss");
    lossVal = new JTextField("");
    delayLabel = new JLabel("Delay (ms)");
    delayVal = new JTextField("");
    throuLabel = new JLabel("Throughput (Mbps)");
    throuVal = new JTextField("");

    /// Initialize data variable for manipulating lists
    sourceList.addListSelectionListener(new ListHandler());
    destList.addListSelectionListener(new ListHandler());
    routerList.addListSelectionListener(new ListHandler());
    packTypeList.addListSelectionListener(new ListHandler());

    /// Initialize drawing field
    drawTest = new DrawingTester(this);

    /// Initialize data variable for manipulating buttons
    aPlus.addActionListener(new ActionHandler());
    aMinus.addActionListener(new ActionHandler());
    vPlus.addActionListener(new ActionHandler());
    vMinus.addActionListener(new ActionHandler());
    tPlus.addActionListener(new ActionHandler());
    tMinus.addActionListener(new ActionHandler());

    /// Define layout display
    getContentPane().setLayout(null);
    getContentPane().add(drawTest);

    getContentPane().add(src);
    getContentPane().add(dst);
    getContentPane().add(rter);
    getContentPane().add(Source);
    getContentPane().add(Dest);
    getContentPane().add(Router);

    getContentPane().add(changePrior);
    getContentPane().add(audio);
    getContentPane().add(audioVal);
    getContentPane().add(aPlus);
    getContentPane().add(aMinus);
    getContentPane().add(video);
    getContentPane().add(videoVal);
    getContentPane().add(vPlus);
    getContentPane().add(vMinus);
    getContentPane().add(text);
    getContentPane().add(textVal);
    getContentPane().add(tPlus);
    getContentPane().add(tMinus);

    getContentPane().add(packTypeLabel);
    getContentPane().add(packType);

    getContentPane().add(lossLabel);
    getContentPane().add(lossVal);
    getContentPane().add(delayLabel);
    getContentPane().add(delayVal);
    getContentPane().add(throuLabel);
    getContentPane().add(throuVal);

    /// Set bound for display components
    drawTest.setBounds(10, 10, 650, 500);

    src.setBounds(700, 10, 150, 30);
    Source.setBounds(700, 40, 80, 60);

    dst.setBounds(700, 110, 150, 30);
    Dest.setBounds(700, 140, 80, 80);

    rter.setBounds(100, 520, 150, 30);
    Router.setBounds(100, 550, 80, 100);

    changePrior.setBounds(320, 520, 260, 30);
    audio.setBounds(320, 550, 80, 25);
    aPlus.setBounds(380, 550, 45, 25);
    audioVal.setBounds(430, 550, 50, 25);
    aMinus.setBounds(485, 550, 45, 25);

    video.setBounds(320, 585, 80, 25);
    vPlus.setBounds(380, 585, 45, 25);
    videoVal.setBounds(430, 585, 50, 25);
    vMinus.setBounds(485, 585, 45, 25);

    text.setBounds(320, 620, 80, 25);
    tPlus.setBounds(380, 620, 45, 25);
    textVal.setBounds(430, 620, 50, 25);
    tMinus.setBounds(485, 620, 45, 25);

    lossLabel.setBounds(700, 250, 80, 30);
    lossVal.setBounds(700, 280, 100, 30);
    delayLabel.setBounds(700, 320, 80, 30);
    delayVal.setBounds(700, 350, 80, 30);
    throuLabel.setBounds(700, 390, 120, 30);
    throuVal.setBounds(700, 420, 80, 30);

    packTypeLabel.setBounds(620, 520, 80, 30);
    packType.setBounds(620, 550, 60, 60);

    /// Display all the components
    setVisible(true);
  }
 public void flush() {
   ArrayList<Item> alItem = father.idp.alItem;
   jl.setListData(alItem.toArray());
 }
Esempio n. 11
0
 private void fillSequenceChooser() {
   sequenceToShowChooser.setListData(sequenceValues.toArray(new Value[sequenceValues.size()]));
   sequenceToShowChooser.setSelectionInterval(0, sequenceValues.size() - 1);
 }
Esempio n. 12
0
  public CellarGUI(Cellar model) {
    this.model = model;
    setTitle("Cellar");
    setSize(new Dimension(1000, 600));
    setResizable(false);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new BorderLayout());
    health.setPreferredSize(new Dimension(200, 10));
    exp.setPreferredSize(new Dimension(200, 10));
    currentRoom.setPreferredSize(new Dimension(200, 10));
    spacer.setPreferredSize(new Dimension(200, 115));
    magicLabel.setPreferredSize(new Dimension(200, 10));
    magicLabel.setHorizontalAlignment(JLabel.CENTER);
    playerItemLabel.setText("Player's Items (Max 1)");
    setLabels();

    JScrollPane playerItemsPane = new JScrollPane();
    playerItemsList.setListData(model.getPlayer().getItemList().toArray());
    playerItemsPane.setViewportView(playerItemsList);
    playerItemsPane.setPreferredSize(new Dimension(200, 125));
    JButton drop = new JButton("Drop Item");
    drop.addActionListener(this);
    drop.setPreferredSize(new Dimension(200, 25));

    JScrollPane roomItemsPane = new JScrollPane();
    roomItemsList = new JList(getRoomItems());
    roomItemsPane.setViewportView(roomItemsList);
    roomItemsPane.setPreferredSize(new Dimension(200, 125));
    JButton pickUp = new JButton("Pick Up");
    pickUp.addActionListener(this);
    pickUp.setPreferredSize(new Dimension(200, 25));

    JScrollPane hallsPane = new JScrollPane();
    hallList = new JList(getHalls());
    hallsPane.setViewportView(hallList);
    hallsPane.setPreferredSize(new Dimension(200, 200));
    JButton enterHall = new JButton("Enter Hallway");
    enterHall.setPreferredSize(new Dimension(200, 25));
    enterHall.addActionListener(this);

    JScrollPane outputPane = new JScrollPane();
    output = new JTextArea();
    outputPane.setPreferredSize(new Dimension(550, 550));
    output.setEditable(false);
    output.setBorder(BorderFactory.createLineBorder(Color.black));
    outputPane.setViewportView(output);

    JLabel roomItemLabel = new JLabel("Items in the Room");
    JLabel hallsLabel = new JLabel("Hallways");
    JPanel rightPanel = new JPanel();
    JPanel leftPanel = new JPanel();
    rightPanel.add(playerItemLabel);
    rightPanel.add(playerItemsPane);
    rightPanel.add(drop);
    rightPanel.add(roomItemLabel);
    rightPanel.add(roomItemsPane);
    rightPanel.add(pickUp);
    rightPanel.add(magicLabel);
    rightPanel.add(magic);
    rightPanel.add(spacer);
    rightPanel.add(health);
    rightPanel.add(exp);
    rightPanel.add(currentRoom);
    rightPanel.setPreferredSize(new Dimension(200, 600));
    rightPanel.setBackground(Color.WHITE);
    leftPanel.add(hallsLabel);
    leftPanel.add(hallsPane);
    leftPanel.add(enterHall);
    leftPanel.setPreferredSize(new Dimension(200, 600));
    leftPanel.setBackground(Color.WHITE);
    add(outputPane, BorderLayout.CENTER);
    add(rightPanel, BorderLayout.WEST);
    add(leftPanel, BorderLayout.EAST);
  }
 /**
  * Handles selected index change for the packages Jlist. Dsiplays the scan history of the selected
  * package in the scans JList.
  */
 private void jListPackagesActionPertformed(ListSelectionEvent event) {
   int index = jListPackages.getSelectedIndex();
   if (index >= 0) jListScans.setListData(new Vector(this.packages.get(index).scanHistory));
 }
Esempio n. 14
0
 /** sorts the user list and rebuilds the user list from the sorted user vector, */
 public void updateList() {
   Object[] tmp = users.toArray();
   Arrays.sort(tmp);
   userList.setListData(tmp);
 }