public void search() {
    hilit.removeAllHighlights();

    String s = entry.getText();
    if (s.length() <= 0) {
      message("Nothing to search");
      return;
    }

    String content = textArea.getText();
    int index = content.indexOf(s, 0);
    if (index >= 0) {
      try {
        int end = index + s.length();
        hilit.addHighlight(index, end, painter);
        textArea.setCaretPosition(end);
        entry.setBackground(entryBg);
        message("'" + s + "' found. Press ESC to end search");
      } catch (BadLocationException e) {
        e.printStackTrace();
      }
    } else {
      entry.setBackground(ERROR_COLOR);
      message("'" + s + "' found. Press ESC to start a new search");
    }
  }
Example #2
0
  @Override
  protected void prepareComponent(
      JPanel component,
      HierarchicalTable<Property> table,
      Property property,
      Object value,
      boolean isSelected,
      boolean hasFocus,
      int row,
      int column,
      boolean forEditor) {
    super.prepareComponent(
        component, table, property, value, isSelected, hasFocus, row, column, forEditor);

    if (property.getButtonText() == null) {
      button.setVisible(false);
    } else {
      button.setVisible(true);
      button.setText(property.getButtonText());
      button.setToolTipText(property.getButtonTooltip());
    }

    if (isSelected && !forEditor) {
      textfield.setBackground(table.getSelectionBackground());
      textfield.setForeground(table.getSelectionForeground());
    } else {
      textfield.setBackground(table.getBackground());
      textfield.setForeground(table.getStyle().getValueCellFontColor());
    }
    panel.setBackground(textfield.getBackground());
    textfield.setFont(table.getStyle().getValueCellFont());
    textfield.setBorder(null);

    textfield.setText(FORMAT.format(value));
  }
Example #3
0
 /** Create new Account and Charge */
 private void createNew() {
   log.info("");
   //  Get Input
   String value = valueField.getText();
   if (value.length() == 0) {
     valueField.setBackground(AdempierePLAF.getFieldBackground_Error());
     return;
   }
   String name = nameField.getText();
   if (name.length() == 0) {
     nameField.setBackground(AdempierePLAF.getFieldBackground_Error());
     return;
   }
   //  Create Element
   int C_ElementValue_ID = createElementValue(value, name, isExpense.isSelected());
   if (C_ElementValue_ID == 0) {
     ADialog.error(m_WindowNo, panel, "ChargeNotCreated", name);
     return;
   }
   //  Create Charge
   int C_Charge_ID = createCharge(name, C_ElementValue_ID);
   if (C_Charge_ID == 0) {
     ADialog.error(m_WindowNo, panel, "ChargeNotCreated", name);
     return;
   }
   ADialog.info(m_WindowNo, panel, "ChargeCreated", name);
 } //  createNew
Example #4
0
  private int[] extractParametersFromTokens(
      String[] chrTokens, String[] dashChrTokens, JTextField positionChr) throws IOException {
    // Read positions:
    int start = 0, end = 0, outBin = 0, estimatedOutBinSize = 0;
    if (chrTokens.length > 2 && dashChrTokens.length > 1) {
      // Make sure values are numerical:
      try {
        start = Math.min(cleanUpNumber(chrTokens[1]), cleanUpNumber(chrTokens[2]));
        end = Math.max(cleanUpNumber(chrTokens[1]), cleanUpNumber(chrTokens[2]));
      } catch (Exception e) {
        log.error("Cannot parse " + chrTokens[1] + " or " + chrTokens[2] + ". Expecting int");
        positionChr.setBackground(Color.yellow);
        throw new IOException();
      }
      outBin = start + ((end - start) / 2);
      int diff = end - start;
      estimatedOutBinSize = getEstimationOfAppropriateZoomLevel(diff);

    } else if (chrTokens.length > 1) {
      // Make sure values are numerical:
      try {
        outBin = cleanUpNumber(chrTokens[1]);
      } catch (Exception e) {
        log.error("Cannot parse " + chrTokens[1] + ". Expecting int");
        positionChr.setBackground(Color.yellow);
        throw new IOException();
      }
    }
    return new int[] {start, end, outBin, estimatedOutBinSize};
  }
 protected void signalViolation(String msg) {
   final Color bg = _field.getBackground();
   _field.setBackground(Binding.INVALID_COLOR);
   MainFrame.getInstance().warn(msg);
   _field.setBackground(bg);
   _field.requestFocusInWindow();
 }
Example #6
0
 private final void setPrompt(boolean b) {
   prompt.setEnabled(b);
   if (b) {
     prompt.requestFocus();
     prompt.setBackground(Color.black);
   } else prompt.setBackground(Color.darkGray);
 }
 private void checkJARPath() {
   if (jarMCTL == null || jarMEP == null) {
     jtJAR.setBackground(INVALID);
   } else {
     jtJAR.setBackground(VALID);
   }
 }
 private void checkJCPPath() {
   if (txtJCP == null) {
     jtJCP.setBackground(INVALID);
   } else {
     jtJCP.setBackground(VALID);
   }
 }
 private void actualizarActivo() {
   if (lado) {
     txtAyNBlancas.setBackground(new Color(204, 0, 0));
     txtAyNNegras.setBackground(UIManager.getColor("Button.background"));
   } else {
     txtAyNBlancas.setBackground(UIManager.getColor("Button.background"));
     txtAyNNegras.setBackground(new Color(204, 0, 0));
   }
 }
 public void setID(String s) {
   id.setText(s);
   if (colorToggle) {
     id.setBackground(Color.BLUE);
   } else {
     id.setBackground(Color.GREEN);
   }
   colorToggle = !colorToggle;
 }
Example #11
0
  public void run() {
    switch (Connection.connectionStatus) {
      case DISCONNECTED:
        connectButton.setEnabled(true);
        disconnectButton.setEnabled(false);
        clearButton.setEnabled(true);
        ipField.setEnabled(true);
        portField.setEnabled(true);
        windowWidth.setEnabled(true);
        statusColor.setBackground(Color.red);
        break;

      case DISCONNECTING:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(false);
        clearButton.setEnabled(false);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        windowWidth.setEnabled(false);
        statusColor.setBackground(Color.orange);
        break;

      case CONNECTED:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(true);
        clearButton.setEnabled(true);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        windowWidth.setEnabled(false);
        statusColor.setBackground(Color.green);
        break;

      case BEGIN_CONNECT:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(false);
        clearButton.setEnabled(false);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        windowWidth.setEnabled(false);
        statusColor.setBackground(Color.orange);
        break;

      default:
        break;
    }

    ipField.setText(Connection.hostIP);
    portField.setText((new Integer(Connection.port)).toString());
    statusField.setText(Connection.statusString);
    chatText.append(Connection.toAppend.toString());
    windowWidth.setText(TCPServer.windowWidth.toString());
    Connection.toAppend.setLength(0);

    mainFrame.repaint();
  }
Example #12
0
 public void actionPerformed(ActionEvent event) {
   if (positionChrLeft.getText().isEmpty() && positionChrTop.getText().isEmpty()) {
     positionChrTop.setBackground(Color.yellow);
     positionChrLeft.setBackground(Color.yellow);
   } else if (positionChrLeft.getText().isEmpty()) {
     positionChrLeft.setText(positionChrTop.getText());
   } else if (positionChrTop.getText().isEmpty()) {
     positionChrTop.setText(positionChrLeft.getText());
   }
   parsePositionText();
 }
Example #13
0
  private void search(int direction) {
    String searchText = searchField.getText();
    if (searchText == null || searchText.length() == 0 || rTextArea.getText() == null) {
      return;
    }

    boolean forward = direction >= 0;
    boolean matchCase = matchCaseCB.isSelected();
    boolean regex = regexCB.isSelected();
    boolean wholeWord = wholeWordCB.isSelected();

    if (markAllCB.isSelected()) {
      rTextArea.markAll(searchText, matchCase, wholeWord, regex);
    } else {
      rTextArea.clearMarkAllHighlights();
    }

    SearchContext context = new SearchContext();
    context.setSearchFor(searchText);
    context.setMatchCase(matchCase);
    context.setRegularExpression(regex);
    context.setSearchForward(forward);
    context.setWholeWord(wholeWord);

    // TODO hack: move cursor before previous search for not jump to next occurrence
    if (direction == 0 && !COLOR_BG_ERROR.equals(searchField.getBackground())) {
      try {
        int caretPos = rTextArea.getCaretPosition();
        int lineNum = rTextArea.getLineOfOffset(caretPos) - 1;
        if (lineNum > 1) {
          rTextArea.setCaretPosition(rTextArea.getLineStartOffset(lineNum));
        }
      } catch (BadLocationException e) {
        LOG.error("Caret move error", e);
      }
    }

    boolean found = SearchEngine.find(rTextArea, context);
    if (!found) {
      int pos =
          SearchEngine.getNextMatchPos(
              searchText, rTextArea.getText(), forward, matchCase, wholeWord);
      if (pos != -1) {
        rTextArea.setCaretPosition(forward ? 0 : rTextArea.getDocument().getLength() - 1);
        search(direction);
        searchField.setBackground(COLOR_BG_WARN);
        return;
      }
      searchField.setBackground(COLOR_BG_ERROR);
    } else {
      searchField.setBackground(COLOR_BG_NORMAL);
    }
  }
Example #14
0
 private void filterValidStateChanged(LogView4JEvent event) {
   Boolean isValid = (Boolean) event.get(LogView4JEventKey.FILTER_VALID);
   if (Boolean.TRUE.equals(isValid)) {
     quickFilterTextField.setToolTipText("Quick filter");
     quickFilterTextField.setBackground(Color.WHITE);
     quickFilterTextField.setForeground(Color.BLACK);
   } else {
     String error = (String) event.get(LogView4JEventKey.ERROR_MESSAGE);
     quickFilterTextField.setToolTipText("Quick filter : " + error);
     quickFilterTextField.setBackground(INVALID_COLOR);
     quickFilterTextField.setForeground(Color.WHITE);
   }
 }
 public void updatePageCounterField(int n) {
   if (pageCounterField == null) return;
   if (n == 0) {
     pageCounterField.setBackground(pageCounterFieldDefaultColor);
     pageCounterField.setForeground(Color.BLACK);
     pageCounterButton.setForeground(pageCounterButtonDefaultForeground);
   } else {
     pageCounterField.setBackground(pageCounterFieldColor);
     pageCounterField.setForeground(Color.WHITE);
     pageCounterButton.setForeground(pageCounterFieldColor);
   }
   pageCounterField.setText("" + n);
 }
Example #16
0
 private void processFilterAction(final ActionEvent e) {
   if (jColumn.equals(e.getSource())) {
     updateNumeric(true);
   }
   if (jCompare.equals(e.getSource())) {
     updateCompare(true);
   }
   if (jEnabled.isSelected()) {
     jText.setBackground(Color.WHITE);
   } else {
     jText.setBackground(new Color(255, 200, 200));
   }
   timer.stop();
   refilter();
 }
  public PanelTambahAnggota() {

    setLayout(null);

    labelPanel = new JLabel(Perpustakaan.NAMA);
    labelPanel.setBounds(190, 15, 200, 40);
    add(labelPanel);

    labelKodeAnggota = new JLabel("Id Anggota");
    labelKodeAnggota.setBounds(50, 90, 100, 50);
    add(labelKodeAnggota);

    labelNama = new JLabel("Nama");
    labelNama.setBounds(50, 132, 100, 50);
    add(labelNama);

    textKodeAnggota = new JTextField(20);
    textKodeAnggota.setBounds(150, 100, 270, 32);
    textKodeAnggota.setBackground(Color.WHITE);
    add(textKodeAnggota);

    textNama = new JTextField(20);
    textNama.setBounds(150, 142, 270, 32);
    textNama.setBackground(Color.WHITE);
    add(textNama);

    tombolSimpan = new JButton("Simpan");
    tombolSimpan.setBounds(95, 280, 110, 30);
    add(tombolSimpan);
    tombolSimpan.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            tombolSimpanAction();
          }
        });

    tombolBatal = new JButton("Batal");
    tombolBatal.setBounds(290, 280, 110, 30);
    add(tombolBatal);
    tombolBatal.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            tombolBatalAction();
          }
        });

    setVisible(true);
  }
Example #18
0
  private JPanel getNorthDownPanel() {
    JPanel ret = new JPanel();
    ret.setLayout(new BorderLayout(5, 0));
    JLabel fil = new JLabel("文本:");
    ret.add(BorderLayout.WEST, fil);
    textField.setEditable(true);
    textField.setBackground(Color.WHITE);
    ret.add(BorderLayout.CENTER, textField);

    /*
     * 浏览文件的按钮
     */
    JButton buttonComput = new JButton("文本校验");
    buttonComput.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            onButtonTextCheck();
          }
        });

    ret.add(BorderLayout.EAST, buttonComput);

    return ret;
  }
  public SurrenderUI() {
    setType(Type.UTILITY);

    ExitB = new JButton("Exit");
    ExitB.setFont(new Font("Tahoma", Font.BOLD, 12));
    ExitB.setBackground(new Color(255, 215, 0));
    ExitB.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
            new HSmain();
          }
        });
    ExitB.setBounds(461, 427, 296, 60);

    setTitle("Surrendering a Pet");
    Container pane = getContentPane();
    getContentPane().setLayout(null);
    pane.add(ExitB);

    txtSurrender = new JTextField();
    txtSurrender.setEditable(false);
    txtSurrender.setForeground(new Color(0, 0, 0));
    txtSurrender.setBackground(new Color(255, 215, 0));
    txtSurrender.setBounds(10, 11, 764, 50);
    txtSurrender.setHorizontalAlignment(SwingConstants.CENTER);
    txtSurrender.setFont(new Font("Lucida Handwriting", Font.BOLD, 18));
    txtSurrender.setText("Surrendering a Pet");
    getContentPane().add(txtSurrender);
    txtSurrender.setColumns(10);

    BackB = new JButton("Back");
    BackB.setFont(new Font("Tahoma", Font.BOLD, 12));
    BackB.setBackground(new Color(255, 215, 0));
    BackB.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new AnimalServiceUI();
            dispose();
          }
        });
    BackB.setBounds(26, 427, 320, 60);
    getContentPane().add(BackB);

    scrollPane = new JScrollPane();
    scrollPane.setBounds(0, 72, 764, 329);
    getContentPane().add(scrollPane);

    JTextPane txtSurrenderInfo = new JTextPane();
    scrollPane.setViewportView(txtSurrenderInfo);
    txtSurrenderInfo.setForeground(new Color(0, 0, 0));
    txtSurrenderInfo.setEditable(false);
    txtSurrenderInfo.setFont(new Font("Times New Roman", Font.BOLD, 15));
    txtSurrenderInfo.setText(
        "\tThe Humane Society of Lamar cannot accept every animal brought to our shelter immediately. \r\nWe respect the difficult decision of owners to relinquish their pets, and the hard choices of those \r\ngood citizens who are trying to help a stray. We accept the surrender of pets as space allows. \r\nWe maintain a waiting list for all animals needing to be admitted to the shelter.\r\nAnimals are surrendered to our facility by appointment.\r\nWe admit at least 12 animals per week. We accept more animals as adoptions and space allow.\r\nNote that we cannot accept aggressive, sick or pregnant animals.\r\nPlease call 409-225-7981, and one of our adoption specialists will speak to you.\r\nAt times our waiting list will have up to 100 animals waiting for admission and it can take several weeks \r\nbefore we can admit your pet.\r\nPlease understand that our primary goal is to place as many animals in forever homes as possible, \r\ntherefore we must give every pet admitted to the shelter enough time to find a loving home. \r\nWe cannot guarantee placement of every animal admitted to the shelter.\r\n\t\r\n\tAdmission of any animal into the Humane Society of Lamar  is based on the animal\u2019s health, \r\nbehavior, and adoptability. When you bring your pets, please have:\r\n\r\n    *Any veterinary records\r\n    *Your pet\u2019s medications\r\n    *Special food or treats that your pet needs\r\n    *Your pet\u2019s bed, toys, leash and other belongings from home\r\n\r\nA staff member will evaluate the temperament of your pet. Once your pet has been screened, \r\nand the Humane Society of Lamar decides to accept your pet, we ask a donation to our shelter to be made. \r\nThis is not required, but will greatly help us care for your pet.");

    setSize(800, 553);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
  public void setCell(DatasetEditorModelCell cell) {
    if (this.cell != null) updateUserValue(false);
    this.cell = cell;

    DatasetEditorModelRow row = cell.getRow();
    boolean editable = !row.isDeleted() && row.getModel().isEditable();
    editorComponent.setEnabled(editable);
    editorComponent.setUserValueHolder(cell);

    Formatter formatter = regionalSettings.getFormatter();
    if (cell.getUserValue() instanceof String) {
      String userValue = (String) cell.getUserValue();
      if (userValue.indexOf('\n') > -1) {
        userValue = userValue.replace('\n', ' ');
        editorComponent.setEditable(false);
      } else {
        editorComponent.setEditable(editable);
      }
      editorComponent.setText(userValue);
    } else {
      editable = editable && !(cell.getUserValue() instanceof LazyLoadedValue);
      editorComponent.setEditable(editable);
      String formattedUserValue = formatter.formatObject(cell.getUserValue());
      editorComponent.setText(formattedUserValue);
    }
    JTextField valueTextField = editorComponent.getTextField();
    valueTextField.setBackground(UIUtil.getTextFieldBackground());
  }
  /**
   * This method initializes formTextField
   *
   * @return javax.swing.JTextField
   */
  private JTextField getFormTextField() {
    if (formTextField == null) {
      formTextField = new JTextField();
      formTextField.setBounds(new Rectangle(160, 139, 300, 20));
      formTextField.setBackground(null);
      formTextField.setBorder(null);
      formTextField.setEditable(false);

      String formCode = "NIL";
      for (int i = 0; i < ff.getCode().size(); i++) {
        if (i == 0) {
          formCode = ff.getCode().get(i).toString();
        } else {
          formCode += ff.getCode().get(i).toString();
        }

        if (i != ff.getCode().size() - 1) {
          formCode += ", ";
        }
      }

      formTextField.setText(formCode);
    }
    return formTextField;
  }
Example #22
0
 /**
  * JBuilder自动生成的初始化界面方法
  *
  * @throws Exception
  */
 private void jbInit() throws Exception {
   jPanel1.setLayout(borderLayout1);
   jPanel3.setPreferredSize(new Dimension(10, 30));
   jPanel4.setPreferredSize(new Dimension(30, 10));
   jPanel5.setPreferredSize(new Dimension(30, 10));
   jPanel6.setPreferredSize(new Dimension(10, 30));
   jPanel2.setLayout(verticalFlowLayout1);
   MoneyDuom.setBackground(Color.white);
   MoneyDuom.setFont(new java.awt.Font("Dialog", 0, 16));
   MoneyDuom.setPreferredSize(new Dimension(100, 30));
   MoneyDuom.setEditable(true);
   MoneyDuom.setText("");
   jLabel1.setFont(new java.awt.Font("Dialog", 1, 16));
   jLabel1.setPreferredSize(new Dimension(70, 23));
   jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
   jLabel1.setText("金  额:");
   this.getContentPane().add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jPanel2, BorderLayout.CENTER);
   jPanel2.add(jPanel8, null);
   jPanel8.add(jLabel1, null);
   jPanel8.add(MoneyDuom, null);
   jPanel2.add(jPanel7, null);
   jPanel1.add(jPanel3, BorderLayout.SOUTH);
   jPanel1.add(jPanel4, BorderLayout.WEST);
   jPanel1.add(jPanel5, BorderLayout.EAST);
   jPanel1.add(jPanel6, BorderLayout.NORTH);
 }
  private JTextField createField(final String text) {
    final JTextField field =
        new JTextField(text) {
          public Dimension getPreferredSize() {
            Dimension preferredSize = super.getPreferredSize();
            return new Dimension(preferredSize.width, myTextHeight);
          }
        };
    field.setBackground(UIUtil.getPanelBackground());
    field.setEditable(false);
    final Border lineBorder = BorderFactory.createLineBorder(UIUtil.getPanelBackground());
    final DottedBorder dotted = new DottedBorder(UIUtil.getActiveTextColor());
    field.setBorder(lineBorder);
    // field.setFocusable(false);
    field.setHorizontalAlignment(JTextField.RIGHT);
    field.setCaretPosition(0);
    field.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent e) {
            field.setBorder(dotted);
          }

          public void focusLost(FocusEvent e) {
            field.setBorder(lineBorder);
          }
        });
    return field;
  }
  /** {@inheritDoc } */
  @Override
  public void setController(JmsInterfaceContextController theController) {
    final JmsInterfaceImpl model = theController.getModel();

    myUsernameTextBox.setText(model.getUsername());
    myUsernameTextBox
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {

              public void undoableEditHappened(UndoableEditEvent e) {
                model.setUsername(myUsernameTextBox.getText());
              }
            });

    myPasswordTextBox.setText(model.getPassword());
    myPasswordTextBox
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {

              public void undoableEditHappened(UndoableEditEvent e) {
                model.setPassword(myPasswordTextBox.getText());
              }
            });

    myQueueNameTextBox.setText(model.getQueueName());
    if (StringUtils.isBlank(model.getQueueName())) {
      myQueueNameTextBox.setBackground(Colours.getTextFieldError());
    }
    myQueueNameTextBox
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {

              @Override
              public void undoableEditHappened(UndoableEditEvent e) {
                try {
                  model.setQueueName(myQueueNameTextBox.getText());
                  myQueueNameTextBox.setBackground(Colours.getTextFieldOk());
                } catch (PropertyVetoException ex) {
                  LogFactory.INSTANCE.getSystem(getClass()).error(ex.getMessage());
                  myQueueNameTextBox.setBackground(Colours.getTextFieldError());
                }
              }
            });

    myQueueTopicCombo.setSelectedIndex(model.isPubSubDomain() ? 1 : 0);
    myQueueTopicCombo.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            model.setPubSubDomain(myQueueTopicCombo.getSelectedIndex() == 1);
          }
        });

    myConnectionFactoryBeanEditor.setController(theController.getConstructorArgsController());
  }
Example #25
0
  // Initialize all the GUI components and display the frame
  private static void initGUI() {
    // Set up the status bar
    statusField = new JLabel();
    statusField.setText(statusMessages[DISCONNECTED]);
    statusColor = new JTextField(1);
    statusColor.setBackground(Color.red);
    statusColor.setEditable(false);
    statusBar = new JPanel(new BorderLayout());
    statusBar.add(statusColor, BorderLayout.WEST);
    statusBar.add(statusField, BorderLayout.CENTER);

    // Set up the options pane
    JPanel optionsPane = initOptionsPane();

    // Set up the chat pane
    JPanel chatPane = new JPanel(new BorderLayout());
    chatText = new JTextArea(10, 20);
    chatText.setLineWrap(true);
    chatText.setEditable(false);
    chatText.setForeground(Color.blue);
    JScrollPane chatTextPane =
        new JScrollPane(
            chatText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    chatLine = new JTextField();
    chatLine.setEnabled(false);
    chatLine.addActionListener(
        new ActionAdapter() {
          public void actionPerformed(ActionEvent e) {
            String s = chatLine.getText();
            if (!s.equals("")) {
              appendToChatBox("OUTGOING: " + s + "\n");
              chatLine.selectAll();

              // Send the string
              sendString(s);
            }
          }
        });
    chatPane.add(chatLine, BorderLayout.SOUTH);
    chatPane.add(chatTextPane, BorderLayout.CENTER);
    chatPane.setPreferredSize(new Dimension(200, 200));

    // Set up the main pane
    JPanel mainPane = new JPanel(new BorderLayout());
    mainPane.add(statusBar, BorderLayout.SOUTH);
    mainPane.add(optionsPane, BorderLayout.WEST);
    mainPane.add(chatPane, BorderLayout.CENTER);

    // Set up the main frame
    mainFrame = new JFrame("Simple TCP Chat");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setContentPane(mainPane);
    mainFrame.setSize(mainFrame.getPreferredSize());
    mainFrame.setLocation(200, 200);
    mainFrame.pack();
    mainFrame.setVisible(true);
  }
Example #26
0
  @Override
  public void mouseExited(MouseEvent c) {
    // TODO Auto-generated method stub

    if (c.getSource() == textfield2) {
      textfield2.setBackground(Color.pink);
    }
  }
Example #27
0
  @Override
  public void mouseEntered(MouseEvent d) {
    // TODO Auto-generated method stub

    if (d.getSource() == textfield2) {
      textfield2.setBackground(Color.red);
    }
  }
Example #28
0
  // Constructor
  public Temperature() {
    Container c = getContentPane();
    c.setLayout(new GridLayout(2, 2, 10, 0));

    c.add(new JLabel("  Fahrenheit:"));
    c.add(new JLabel("  Celsius:"));

    displayF = new JTextField(6);
    displayF.setBackground(Color.YELLOW);
    displayF.addActionListener(this);
    c.add(displayF);

    displayC = new JTextField(6);
    displayC.setBackground(Color.YELLOW);
    displayC.addActionListener(this);
    c.add(displayC);
  }
Example #29
0
  // methods
  public void updateMessage() {
    messageField.setText(message);
    messageField.setFont(messageFont);
    messageField.setForeground(foreground);
    messageField.setBackground(background);
    // tt = messageField.getText();

  }
  /**
   * This is used by the Observer design pattern. This method is called when there is a change has
   * been notified
   */
  @Override
  public void update(Observable o, Object arg) {

    if (o instanceof ManageInstructions) {
      clearTextFields();

      for (int i = 0; i < textFieldContainer.size(); i++) {
        String registerName = textFieldContainer.get(i).getName();
        if (!textFieldContainer
            .get(i)
            .getText()
            .equals(Integer.toString(simulator.getRegisters().getRegisterValue(registerName)))) {
          textFieldContainer.get(i).setBackground(new Color(51, 204, 255));
        }
        textFieldContainer
            .get(i)
            .setText(Integer.toString(simulator.getRegisters().getRegisterValue(registerName)));
      }

      csField.setText(Integer.toString(simulator.getMemory().codeSegmentStart));
      if (Integer.toString(simulator.getProgramCounter()) != ipField.getText()) {
        ipField.setBackground(new Color(51, 204, 255));
      }
      ipField.setText(Integer.toString((simulator.getProgramCounter() * 2) + 2));
      dsField.setText(Integer.toString(simulator.getMemory().dataSegmentStart));
      ssField.setText(Integer.toString(simulator.getMemory().stackSegmentStart));
    }
    if (o instanceof MemoryStack) {

      ArrayList stack = simulator.getMemory().getStack().stack();
      while (stackModel.getRowCount() > 0) {
        stackModel.removeRow(0);
      }

      int bp = simulator.getMemory().getStack().oldbp;
      for (int i = 0; i < stack.size(); i++) {
        String operator = "+";
        int n = (stack.size() - i) * 2;
        if (i < bp && bp != 0) {
          operator = "+";
          n = (bp - i) * 2;
        }
        if (bp == 0) {
          operator = "-";
        }
        if (i > bp && bp != 0) {
          operator = "-";
        }
        if (i == bp && bp != 0) {
          n = 0;
        }

        String[] stackRow = {"bp " + operator + " " + n, stack.get(i).toString()};
        stackModel.addRow(stackRow);
      }
    }
  }