📄 subconfigboxparam.java
字号:
if (blockType.get(i).equals("text")) { subVertex.values.set(i, ((JTextField)enteredData.get(i)).getText()); } // code to use if the data is a vector field // if (blockType.get(i).equals("vector")) { subVertex.values.set(i, ((JTextField)enteredData.get(i)).getText()); } // code to use if the data is an enumerated type // if(blockType.get(i).equals("enum")) { // set the vertex's value to match the newly selected one // subVertex.values. set(i,(String)((JComboBox)enteredData.get(i)). getSelectedItem()); } // code to get information from a check box // if (blockType.get(i).equals("boolean")) { boolean status = ((JCheckBox)enteredData.get(i)).isSelected(); String value = new String(); if(status) value = "true"; else value = "false"; subVertex.values.set(i,value); } // code to get information from a float variable // if (blockType.get(i).equals("float")) { String text = ((JTextField)enteredData.get(i)).getText(); try { float value = Float.valueOf(text).floatValue(); subVertex.values.set(i, text); } catch (java.lang.NumberFormatException event) { JFrame frame = new JFrame("Warning"); String warningMessage = new String("The value entered for " + subVertex.names.get(i) + " is not a floating point number."); JOptionPane.showMessageDialog(frame, warningMessage); return false; } } // code to get information from a double variable // if (blockType.get(i).equals("double")) { String text = ((JTextField)enteredData.get(i)).getText(); try { double value = Double.valueOf(text).doubleValue(); subVertex.values.set(i, text); } catch (java.lang.NumberFormatException event) { JFrame frame = new JFrame("Warning"); String warningMessage = new String("The value entered for " + subVertex.names.get(i) + " is not a floating point number."); JOptionPane.showMessageDialog(frame, warningMessage); return false; } } // code to get information from an unsigned integer variable // if (blockType.get(i).equals("unsigned-integer")) { String text = ((JTextField)enteredData.get(i)).getText(); try { int value = Integer.valueOf(text).intValue(); if (value >= 0) { subVertex.values.set(i, text); } else { JFrame frame = new JFrame("Warning"); String warningMessage = new String("The value entered for " + subVertex.names.get(i) + " is not an unsigned integer."); JOptionPane.showMessageDialog(frame,warningMessage); return false; } } catch (java.lang.NumberFormatException event) { JFrame frame = new JFrame("Warning"); String warningMessage = new String("The value entered for " + subVertex.names.get(i) + " is not an unsigned integer."); JOptionPane.showMessageDialog(frame, warningMessage); return false; } } // code to get information from an integer variable // if (blockType.get(i).equals("integer")) { String text = ((JTextField)enteredData.get(i)).getText(); try { int value = Integer.valueOf(text).intValue(); subVertex.values. set(i, text); } catch (java.lang.NumberFormatException event) { JFrame frame = new JFrame("Warning"); String warningMessage = new String("The value entered for " + subVertex.names.get(i) + " is not an integer."); JOptionPane.showMessageDialog(frame, warningMessage); return false; } } } return true; } // method: actionPerformed // // arguments: // ActionEvent e: event that was fired // // return : none // // listens for actions taking place on the components // public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("update")){ // validate the inputs and if they are all valid, // dispose of the box // if(validation()) { this.dispose(); parent.setModal(true); } } if(e.getActionCommand().equals("cancel")){ // dispose of the changes and revert to the old ways // this.dispose(); parent.setModal(true); } if(e.getActionCommand().equals("default")){ defaultSettings(); } if(e.getActionCommand().equals("revert")){ revertSettings(); } if(e.getActionCommand().equals("help")){ // display a help message: "under construction" // JFrame frame = new JFrame("Help"); JOptionPane.showMessageDialog(frame, "The help message is under construction"); } // create config window if dealing with a nested class for config // if(e.getActionCommand().equals("class")){ Vertex temp = (Vertex)e.getSource(); if(isModal() && isSubDiagOpen == 0) { setModal(false); SubConfigBox class_config_panel = new SubConfigBox(this, data, temp, subVertex); isSubDiagOpen = 1; class_config_panel.pack(); class_config_panel.setVisible(true); } } // create config window if dealing with a nested param for config // if(e.getActionCommand().equals("param")){ // if the block we've configured is a subclass // if(validation()) { //Vertex temp = (Vertex)e.getSource(); Vertex temp = (Vertex)subVertex.subparam.get(subVertex.subparam.size()-1); if(isModal()) { setModal(false); SubConfigBoxParam class_config_panel = new SubConfigBoxParam(this, data, temp, subVertex, subparamInfo); class_config_panel.pack(); class_config_panel.setVisible(true); } } } } // method: defaultSettings // // arguments: none // // return: none // // resets all configuartion items to the default values as given in // the gui configuration file // public void defaultSettings() { // get the name of the class we're working on // String association = subVertex.association; // get the beginning and end of my search for default data // int begin = data.association.indexOf(association); int end = data.association.lastIndexOf(association); // change all values back to the default // for(int i = subStart + subInfo.size(); i < subEnd; i++) { // set enum type back to default value // if(data.type.get(i).equals("enum")) { Vector enum_values = (Vector)data.values.get(i); // actually change the enum to the default setting // JComboBox select = (JComboBox)enteredData.get(i - subStart - subInfo.size()); select.setSelectedItem((String)enum_values.get(0)); } // make the check box revert to its previous state // else if (data.type.get(i).equals("boolean")){ // get the value for the check box // String value = (String)(data.values.get(i)); boolean value2; if (value.equals("true")) value2 = true; else value2 = false; // actually make the change to the check box // JCheckBox checkBox = (JCheckBox)enteredData.get(i - subStart - subInfo.size()); checkBox.setSelected(value2); } // do nothing if the type is image // else if (data.type.get(i).equals("image")) { } else if (data.type.get(i).equals("class")) { /* Vertex subclass = (Vertex)cfgVertexFocus.subclass.get(subclass_index); // get the name of the class we're working on // String association2 = subclass.association; // get the beginning and end of my search for default data // int begin2 = data.association.indexOf(association2); int end2 = data.association.lastIndexOf(association2); // change all values back to the default // for(int j= begin2; j <= end2; j++) { // set enum type back to default value // if(data.type.get(j).equals("enum")) { Vector enum_values = (Vector)data.values.get(j); subclass.values. set(j - begin2, enum_values.get(0)); } // make the check box revert to its default state // else if (data.type.get(j).equals("boolean")){ // get the value for the check box // subclass.values. set(j - begin2, data.values.get(j)); } // do nothing if the type is image // else if (data.type.get(j).equals("image")) { } // set all text field back to defaults // else { subclass.values. set(j - begin2, data.values.get(j)); } } subclass_index++; */ } else if (data.type.get(i).equals("param")) { } // set all text field back to defaults // else { JTextField text_box = (JTextField)enteredData.get(i - subStart - subInfo.size()); text_box.setText((String)data.values.get(i)); } } } // method: revertSettings // // arguments: none // // return: none // // resets all configuartion items to the values that were stored in the // referring vertex before the configuration began // public void revertSettings() { // run through these and add labels and input fields as appropriate // for(int i=0; i < subVertex.values.size(); i++) { // make the selected option revert to its previous state // if(subVertex.types.get(i).equals("enum")){ JComboBox select = (JComboBox)enteredData.get(i); select.setSelectedItem(subVertex.values.get(i)); } // make the check box revert to its previous state // else if (subVertex.types.get(i).equals("boolean")){ // get the value for the check box // String value = (String)(subVertex.values.get(i)); JCheckBox checkBox = (JCheckBox)enteredData.get(i); boolean value2; if (value.equals("true")) value2 = true; else value2 = false; checkBox.setSelected(value2); } // do nothing if the type is image // else if (subVertex.types.get(i).equals("image")) { } // take care of anything of type text // else if (subVertex.types.get(i).equals("text")) { JTextField text_box = (JTextField)enteredData.get(i); String text = (String)subVertex.values.get(i); text_box.setText(text); } // creation of input box for unsigned int // else if (subVertex.types.get(i).equals("unsigned-integer")) { JTextField text_box = (JTextField)enteredData.get(i); String text = (String)subVertex.values.get(i); text_box.setText(text); } // creation of input box for float // else if (subVertex.types.get(i).equals("float")) { JTextField text_box = (JTextField)enteredData.get(i); String text = (String)subVertex.values.get(i); text_box.setText(text); } // creation of input box for double // else if (subVertex.types.get(i).equals("double")) { JTextField text_box = (JTextField)enteredData.get(i); String text = (String)subVertex.values.get(i); text_box.setText(text); } // creation of input box for int // else if (subVertex.types.get(i).equals("integer")) { JTextField text_box = (JTextField)enteredData.get(i); String text = (String)subVertex.values.get(i); text_box.setText(text); } } }}//// end of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -