/** 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(); } }
protected boolean setDir(JTextField txf, String strValue) { String strTxt = txf.getText(); String strName = txf.getName(); boolean bSet = false; if ((strTxt == null || strTxt.trim().length() == 0 || strTxt.equals(INFOSTR)) && strName.equalsIgnoreCase("value")) { if (timer != null) { timer.cancel(); txf.setForeground(Color.black); } bSet = true; txf.setText(strValue); txf.grabFocus(); } return bSet; }
/** * Method to display pixel information for the passed x and y * * @param pictureX the x value in the picture * @param pictureY the y value in the picture */ private void displayPixelInformation(int pictureX, int pictureY) { // check that this x and y are in range if (isLocationInPicture(pictureX, pictureY)) { // save the current x and y index colIndex = pictureX; rowIndex = pictureY; // get the pixel at the x and y Pixel pixel = new Pixel(picture, colIndex, rowIndex); // set the values based on the pixel colValue.setText(Integer.toString(colIndex + numberBase)); rowValue.setText(Integer.toString(rowIndex + numberBase)); rValue.setText("R: " + pixel.getRed()); gValue.setText("G: " + pixel.getGreen()); bValue.setText("B: " + pixel.getBlue()); colorPanel.setBackground(new Color(pixel.getRed(), pixel.getGreen(), pixel.getBlue())); } else { clearInformation(); } // notify the image display of the current x and y imageDisplay.setCurrentX((int) (colIndex * zoomFactor)); imageDisplay.setCurrentY((int) (rowIndex * zoomFactor)); }
void jTextFieldSendMessages_keyPressed(KeyEvent e) { if (e.getKeyCode() == e.VK_DOWN) { String s = msgHistory.forward(); if (s != null) { jTextFieldSendMessages.setText(s); } } else if (e.getKeyCode() == e.VK_UP) { String s = msgHistory.back(); if (s != null) { jTextFieldSendMessages.setText(s); } } else if (e.getKeyChar() == '\n') { String body = jTextFieldSendMessages.getText(); if (body.length() > 0) { if (body.charAt(body.length() - 1) == '\n') body = body.substring(0, body.length() - 1); String subject = jTextFieldSendSubject.getText(); if (subject.length() > 0) { if (subject.charAt(subject.length() - 1) == '\n') subject = subject.substring(0, subject.length() - 1); } if (session != null && session.isConnected()) { session.postMessage(jTextFieldTargetUser.getText(), subject, body); displaySendMessage(subject, jTextFieldTargetUser.getText(), body, outgoingMsgAttrSet); } msgHistory.add(body); subjectHistory.add(subject); subjectHistory.reset(); msgHistory.reset(); jTextFieldSendMessages.setText(""); jTextFieldSendSubject.setText(""); } } }
/** Creates new form SIPHeadersParametersFrame */ public StackPanel(ConfigurationFrame configurationFrame, ProxyLauncher proxyLauncher) { super(); this.parent = configurationFrame; this.proxyLauncher = proxyLauncher; listeningPointsList = new ListeningPointsList(proxyLauncher); initComponents(); // Init the components input: try { Configuration configuration = proxyLauncher.getConfiguration(); if (configuration == null) return; if (configuration.stackName != null) proxyStackNameTextField.setText(configuration.stackName); if (configuration.stackIPAddress != null) proxyIPAddressTextField.setText(configuration.stackIPAddress); if (configuration.outboundProxy != null) outboundProxyTextField.setText(configuration.outboundProxy); if (configuration.routerPath != null) routerClassTextField.setText(configuration.routerPath); if (configuration == null) listeningPointsList.displayList(new Hashtable()); else listeningPointsList.displayList(configuration.listeningPoints); } catch (Exception e) { e.printStackTrace(); } }
/** Method to clear the labels and current color and reset the current index to -1 */ private void clearInformation() { colValue.setText("N/A"); rowValue.setText("N/A"); rValue.setText("R: N/A"); gValue.setText("G: N/A"); bValue.setText("B: N/A"); colorPanel.setBackground(Color.black); colIndex = -1; rowIndex = -1; }
/** Load the settings of this panel */ private void loadSettings() { uploadPrioTextField.setText(settings.getValue(SettingsClass.FCP2_DEFAULT_PRIO_MESSAGE_UPLOAD)); downloadPrioTextField.setText( settings.getValue(SettingsClass.FCP2_DEFAULT_PRIO_MESSAGE_DOWNLOAD)); useOneConnectionForMessagesCheckBox.setSelected( settings.getBoolValue(SettingsClass.FCP2_USE_ONE_CONNECTION_FOR_MESSAGES)); displayDaysTextField.setText(settings.getValue(SettingsClass.MAX_MESSAGE_DISPLAY)); downloadDaysTextField.setText(settings.getValue(SettingsClass.MAX_MESSAGE_DOWNLOAD)); messageBaseTextField.setText(settings.getValue(SettingsClass.MESSAGE_BASE)); alwaysDownloadBackloadCheckBox.setSelected( settings.getBoolValue(SettingsClass.ALWAYS_DOWNLOAD_MESSAGES_BACKLOAD)); minimumIntervalTextField.setText( settings.getValue(SettingsClass.BOARD_AUTOUPDATE_MIN_INTERVAL)); concurrentUpdatesTextField.setText( settings.getValue(SettingsClass.BOARD_AUTOUPDATE_CONCURRENT_UPDATES)); // this setting is in MainFrame automaticBoardUpdateCheckBox.setSelected( MainFrame.getInstance().isAutomaticBoardUpdateEnabled()); refreshUpdateState(); storeSentMessagesCheckBox.setSelected( settings.getBoolValue(SettingsClass.STORAGE_STORE_SENT_MESSAGES)); silentlyRetryCheckBox.setSelected(settings.getBoolValue(SettingsClass.SILENTLY_RETRY_MESSAGES)); altEditCheckBox.setSelected(settings.getBoolValue(SettingsClass.ALTERNATE_EDITOR_ENABLED)); altEditTextField.setEnabled(altEditCheckBox.isSelected()); altEditTextField.setText(settings.getValue(SettingsClass.ALTERNATE_EDITOR_COMMAND)); }
void jTextFieldSendSubject_keyPressed(KeyEvent e) { if (e.getKeyCode() == e.VK_DOWN) { String s = subjectHistory.forward(); if (s != null) { jTextFieldSendSubject.setText(s); } } else if (e.getKeyCode() == e.VK_UP) { String s = subjectHistory.back(); if (s != null) { jTextFieldSendSubject.setText(s); } } else if (e.getKeyChar() == '\n') { jTextFieldSendMessages.requestFocus(); } }
/** * Used to initialize the componenets. Also called after every event that is required to update * other fields. */ public void setup() { if (firstTime) { defaultDirBackupPath = convertSet.getBackupPath().getPath(); defaultOneFileBackupPath = System.getProperty("user.dir"); firstTime = false; } dirTF.setText(convertSet.getSourcePath().getPath()); recursiveCheckBox.setSelected(converter.isRecurse()); if (converter.isStaticVersioning()) { staticVersioningRadioButton.setSelected(true); } else { dynamicVersioningRadioButton.setSelected(true); } backupTF.setText(defaultDirBackupPath); }
void jListOnlineUsers_mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { jTextFieldTargetUser.setText(((HostItem) jListOnlineUsers.getSelectedValue()).name); Flasher.instance().flashBackground(jTextFieldTargetUser, Color.yellow, 2); jTextFieldSendMessages.requestFocus(); } }
// ボタンが押されたときのイベント処理 public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("submit")) { // 送信 sendMessage("msg " + msgTextField.getText()); msgTextField.setText(""); } else if (cmd.equals("rename")) { // 名前の変更 sendMessage("setName " + nameTextField.getText()); } else if (cmd.equals("addRoom")) { // 部屋を作成 String roomName = nameTextField.getText(); sendMessage("addRoom " + roomName); enteredRoom(roomName); sendMessage("getUsers " + roomName); } else if (cmd.equals("enterRoom")) { // 入室 Object room = roomList.getSelectedValue(); if (room != null) { String roomName = room.toString(); sendMessage("enterRoom " + roomName); enteredRoom(roomName); } } else if (cmd.equals("exitRoom")) { // 退室 sendMessage("exitRoom " + roomName); exitedRoom(); } }
/** standard constructor */ public AboutDialog(JFrame frame) { super(frame, true); getConfDbVersion(); // load info from confdb.version file getContactPerson(); // load info from confdb.version file setTitle("About ConfDbGUI"); setContentPane(initComponents()); String txt = "<p>Thank you for using <b>ConfDbGUI</b>," + "a CMS tool to create and manage " + "CMSSW job configurations based on a " + "relational database.</p>" + "This software was originally developed " + "by Philipp Schieferdecker and is currently " + "maintained by Raul Jimenez Estupinan " + "with contributions from Ulf Behrens, " + "Jonathan Hollar, Vasundhara Chetluru " + "and Martin Gruenewald. " + "<p>For feedback please contact me at " + "<b>" + contactEmail + "</b>.</p>" + "<p>Find documentation on the web under " + "<b>https://twiki.cern.ch/twiki/bin/view/CMS/EvfConfDBGUI</b>.</p>"; jTextFieldApplication.setText("ConfDbGUI"); // jTextFieldVersion.setText("V01-05-82"); // Change in confdb.version file! jEditorPaneAbout.setContentType("text/html"); jEditorPaneAbout.setText(txt); }
@Override public void setSelectedIndex(int ind) { super.setSelectedIndex(ind); editor.setText(getItemAt(ind).toString()); editor.setSelectionEnd(caretPos + editor.getText().length()); editor.moveCaretPosition(caretPos); }
protected void load() { nameField.setText(data.name); costField.setValue(data.cost); colorBox.setSelectedItem(data.color); charField.setValue(data.text); weightField.setValue(data.weight); spellBox.setSelectedItem(data.spell); }
/** * Method called when a user message has been sent. checks to see if it is a command or regular * message */ private void sendMessage() { String txt = new String(messageText.getText()); if (!txt.equals("")) { if (txt.charAt(0) == '\\' || txt.charAt(0) == '/') { parseCommand(txt.substring(1)); messageText.setText(""); history.add(txt); } else if (server != null && server.connected && username != null) { sendText(username, txt, false); messageText.setText(""); sendChat(txt); history.add(txt); } else { error("Not connected, type \\reconnect to try and reconnect"); } } }
void profileList_mouseClicked(MouseEvent e) { JList theList = (JList) e.getSource(); ListModel aModel = theList.getModel(); int index = theList.locationToIndex(e.getPoint()); if (index < 0) return; UniProfile aProfile = (UniProfile) aModel.getElementAt(index); nameTextField.setText(aProfile.toString()); }
/** Observer method to update the insuranceCompanyTable */ public void updateTable() { tableData.update( model.getInsuranceCompanies(), model.getSortingStrategy()); // Populate the table // Check if InsuranceCompany map is empty if (model.getInsuranceCompanies().size() > 0) { selectRow(); int selectedCompanyId = Integer.valueOf( (String) insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0)); controller.selectInsuranceCompany(selectedCompanyId); recordEdited = -1; // Reset the recordEdited field } else { // If all records are deleted, clear the edit panel companyIdTextField.setText(""); companyNameTextField.setText(""); urlTextField.setText(""); generalDescriptionTextField.setText(""); insuranceTypesTextField.setText(""); telephoneTextField.setText(""); percentageTextField.setText(""); } }
/** * getConfDbVersion ------------------------------- return ConfDb current version String. Allow * get confdb version in case of errors. NOTE: to change the GUI version go to: * /conf/confdb.version file . */ public String getConfDbVersion() { ConfdbSoftwareVersion softversion = new ConfdbSoftwareVersion(); softversion.loadLocalProperties(); jTextFieldVersion.setText(softversion.getClientVersion()); return jTextFieldVersion.getText(); }
public void actionPerformed(ActionEvent evt) { File directory = new File(field.getText()); JFileChooser chooser = new JFileChooser(directory.getParent()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setSelectedFile(directory); if (chooser.showOpenDialog(SwingInstall.this) == JFileChooser.APPROVE_OPTION) field.setText(chooser.getSelectedFile().getPath()); }
void doCaretUpdate(int dot, int mark) { if (dot == mark) { mainFrame.cutItem.setEnabled(false); mainFrame.copyItem.setEnabled(false); mainFrame.deleteItem.setEnabled(false); } else { mainFrame.cutItem.setEnabled(true); mainFrame.copyItem.setEnabled(true); mainFrame.deleteItem.setEnabled(true); } int length = sourceArea.getText().length(); if (length == 0 || abs(mark - dot) == length) { mainFrame.selectAllItem.setEnabled(false); } else { mainFrame.selectAllItem.setEnabled(true); } try { if (length == 0) { mainFrame.selectLineItem.setEnabled(false); } else { int lineNum = sourceArea.getLineOfOffset(dot); int startLine = sourceArea.getLineStartOffset(lineNum); int endLine = sourceArea.getLineEndOffset(lineNum); if (endLine - startLine <= 1) { mainFrame.selectLineItem.setEnabled(false); } else { mainFrame.selectLineItem.setEnabled(true); } } } catch (BadLocationException ex) { ex.printStackTrace(); } try { int line = sourceArea.getLineOfOffset(dot); lineText.setText(Integer.toString(line + 1)); int column = dot - sourceArea.getLineStartOffset(line); columnText.setText(Integer.toString(column + 1)); } catch (BadLocationException ex) { ex.printStackTrace(); } }
// event handling public void actionPerformed(ActionEvent e) { if (e.getSource() == btnok) { PreparedStatement pstm; ResultSet rs; String sql; // if no entries has been made and hit ok button throw an error // you can do this step using try clause as well if ((tf1.getText().equals("") && (tf2.getText().equals("")))) { lblmsg.setText("Enter your details "); lblmsg.setForeground(Color.magenta); } else { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connect = DriverManager.getConnection("jdbc:odbc:student_base"); System.out.println("Connected to the database"); pstm = connect.prepareStatement("insert into student_base values(?,?)"); pstm.setString(1, tf1.getText()); pstm.setString(2, tf2.getText()); // execute method to execute the query pstm.executeUpdate(); lblmsg.setText("Details have been added to database"); // closing the prepared statement and connection object pstm.close(); connect.close(); } catch (SQLException sqe) { System.out.println("SQl error"); } catch (ClassNotFoundException cnf) { System.out.println("Class not found error"); } } } // upon clickin button addnew , your textfield will be empty to enternext record if (e.getSource() == btnaddnew) { tf1.setText(""); tf2.setText(""); } if (e.getSource() == btnexit) { System.exit(1); } }
void addTextField(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextField field = new JTextField(); field.setText(sketch.configFile.get(key)); field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height)); fields.put(key, field); panel.add(field); }
/** * Set whether this a new projection * * @param v true for new projection * @param name name for new projection */ void setDoingNewProjection(boolean v, String name) { doingNew = v; // For now don't disable the type box nameTF.setText(name); if (typeLabel != null) { // typeLabel.setEnabled (doingNew); // projClassCB.setEnabled (doingNew); } }
/** Sets the ClassMemberSpecification to be represented in this dialog. */ public void setClassMemberSpecification(ClassMemberSpecification classMemberSpecification) { String name = classMemberSpecification.name; String descriptor = classMemberSpecification.descriptor; // Set the access radio buttons. setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_PUBLIC, publicRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_PRIVATE, privateRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_PROTECTED, protectedRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_STATIC, staticRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_FINAL, finalRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_VOLATILE, volatileRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_TRANSIENT, transientRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_SYNCHRONIZED, synchronizedRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_NATIVE, nativeRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_ABSTRACT, abstractRadioButtons); setClassMemberSpecificationRadioButtons( classMemberSpecification, ClassConstants.INTERNAL_ACC_STRICT, strictRadioButtons); // Set the class name text fields. nameTextField.setText(name == null ? "" : name); if (isField) { typeTextField.setText(descriptor == null ? "" : ClassUtil.externalType(descriptor)); } else { typeTextField.setText( descriptor == null ? "" : ClassUtil.externalMethodReturnType(descriptor)); argumentsTextField.setText( descriptor == null ? "" : ClassUtil.externalMethodArguments(descriptor)); } }
/** Update the interface display to show the current value of the calculator. */ private void redisplay() { if (calc.isHexOn()) { int displayInt = calc.getDisplayValue(); if (displayInt < 0) { // toHexString() returns an unsigned integer as a String, // meaning negative values return (String)(ffffffff - n) instead of (-n) // example: -9 would show ffffffff - 9 = fffffff4 display.setText("-" + Integer.toHexString(Math.abs(displayInt))); } else { display.setText(Integer.toHexString(displayInt)); } // show all hexButtons since hexSwitch is true hexPanel.setVisible(true); } else { display.setText("" + calc.getDisplayValue()); // hide all hexButtons since hexSwitch is false hexPanel.setVisible(false); } }
public void init(Map whiteboard) { mWhiteBoard = whiteboard; // Get handle to broker mBroker = new ConfigBrokerProxy(); // Create a context mContext = (ConfigContext) mWhiteBoard.get("context"); mNodesListModel = new ConfigPtrListModel(mContext); mNodesListModel.addElementType(CLUSTER_NODE_TYPE); mBroker.addConfigListener(mNodesListModel); lstNodes.setModel(mNodesListModel); mHostnameField.setText(""); }
/* * The following method resets the window to its original status. */ public void init() { sampleField.setText(new String("Big Java")); textField.setText(new String("Big Java")); facenameCombo.setSelectedIndex(0); sizeCombo.setSelectedIndex(2); italicCheckBox.setSelected(false); boldCheckBox.setSelected(false); // largeButton.setSelected(true); fontColor = Color.BLACK; setSampleFont(); } // end init method
private void mAddNodeBtn_actionPerformed(ActionEvent e) { String host_name = mHostnameField.getText().trim(); String element_name = "Node(" + host_name + ")"; java.util.List elts = mBroker.getElements(mContext); java.util.List matches = ConfigUtilities.getElementsWithDefinition(elts, element_name); if (!host_name.equals("") && matches.size() == 0) { // Create a cluster_node element for the node ConfigElementFactory factory = new ConfigElementFactory(mBroker.getRepository().getAllLatest()); ConfigElement element = factory.create(element_name, CLUSTER_NODE_TYPE); mBroker.add(mContext, element); element.setProperty("host_name", 0, host_name); element.setProperty("listen_port", 0, "7000"); } mHostnameField.setText(""); }
/** * Pop-up a Dialog if the source and backup fields are the same. Returns true if the source and * backup remain the same. */ private boolean testSourceVsBackup() { if (dirTF.getText().equals(backupTF.getText())) { final String caption = ResourceHandler.getMessage("caption.warning"); MessageFormat formatter = new MessageFormat(ResourceHandler.getMessage("warning_dialog.info")); final String info = formatter.format(new Object[] {backupTF.getText()}); int n = JOptionPane.showConfirmDialog(this, info, caption, JOptionPane.WARNING_MESSAGE); if (n == JOptionPane.YES_OPTION) { backupTF.setText(backupTF.getText() + "_BAK"); return false; } else if (n == JOptionPane.NO_OPTION) return true; } return false; }
private void myInit2( SanBootView _view, Backupable _bakable, int _mode, int _type, BootHost host) { view = _view; bakable = _bakable; mode = _mode; type = _type; setupProfileType(); setupList(); setupLanguage(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); Date date = new Date(); String time = df.format(date); System.out.println(host.getID() + "-" + time); nameTextField.setText(host.getID() + "-" + time); if (mode == ProfileChooser.MODE_SAVEAS || mode == ProfileChooser.MODE_SAVE) { saveAsProfile = new UniProfile(); nameTextField.requestFocus(); } }