public void onWho(ActionEvent actionEvent) { StandardDialog dlg = new StandardDialog(); dlg.setTitle("Your name and address"); String strName = prefs.get(NAME, server.ip + ":" + server.port); JTextField name = new JTextField(strName), ip = new JTextField(server.ip), port = new JTextField(server.port + ""); ip.setEditable(false); port.setEditable(false); LabelledItemPanel myContentPane = new LabelledItemPanel(); myContentPane.setBorder(BorderFactory.createEtchedBorder()); myContentPane.addItem("Your name", name); myContentPane.addItem("", new JLabel("Tell your buddy the follows:")); myContentPane.addItem("Your IP", ip); myContentPane.addItem("Your port", port); dlg.setContentPane(myContentPane); dlg.setSize(300, 300); GUIUtils.centerWithinScreen(dlg); dlg.setVisible(true); if (!dlg.hasUserCancelled()) { prefs.put(NAME, name.getText()); server.myName = name.getText(); } }
private void refreshSelection(int choice) { if (choice == POINT_PRIX) { pointsPrix.setSelected(true); prixParPoint.setEditable(true); prixParPoint.setEnabled(true); pointsService.setSelected(false); pointsParAutre.setEditable(false); pointsParAutre.setEnabled(false); pointsParCoiffure.setEditable(false); pointsParCoiffure.setEnabled(false); pointsParCoupe.setEditable(false); pointsParCoupe.setEnabled(false); pointsParCouleur.setEditable(false); pointsParCouleur.setEnabled(false); } else if (choice == POINT_SERVICE) { pointsPrix.setSelected(false); prixParPoint.setEditable(false); prixParPoint.setEnabled(false); pointsService.setSelected(true); pointsParAutre.setEditable(true); pointsParAutre.setEnabled(true); pointsParCoiffure.setEditable(true); pointsParCoiffure.setEnabled(true); pointsParCoupe.setEditable(true); pointsParCoupe.setEnabled(true); pointsParCouleur.setEditable(true); pointsParCouleur.setEnabled(true); } }
// Mode modification public void modeModification() { resetCollection(); loadCollection(); resetCategorie(); loadCategorie(); comboCollection.setEnabled(true); textTitre.setVisible(true); textTitre.setEnabled(true); textTitre.setEditable(true); textAnnee.setVisible(true); textAnnee.setEnabled(true); textAnnee.setEditable(true); comboType.setVisible(true); comboType.setEnabled(true); comboEval.setVisible(true); comboEval.setEnabled(true); scrollCom.setEnabled(true); scrollCat.setEnabled(true); textCommentaires.setEnabled(true); textCommentaires.setEditable(true); textCommentaires.setBackground(Color.WHITE); textCommentaires.setText(""); textCategories.setEnabled(true); textCategories.setEditable(false); textCategories.setBackground(GRIS); textCategories.setText(""); for (int i = 0; i < infos_film.length; i++) { infos_film[i].setVisible(false); } for (int k = 0; k < modeButton.length; k++) { modeButton[k].setEnabled(false); modeButton[k].setVisible(false); } modeButton[3].setVisible(true); // Boutton Modifier modeButton[4].setVisible(true); // Boutton Supprimer boolean enabled = true; if (listeEstVide()) { enabled = false; } modeButton[3].setEnabled(enabled); modeButton[4].setEnabled(enabled); optionCategories[0].setEnabled(true); // Boutton ajouter categorie optionCategories[1].setEnabled(true); // Place the first element of combobox in the grid comboCollection.setSelectedIndex(0); Video video = this.obtenirVideo(comboCollection.getSelectedItem().toString()); afficherFilmChoisis(video.getTitre()); }
// Mode consultation public void modeConsultation() { resetCollection(); loadCollection(); comboCollection.setEnabled(true); textTitre.setVisible(false); textTitre.setEditable(false); textAnnee.setVisible(false); textAnnee.setEditable(false); comboType.setVisible(false); comboType.setEnabled(false); comboEval.setVisible(false); comboEval.setEnabled(false); // Juste au cas que ca foire scrollCom.setEnabled(true); scrollCat.setEnabled(true); textCommentaires.setEnabled(true); textCommentaires.setEditable(false); textCategories.setEnabled(true); textCategories.setEditable(false); textCommentaires.setBackground(GRIS); textCategories.setBackground(GRIS); for (int k = 0; k < infos_film.length; k++) { infos_film[k].setVisible(true); } // Place the first element of combobox in the grid DEPRECATED by Enoncé comboCollection.setSelectedIndex(comboCollection.getSelectedIndex()); for (int l = 0; l < modeButton.length; l++) { if (l < 2) { modeButton[0].setEnabled(false); modeButton[0].setVisible(true); if (comboCollection.getItemCount() > 1) { modeButton[l].setEnabled(true); modeButton[l].setVisible(true); } else { modeButton[l].setEnabled(false); modeButton[l].setVisible(true); } // modeButton[l].setEnabled(true); // modeButton[l].setVisible(true); } else { modeButton[l].setEnabled(false); modeButton[l].setVisible(false); } } optionCategories[0].setEnabled(false); optionCategories[1].setEnabled(false); // Get the collection and place in combobox Video video = this.obtenirVideo(comboCollection.getSelectedItem().toString()); afficherFilmChoisis(video.getTitre()); }
public ControlPanel(ClueGame game) { // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.game = game; setSize(new Dimension(400, 100)); setPreferredSize(new Dimension(300, 100)); turn = new JLabel("Whose Turn?"); dice = new JLabel("Roll"); guess = new JLabel("Guess"); response = new JLabel("Response"); nextPlayer = new JButton("Next player"); nextPlayer.addActionListener(new ButtonListener()); accusation = new JButton("Make an accusation"); accusation.addActionListener(new ButtonListener()); diceValue = new JTextField(1); diceValue.setEditable(false); guessValue = new JTextField(30); guessValue.setEditable(false); responseValue = new JTextField(15); responseValue.setEditable(false); turnValue = new JTextField(15); turnValue.setEditable(false); dicePanel = new JPanel(); guessPanel = new JPanel(); responsePanel = new JPanel(); turnPanel = new JPanel(); topPanel = new JPanel(); botPanel = new JPanel(); this.add(topPanel, BorderLayout.CENTER); this.add(botPanel, BorderLayout.SOUTH); topPanel.setLayout(new GridLayout(1, 3)); // botPanel.setLayout(new GridLayout(1,3)); turnPanel.add(turn); turnPanel.add(turnValue); turnValue.setBorder(new TitledBorder(new EtchedBorder())); topPanel.add(turnPanel); topPanel.add(nextPlayer); topPanel.add(accusation); dicePanel.setBorder(new TitledBorder(new EtchedBorder(), "Die")); guessPanel.setBorder(new TitledBorder(new EtchedBorder(), "Guess")); responsePanel.setBorder(new TitledBorder(new EtchedBorder(), "Guess Result")); dicePanel.add(dice); diceValue.setText(" "); dicePanel.add(diceValue); diceValue.setBorder(new EtchedBorder()); botPanel.add(dicePanel, BorderLayout.WEST); guessPanel.add(guess); guessValue.setText(" "); guessPanel.add(guessValue); guessValue.setBorder(new EtchedBorder()); botPanel.add(guessPanel, BorderLayout.CENTER); responsePanel.add(response); responseValue.setText(" "); responsePanel.add(responseValue); responseValue.setBorder(new EtchedBorder()); botPanel.add(responsePanel, BorderLayout.EAST); }
public void init() { if (destroyed) { return; } resultPanel = new ResultPanel(); plotPanel.setLayout(new GridLayout(1, 0)); plotButton = new JToggleButton[plotButtonName.length]; for (int i = 0; i < plotButton.length; i++) { plotButton[i] = new JToggleButton(plotButtonName[i]); plotButton[i].addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { resultPanel.repaint(); } }); plotPanel.add(plotButton[i]); } plotButton[0].setSelected(true); plotButton[4].setSelected(true); GridBagLayout g = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); mainPanel.setLayout(g); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; c.weighty = 0.0; mainPanel.add(plotPanel, c); yField.setEditable(false); callsField.setEditable(false); JPanel panel = new JPanel(new GridLayout(1, 2)); panel.add(yField); panel.add(callsField); mainPanel.add(panel, c); mainPanel.add(zoomXBar, c); c.gridwidth = 3; c.weightx = 1.0; c.weighty = 1.0; mainPanel.add(resultPanel, c); c.weightx = 0.0; mainPanel.add(zoomYBar, c); mainPanel.add(shiftYBar, c); AdjustmentListener listener = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { resultPanel.repaint(); } }; zoomXBar.addAdjustmentListener(listener); zoomYBar.addAdjustmentListener(listener); shiftYBar.addAdjustmentListener(listener); frame.getContentPane().add(mainPanel); frame.setVisible(true); }
@Override public void vista_edicion() { if (getEstado().equals(NUEVO)) txtCodigo.setEditable(true); txtDescripcion.setEditable(true); this.txtDescCorta.setEditable(true); tblLista.setEnabled(false); getSubgrupoTM().setEditar(true); }
private void switchSearchFunction() { if (requestDispatcher.getNumberOfField() == 0) { searchTextField.setEditable(false); resetButton.setEnabled(false); } else { searchTextField.setEditable(true); resetButton.setEnabled(true); } }
// Mode ajout public void modeAjout() { resetCollection(); loadCollection(); resetCategorie(); loadCategorie(); comboCollection.setEnabled(false); textTitre.setVisible(true); textTitre.setEnabled(true); textTitre.setEditable(true); textTitre.setText(""); textTitre.requestFocusInWindow(); textAnnee.setVisible(true); textAnnee.setEnabled(true); textAnnee.setEditable(true); textAnnee.setText(""); comboType.setVisible(true); comboType.setEnabled(true); comboType.setSelectedIndex(1); comboEval.setVisible(true); comboEval.setEnabled(true); comboEval.setSelectedIndex(0); // Juste au cas que ca foire scrollCom.setEnabled(true); scrollCat.setEnabled(true); textCommentaires.setEnabled(true); textCommentaires.setEditable(true); textCommentaires.setBackground(Color.WHITE); textCommentaires.setText(""); textCategories.setEnabled(true); textCategories.setEditable(false); textCategories.setBackground(GRIS); textCategories.setText(""); optionCategories[0].setEnabled(true); optionCategories[1].setEnabled(false); for (int i = 0; i < infos_film.length; i++) { infos_film[i].setVisible(false); } for (int k = 0; k < modeButton.length; k++) { if (k == 2) { modeButton[k].setEnabled(true); modeButton[k].setVisible(true); } else { modeButton[k].setEnabled(false); modeButton[k].setVisible(false); } } }
public void enableCustomDimension(boolean value) { txtLarghezza.setEditable(value); txtAltezza.setEditable(value); formatoCarta.setEnabled(!value); if (!value) { this.changeFormato(formatoCarta.getSelectedIndex()); } }
// Mode recherche public void modeRecherche() { resetCollection(); comboCollection.setEnabled(false); textTitre.setVisible(true); textTitre.setEnabled(true); textTitre.setEditable(true); textTitre.setText(""); textTitre.requestFocusInWindow(); textAnnee.setVisible(true); textAnnee.setEnabled(true); textAnnee.setEditable(true); textAnnee.setText(""); comboType.setVisible(true); comboType.setEnabled(true); comboType.setSelectedIndex(0); comboEval.setVisible(true); comboEval.setEnabled(false); // comboEval.setFont(); comboEval.setSelectedIndex(0); textCommentaires.setEnabled(true); textCommentaires.setEditable(false); textCommentaires.setBackground(GRIS); textCommentaires.setText(""); textCategories.setEnabled(true); textCategories.setEditable(false); textCategories.setBackground(GRIS); textCategories.setText(""); for (int i = 0; i < infos_film.length; i++) { infos_film[i].setVisible(false); } for (int k = 0; k < modeButton.length; k++) { modeButton[k].setEnabled(false); modeButton[k].setVisible(false); } modeButton[5].setVisible(true); // modeButton[6].setVisible(true); boolean enabled = true; if (listeEstVide()) { enabled = false; } optionCategories[0].setEnabled(enabled); optionCategories[1].setEnabled(enabled); modeButton[5].setEnabled(enabled); modeButton[6].setEnabled(true); }
private void bloqueiaDesbloqueiaCampos(boolean opcao) { jTextFieldRazaoSocial.setEditable(opcao); jTextFieldFantasia.setEditable(opcao); jTextFieldFormatCnpj.setEditable(opcao); jTextFieldTelefone.setEditable(opcao); jTextFieldEndereco.setEditable(opcao); jTextFieldNumero.setEditable(opcao); jTextFieldQuantQuartos.setEditable(opcao); }
@Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getSource() == place[1]) { textField.setEditable(true); } else { textField.setEditable(false); textField.setText(""); } } }
@Override public void mouseClicked(MouseEvent arg0) { Object source = arg0.getSource(); if (source == jRadioButton1) { jRadioButton2.setSelected(false); jTextField3.setEditable(false); } else if (source == jRadioButton2) { jRadioButton1.setSelected(false); jTextField3.setEditable(true); } }
public void view(String data1, String data2, String identity) throws RemoteException, MalformedURLException, NotBoundException { JTextField data11 = new JTextField(); data11.setEditable(false); data11.setBounds(135, 180, 250, 20); j.add(data11); data11.setBorder(new EmptyBorder(0, 0, 0, 0)); data11.setText("从" + data1 + "到" + data2 + "的收款单列表如下:"); DateRange dr = new DateRange(data1, data2); dr.divide(); ArrayList<String> dateRange = dr.getDateRange(); ReceiptListService bl = new ReceiptList(); ArrayList<ReceiptListVO> vos = bl.find(dateRange); String[][] playerInfore = new String[64][5]; double num = 0; if (vos != null) { for (int i = 0; i < vos.size(); i++) { ReceiptListVO vo = vos.get(i); playerInfore[i][0] = vo.getOrderNumber(); playerInfore[i][1] = vo.getDate(); playerInfore[i][2] = vo.getMoney(); playerInfore[i][3] = vo.getPostman(); double money = Double.parseDouble(vo.getMoney()); num += money; } } JTextField labelx = new JTextField(); labelx.setEditable(false); labelx.setBounds(135, 200, 250, 20); j.add(labelx); labelx.setBorder(new EmptyBorder(0, 0, 0, 0)); labelx.setText("总计" + num + "元"); String[] Names = {"订单条形码号", "收款日期", "收款金额", "收款快递员"}; DefaultTableModel tableModel = new DefaultTableModel(playerInfore, Names); JTable table = new JTable(tableModel); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getColumnModel().getColumn(0).setPreferredWidth(150); table.getColumnModel().getColumn(1).setPreferredWidth(100); table.getColumnModel().getColumn(2).setPreferredWidth(100); table.getColumnModel().getColumn(2).setPreferredWidth(100); scrollPane = new JScrollPane(table); scrollPane.setBounds(30, 230, 445, 330); j.add(scrollPane); // p500.add(j); }
private void editAccount() { btn_edit.setText("Zatwierdź"); btn_edit.setActionCommand("end_edit"); btn_add.setEnabled(false); btn_rmv.setEnabled(false); cBox_accountList.setEnabled(false); txt_name.setEditable(true); txt_surname.setEditable(true); txt_password.setEditable(true); txt_gmail.setEditable(true); }
public void orderForm(NeuralNetwork nnet) { drawButton.setEnabled(false); openInLauncherButton.setEnabled(false); this.nnet = nnet; graphTypeCombo.removeAllItems(); layerCombo.removeAllItems(); datasetTextField.setEditable(false); nnetField.setEditable(false); nnetField.setText(nnet.getLabel()); Layer[] layers = nnet.getLayers(); for (int i = layers.length; i > 0; i--) { layerCombo.addItem(i); } }
public void setEditable(boolean b) { txtBono.setEditable(b); txtFecha.setEditable(false); txtHora.setEditable(false); txtValor.setEditable(b); txtValorbono.setEditable(false); txtHora.transferFocus(); btnCancelar.setVisible(b); btnConfirmar.setVisible(b); btnCargar.setEnabled(b); if (b) setBackground(new Color(255, 255, 240)); else setBackground(new Color(255, 165, 0)); }
void connectionFailed() { login.setEnabled(true); logout.setEnabled(false); // whoIsIn.setEnabled(false); chatStatus.setText("Please login first"); chatField.setText(""); // reset port number and host name as a construction time tfPort.setText("" + defaultPort); tfServer.setText(defaultHost); // let the user change them tfServer.setEditable(false); tfPort.setEditable(false); // don't react to a <CR> after the username chatField.removeActionListener(this); connected = false; }
private JPanel createBrowsePanel() { JPanel browsePanel = new JPanel(new BorderLayout()); final JTextField directoryText = new JTextField(); directoryText.setEditable(false); browsePanel.add(directoryText, BorderLayout.CENTER); JButton browseButton = new JButton("Browse..."); browsePanel.add(browseButton, BorderLayout.EAST); browseButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int retval = chooser.showSaveDialog(CreateThematicMapDialog.this); if (retval == JFileChooser.APPROVE_OPTION) { File selectedFile = chooser.getSelectedFile(); directoryText.setText(selectedFile.getPath()); evaluateFile = selectedFile; } } }); Collections.<Component>addAll(evaluateEnablement, directoryText, browseButton); return browsePanel; }
public void setEditable(boolean isEditable) { isEditable_ = isEditable; if (inputType_.equals("ALPHA") || inputType_.equals("KANJI") || inputType_.equals("NUMERIC")) { ((JTextField) component).setEditable(isEditable_); ((JTextField) component).setFocusable(isEditable_); } if (inputType_.equals("DATE")) { ((XFDateField) component).setEditable(isEditable_); ((XFDateField) component).setFocusable(isEditable_); int fieldWidth = XFUtility.getWidthOfDateValue(dialog_.getSession().getDateFormat(), 14); if (isEditable_) { this.setBounds( this.getBounds().x, this.getBounds().y, 150 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT); } else { this.setBounds( this.getBounds().x, this.getBounds().y, 124 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT); } } if (inputType_.equals("LISTBOX")) { ((JComboBox) component).setEditable(isEditable_); ((JComboBox) component).setFocusable(isEditable_); } if (inputType_.equals("CHECKBOX")) { ((JCheckBox) component).setEnabled(isEditable_); ((JCheckBox) component).setFocusable(isEditable_); } }
public FloatInput(String var, float _value, String _label) { variable = var; value = _value; setLayout(new BorderLayout(5, 5)); label = new JLabel(_label); add(label, BorderLayout.WEST); int defValue = (int) (_value * 100); slider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, defValue); slider.setMajorTickSpacing(25); slider.setMinorTickSpacing(5); slider.setPaintTicks(true); slider.setPaintLabels(false); slider.addChangeListener(this); add(slider, BorderLayout.CENTER); text = new JTextField(); text.setEditable(false); text.setColumns(4); refresh(); JPanel temp = new JPanel(); temp.setLayout(new FlowLayout(FlowLayout.CENTER)); temp.add(text); add(temp, BorderLayout.EAST); }
private JTabbedPane createTab() { Font mainFont = new Font("Times New Roman", Font.BOLD, 11); tabbedPane.setFont(mainFont); tabbedPane.setBorder(new BevelBorder(BevelBorder.LOWERED)); tabbedPane.add("New application", new NewAppPanel()); JPanel existingApp = new JPanel(); existingApp.setLayout(new BoxLayout(existingApp, BoxLayout.X_AXIS)); JLabel pictureLabel = new JLabel("Configuration:"); JButton pictureChooser = new JButton("Choose"); pictureFileName.setEditable(false); pictureFileName.setMaximumSize(new Dimension(contentPane.getPreferredSize().width, 25)); existingApp.add(Box.createHorizontalStrut(20)); existingApp.add(pictureLabel); existingApp.add(pictureFileName); existingApp.add(Box.createHorizontalStrut(5)); existingApp.add(pictureChooser); existingApp.add(Box.createHorizontalStrut(20)); pictureChooser.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { loadFromFile(); } }); tabbedPane.add("Existing application", existingApp); tabbedPane.setPreferredSize(contentPane.getPreferredSize()); return tabbedPane; }
/** * 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; }
/** Inhabilita los campos de ingeso de datos. */ private void inhabilitarCampos() { JDateInicio.setEnabled(false); JDateFin.setEnabled(false); txtDescripcion.setEditable(false); txtNombre.setEditable(false); btnAceptar.setEnabled(false); }
private void createObjectIDBox(JPanel homePanel) { objectIDBox = new JTextField(DEFAULT_OBJECT_ID_TEXT.length() - 1); objectIDBox.setEditable(false); objectIDBox.setText(DEFAULT_OBJECT_ID_TEXT); homePanel.add(objectIDBox); }
/** * 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); }
public void limparTela() { codigoCatalogoField.setText(""); tituloField.setText(""); tituloOriginalField.setText(""); escritorField.setText(""); tradutorField.setText(""); anoPrimEdicaoField.setText(""); anoLancamentoField.setText(""); edicaoField.setText(""); qtdPageField.setText(""); linguagemField.setText(""); generoField.setText(""); categoriaField.setText(""); formatoField.setText(""); editoraField.setText(""); paisLancamentoField.setText(""); codigoBarraField.setText(""); codigoCDDField.setText(""); codigoCDUField.setText(""); sinopseArea.setText(""); seriesArea.setText(""); obsArea.setText(""); capaField.setText(""); capaLabel.setIcon(null); // limpa tabela book itens model.limpar(); codigoCatalogoField.setEditable(true); codigoCatalogoField.requestFocus(); }
/** * Constructs the client by laying out the GUI and registering a listener with the textfield so * that pressing Return in the listener sends the textfield contents to the server. Note however * that the textfield is initially NOT editable, and only becomes editable AFTER the client * receives the NAMEACCEPTED message from the server. */ public ChatClient(String i) { ip = i; name = ("Hawk" + ((int) (Math.random() * 10000) + (int) (Math.random() * 1000) + (int) Math.random() * 100 + (int) Math.random() * 10)); // Layout GUI textField.setEditable(false); messageArea.setEditable(false); frame.getContentPane().add(textField, "South"); textField.setSize(1, 10); frame.getContentPane().add(new JScrollPane(messageArea), "Center"); frame.pack(); // Add Listeners textField.addActionListener( new ActionListener() { /** * Responds to pressing the enter key in the textfield by sending the contents of the text * field to the server. Then clear the text area in preparation for the next message. */ public void actionPerformed(ActionEvent e) { out.println(textField.getText()); textField.setText(""); } }); }
public synchronized void addThumbnail(File thumb, double percent) { ImagePanel panel_t = new ImagePanel(); panel_t.setBackground(Color.DARK_GRAY); panel_t.setBounds(left, top, 100, 100); percent = 100 - (double) ((percent * 100) / 11041); DecimalFormat df = new DecimalFormat("#.##"); textField = new JTextField(); textField.setEditable(false); textField.setText(df.format(percent) + "%"); textField.setBounds(left + 5, top - 5, 50, 20); textField.setColumns(10); panel_4.add(textField); panel_4.add(panel_t); panel_t.create(thumb, 100, 100); panel_t.repaint(); panel_4.repaint(); left += 110; top += 0; if (left % 450 == 0) { top += 110; left = 10; } }