?? objectivevaluepanel.java
字號:
package com.power.util.Message;/** * <p>Title: PIPE Engine</p> * <p>Description: Global Planning Optimization Engine</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: Paraster, Inc.</p> * @author Wei Tan * @version 1.0 */import java.awt.*;import javax.swing.*;import java.util.ResourceBundle;import com.power.pipeengine.*;/** * ObjectiveValue is a one line JPanel that displays current iteration number * and objective value from the LP engine. It has a label and a field for the * iteration and objective value. * It is a singular class. */public class ObjectiveValuePanel extends JPanel { static ResourceBundle res = ResourceBundle.getBundle("com.power.util.Res", EngineConfig.getInstance().getLocale() ); private JLabel _objValueLabel = new JLabel( res.getString("Objective_Value_") ); //Use JTextField to display current objective value //Set the field to hold objective value with 4 columns. private JTextField _objValueField = new JTextField( 20 ); //Objective value is to be displayed as a string private String _objValueStr = ""; private JLabel _iterNumLabel = new JLabel( res.getString("Iteration_") ); private JTextField _iterNumField = new JTextField( 5 ); private String _iterNumStr = ""; //Runnable is used to update the _objValueField on the event dispatch thread. private Runnable runnable; private static final ObjectiveValuePanel INSTANCE = new ObjectiveValuePanel(); /** * class constructor */ private ObjectiveValuePanel() { init(); } /** * Gets the global instance of the singular class object. * @return the global instance. */ public static ObjectiveValuePanel getInstance( ) { return INSTANCE; } //initialize the class private void init() { _objValueField.setEditable( false ); //_objValueField.setSize( new Dimension( 200, 30 ) ); _iterNumField.setEditable( false ); this.setLayout( new FlowLayout() ); this.add( _iterNumLabel ); this.add( _iterNumField ); this.add( _objValueLabel ); this.add( _objValueField ); runnable = new Runnable() { public void run() { _iterNumField.setText( _iterNumStr ); _objValueField.setText( _objValueStr ); } }; } /** * Sets the global objective value for display at every 50 iterations and * refresh the JTextField. * @param value the current objective value to be displayed. */ public void setObjectiveValue( int iterNum, double value ) { _iterNumStr = Integer.toString( iterNum ); _objValueStr = Double.toString( value ); //refresh the JTextField after the _objValueStr being set. try { SwingUtilities.invokeLater( runnable ); } catch (Exception e ) {} }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -