コード例 #1
0
 /**
  * Sets state of the frame, i.e. the location and dimension of the frame for the next use.
  *
  * @param s State to update to, or {@code null} to reset
  */
 public void setFrameState(String s) {
   try {
     _lastState = new FrameState(s);
   } catch (IllegalArgumentException e) {
     _lastState = null;
   }
   if (_lastState != null) {
     setSize(_lastState.getDimension());
     setLocation(_lastState.getLocation());
     int index = _lastState.getCurrentStrategyIndex();
     if ((index >= 0) && (index < _strategies.size())) {
       _currentStrategy = _strategies.get(index);
       _strategyBox.setSelectedIndex(index);
     }
     selectStrategy();
     validate();
   } else {
     Dimension parentDim = (_owner != null) ? _owner.getSize() : getToolkit().getScreenSize();
     // int xs = (int)parentDim.getWidth()/3;
     int ys = (int) parentDim.getHeight() / 4;
     // in line below, parentDim was _owner.getSize(); changed because former could generate
     // NullPointerException
     setSize(
         new Dimension(
             (int) getSize().getWidth(),
             (int) Math.min(parentDim.getHeight(), Math.max(ys, 300))));
     if (_owner != null) {
       setLocationRelativeTo(_owner);
     }
     _currentStrategy = _strategies.get(0);
     _strategyBox.setSelectedIndex(0);
     selectStrategy();
   }
 }
コード例 #2
0
 /**
  * Sets state of the frame, i.e. the location and dimension of the frame for the next use.
  *
  * @param ds State to update to, or {@code null} to reset
  */
 public void setFrameState(FrameState ds) {
   _lastState = ds;
   if (_lastState != null) {
     setSize(_lastState.getDimension());
     setLocation(_lastState.getLocation());
     int index = _lastState.getCurrentStrategyIndex();
     if ((index >= 0) && (index < _strategies.size())) {
       _currentStrategy = _strategies.get(index);
       _strategyBox.setSelectedIndex(index);
     }
     selectStrategy();
     validate();
   }
 }