private void setState(JDesktopPane dp, String state) {
   if (state == CLOSE) {
     JInternalFrame f = dp.getSelectedFrame();
     if (f == null) {
       return;
     }
     f.doDefaultCloseAction();
   } else if (state == MAXIMIZE) {
     // maximize the selected frame
     JInternalFrame f = dp.getSelectedFrame();
     if (f == null) {
       return;
     }
     if (!f.isMaximum()) {
       if (f.isIcon()) {
         try {
           f.setIcon(false);
           f.setMaximum(true);
         } catch (PropertyVetoException pve) {
         }
       } else {
         try {
           f.setMaximum(true);
         } catch (PropertyVetoException pve) {
         }
       }
     }
   } else if (state == MINIMIZE) {
     // minimize the selected frame
     JInternalFrame f = dp.getSelectedFrame();
     if (f == null) {
       return;
     }
     if (!f.isIcon()) {
       try {
         f.setIcon(true);
       } catch (PropertyVetoException pve) {
       }
     }
   } else if (state == RESTORE) {
     // restore the selected minimized or maximized frame
     JInternalFrame f = dp.getSelectedFrame();
     if (f == null) {
       return;
     }
     try {
       if (f.isIcon()) {
         f.setIcon(false);
       } else if (f.isMaximum()) {
         f.setMaximum(false);
       }
       f.setSelected(true);
     } catch (PropertyVetoException pve) {
     }
   }
 }
Пример #2
0
 @Override
 public void setIcon(boolean b) {
   try {
     super.setIcon(b);
   } catch (Exception ex) {
   }
 }
  public void activateFrame(JInternalFrame f) {
    JInternalFrame currentFrame = currentFrameRef != null ? currentFrameRef.get() : null;
    try {
      super.activateFrame(f);
      if (currentFrame != null && f != currentFrame) {
        // If the current frame is maximized, transfer that
        // attribute to the frame being activated.
        if (currentFrame.isMaximum()
            && (f.getClientProperty("JInternalFrame.frameType") != "optionDialog")) {
          // Special case.  If key binding was used to select next
          // frame instead of minimizing the icon via the minimize
          // icon.
          if (!currentFrame.isIcon()) {
            currentFrame.setMaximum(false);
            if (f.isMaximizable()) {
              if (!f.isMaximum()) {
                f.setMaximum(true);
              } else if (f.isMaximum() && f.isIcon()) {
                f.setIcon(false);
              } else {
                f.setMaximum(false);
              }
            }
          }
        }
        if (currentFrame.isSelected()) {
          currentFrame.setSelected(false);
        }
      }

      if (!f.isSelected()) {
        f.setSelected(true);
      }
    } catch (PropertyVetoException e) {
    }
    if (f != currentFrame) {
      currentFrameRef = new WeakReference(f);
    }
  }
Пример #4
0
  public static void init(
      JInternalFrame comp, Thing thing, Container parent, ActionContext actionContext) {
    JComponentCreator.init(comp, thing, parent, actionContext);

    String title = JavaCreator.createText(thing, "title", actionContext);
    if (title != null) {
      comp.setTitle(title);
    }

    Boolean closable = JavaCreator.createBoolean(thing, "closable");
    if (closable != null) {
      comp.setClosable(closable);
    }

    Boolean closed = JavaCreator.createBoolean(thing, "closed");
    if (closed != null) {
      try {
        comp.setClosed(closed);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Cursor cursor = AwtCreator.createCursor(thing, "cursor", actionContext);
    if (cursor != null) {
      comp.setCursor(cursor);
    }

    Integer defaultCloseOperation = null;
    String d = thing.getString("defaultCloseOperation");
    if ("DO_NOTHING_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.DO_NOTHING_ON_CLOSE;
    } else if ("HIDE_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.HIDE_ON_CLOSE;
    } else if ("DISPOSE_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.DISPOSE_ON_CLOSE;
    }
    if (defaultCloseOperation != null) {
      comp.setDefaultCloseOperation(defaultCloseOperation);
    }

    Boolean focusCycleRoot = JavaCreator.createBoolean(thing, "focusCycleRoot");
    if (focusCycleRoot != null) {
      comp.setFocusCycleRoot(focusCycleRoot);
    }

    Icon frameIcon = SwingCreator.createIcon(thing, "frameIcon", actionContext);
    if (frameIcon != null) {
      comp.setFrameIcon(frameIcon);
    }

    Boolean setIcon = JavaCreator.createBoolean(thing, "setIcon");
    if (setIcon != null) {
      try {
        comp.setIcon(setIcon);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Boolean iconifiable = JavaCreator.createBoolean(thing, "iconifiable");
    if (iconifiable != null) {
      comp.setIconifiable(iconifiable);
    }

    Integer layer = JavaCreator.createInteger(thing, "layer");
    if (layer != null) {
      comp.setLayer(layer);
    }

    Boolean maximizable = JavaCreator.createBoolean(thing, "maximizable");
    if (maximizable != null) {
      comp.setMaximizable(maximizable);
    }

    Boolean maximum = JavaCreator.createBoolean(thing, "maximum");
    if (maximum != null) {
      try {
        comp.setMaximum(maximum);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Boolean resizable = JavaCreator.createBoolean(thing, "resizable");
    if (resizable != null) {
      comp.setResizable(resizable);
    }

    Boolean selected = JavaCreator.createBoolean(thing, "selected");
    if (selected != null) {
      try {
        comp.setSelected(selected);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }
  }
Пример #5
0
 @Override
 public void setIcon(boolean b) throws PropertyVetoException {
   super.setIcon(b);
   target.setBounds(this.getBounds());
 }