⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subconfigbox.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	    // 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()) {		setModal(false);		SubConfigBox class_config_panel = 		    new SubConfigBox(this, data, temp, cfgVertexFocus);		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 subparam	    //	    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= begin; i <= end; 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 - begin);		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 - begin); 		checkBox.setSelected(value2);	    }	    // do nothing if the type is image	    //	    else if (data.type.get(i).equals("image")) {	    }	    	    // set all text field back to defaults	    //	    else {		JTextField text_box = (JTextField)enteredData.get(i - begin);		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 + -