Example #1
1
 public int getTitleHeight(Component c) {
   int th = 21;
   int fh = getBorderInsets(c).top + getBorderInsets(c).bottom;
   if (c instanceof JDialog) {
     JDialog dialog = (JDialog) c;
     th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
     if (dialog.getJMenuBar() != null) {
       th -= dialog.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JInternalFrame) {
     JInternalFrame frame = (JInternalFrame) c;
     th = frame.getSize().height - frame.getRootPane().getSize().height - fh - 1;
     if (frame.getJMenuBar() != null) {
       th -= frame.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JRootPane) {
     JRootPane jp = (JRootPane) c;
     if (jp.getParent() instanceof JFrame) {
       JFrame frame = (JFrame) c.getParent();
       th = frame.getSize().height - frame.getContentPane().getSize().height - fh - 1;
       if (frame.getJMenuBar() != null) {
         th -= frame.getJMenuBar().getSize().height;
       }
     } else if (jp.getParent() instanceof JDialog) {
       JDialog dialog = (JDialog) c.getParent();
       th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
       if (dialog.getJMenuBar() != null) {
         th -= dialog.getJMenuBar().getSize().height;
       }
     }
   }
   return th;
 }
  public Component add(JInternalFrame frame) {
    JInternalFrame[] array = getAllFrames();
    Point p;
    int w;
    int h;

    Component retval = super.add(frame);
    checkDesktopSize();
    if (array.length > 0) {
      p = array[0].getLocation();
      p.x = p.x + FRAME_OFFSET;
      p.y = p.y + FRAME_OFFSET;
    } else {
      p = new Point(0, 0);
    }
    frame.setLocation(p.x, p.y);
    /* Jimmy: this is a bit buggy (frames get constant size)
    if (frame.isResizable()) {
        w = getWidth() - (getWidth()/3);
        h = getHeight() - (getHeight()/3);
        if (w < frame.getMinimumSize().getWidth()) w = (int)frame.getMinimumSize().getWidth();
        if (h < frame.getMinimumSize().getHeight()) h = (int)frame.getMinimumSize().getHeight();
        frame.setSize(w, h);
    }*/
    moveToFront(frame);
    frame.setVisible(true);
    try {
      frame.setSelected(true);
    } catch (PropertyVetoException e) {
      frame.toBack();
    }
    return retval;
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
 public void xtestTiming() {
   final JDialog dialog = new JDialog((JFrame) null, "TestTiming");
   JDesktopPane pane = new JDesktopPane();
   dialog.setContentPane(pane);
   final Object[] f = {null};
   for (int i = 99; i >= 0; i--) {
     JInternalFrame frame = new JInternalFrame("Internal Frame - " + i, true, true, true, true);
     JButton s = new JButton("button" + i);
     s.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             final long start = System.currentTimeMillis();
             System.err.println("TestMarathonNamingStrategy.testTiming(): " + start);
             namingStrategy.setTopLevelComponent(dialog, true);
             String name = namingStrategy.getName((Component) e.getSource());
             System.err.println(
                 "TestMarathonNamingStrategy.testTiming(): name = "
                     + name
                     + "::"
                     + (System.currentTimeMillis() - start));
           }
         });
     f[0] = s;
     frame.getContentPane().add(s);
     frame.pack();
     frame.setLocation(i, i);
     frame.setVisible(true);
     pane.add(frame);
   }
   dialog.setSize(500, 500);
   dialog.setModal(true);
   dialog.setVisible(true);
   System.err.println(
       "TestMarathonNamingStrategy.testTiming(): " + ((Component) f[0]).isVisible());
 }
 public JInternalFrame getDefinedGUI() {
   ApplicationController applicationController = new ApplicationController();
   applicationController.initUi();
   JInternalFrame jinternalFrame = applicationController.getApplicationFrame();
   jinternalFrame.setVisible(false);
   return jinternalFrame;
 }
 @RunsInCurrentThread
 private static @Nonnull Pair<Container, Point> findMaximizeLocation(
     @Nonnull JInternalFrame internalFrame) {
   Container clickTarget = internalFrame.isIcon() ? internalFrame.getDesktopIcon() : internalFrame;
   Point location = maximizeButtonLocation(checkNotNull(clickTarget));
   return Pair.of(clickTarget, location);
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFInternetDomainBaseObj focus = getSwingFocusAsDomainBase();
   if (focus != null) {
     ICFInternetDomainBaseEditObj editObj = (ICFBamDomainBaseEditObj) focus.getEdit();
     if (editObj != null) {
       focus = editObj;
     }
     JInternalFrame frame = null;
     Container cont;
     JDesktopPane desktop;
     ICFBamTenantObj referencedObj =
         (ICFBamTenantObj) focus.getRequiredOwnerTenant(swingIsInitializing);
     if (referencedObj != null) {
       String classCode = referencedObj.getClassCode();
       if ("TENT".equals(classCode)) {
         frame = swingSchema.getTenantFactory().newViewEditJInternalFrame(referencedObj);
         cont = getParent();
         while ((cont != null) && (!(cont instanceof JInternalFrame))) {
           cont = cont.getParent();
         }
         if (cont != null) {
           JInternalFrame myInternalFrame = (JInternalFrame) cont;
           myInternalFrame.getDesktopPane().add(frame);
           frame.setVisible(true);
           frame.show();
         }
       } else {
         throw CFLib.getDefaultExceptionFactory()
             .newUnsupportedClassException(
                 getClass(), S_ProcName, "swingFocus", focus, "ICFBamTenantObj");
       }
     }
   }
 }
 public boolean isEnabled() {
   JInternalFrame iFrame = desktop.getSelectedFrame();
   if (iFrame != null) {
     return iFrame.isMaximizable();
   }
   return false;
 }
 /**
  * Ajusta el tamaño de la ventana al envelope pasado como parámetro
  *
  * @param ctx
  * @param newWrapperEnvelope
  * @param viewport
  */
 public static void resizeViewToEnvelope(
     PlugInContext ctx, Envelope newWrapperEnvelope, IViewport viewport) {
   // ajustamos las proporciones de la ventana a las de la feature
   JInternalFrame activeInternalFrame = ctx.getActiveInternalFrame();
   Dimension dimView = ((Dimension) ctx.getLayerViewPanel()).getSize();
   Double widthView = dimView.getWidth();
   Double heightView = dimView.getHeight();
   int widthDiff = (int) (activeInternalFrame.getWidth() - widthView);
   int heightDiff = (int) (activeInternalFrame.getHeight() - heightView);
   Integer newWidth =
       (int)
           ((newWrapperEnvelope.getWidth() / viewport.getEnvelopeInModelCoordinates().getWidth())
               * widthView);
   Integer newHeight =
       (int)
           ((newWrapperEnvelope.getHeight() / viewport.getEnvelopeInModelCoordinates().getHeight())
               * heightView);
   Dimension newDimensionView = new Dimension(newWidth + widthDiff, newHeight + heightDiff);
   activeInternalFrame.setSize(newDimensionView);
   // zoom al envelope actual
   try {
     viewport.zoom(newWrapperEnvelope);
   } catch (NoninvertibleTransformException e) {
     log.warn("No se ha podido alcanzar el zoom " + newWrapperEnvelope);
   }
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame frame = (JInternalFrame) cont;
     if (frame instanceof ICFSecuritySwingSecGroupFormJPanelCommon) {
       ICFSecuritySwingSecGroupFormJPanelCommon jpanelCommon =
           (ICFSecuritySwingSecGroupFormJPanelCommon) frame;
       jpanelCommon.setPanelMode(CFJPanel.PanelMode.Delete);
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUnsupportedClassException(
               getClass(),
               S_ProcName,
               "frame",
               frame,
               "ICFSecuritySwingSecGroupFormJPanelCommon");
     }
     try {
       frame.setClosed(true);
     } catch (Exception x) {
     }
   }
 }
Example #11
0
  public boolean mostrarJInternalFrame(JInternalFrame internalFrame) {
    try {
      desktopPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

      int numInternalFrames = desktopPane.getAllFrames().length;
      if (numInternalFrames == 0) {
        ClassLoader cl = this.getClass().getClassLoader();
        internalFrame.setFrameIcon(new javax.swing.ImageIcon(cl.getResource("img/geopista.gif")));
        desktopPane.add(internalFrame);
        internalFrame.setMaximum(true);
        internalFrame.show();
        try {
          iFrame = (JInternalFrame) internalFrame;
        } catch (Exception e) {
          iFrame = null;
        }
      } else {
        logger.info("cannot open another JInternalFrame");
      }

      desktopPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    } catch (Exception ex) {
      logger.warn("Exception: " + ex.toString());
    }

    return true;
  }
Example #12
0
 /**
  * Creates an Internal Frame.
  *
  * @param name the name of the app
  * @throws ClassNotFoundException
  * @throws IllegalAccessException
  * @throws InstantiationException
  */
 private void createFrame(String name)
     throws InstantiationException, IllegalAccessException, ClassNotFoundException {
   AbstractTool ti = (AbstractTool) Class.forName((String) toolmap.get(name)).newInstance();
   JInternalFrame f = ti.getInternalFrame();
   f.setVisible(true);
   desktop.add(f);
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFSecuritySchemaObj schemaObj = swingSchema.getSchema();
   if (schemaObj == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj");
   }
   ICFSecurityHostNodeObj obj =
       (ICFSecurityHostNodeObj) schemaObj.getHostNodeTableObj().newInstance();
   ICFSecurityHostNodeEditObj edit = (ICFSecurityHostNodeEditObj) (obj.beginEdit());
   if (edit == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "edit");
   }
   ICFSecurityClusterObj secCluster = schemaObj.getSecCluster();
   edit.setRequiredContainerCluster(secCluster);
   JInternalFrame frame = swingSchema.getHostNodeFactory().newViewEditJInternalFrame(obj);
   frame.addInternalFrameListener(getViewEditInternalFrameListener());
   ICFSecuritySwingHostNodeJPanelCommon jpanelCommon =
       (ICFSecuritySwingHostNodeJPanelCommon) frame;
   jpanelCommon.setPanelMode(CFJPanel.PanelMode.Add);
   getDesktopPane().add(frame);
   frame.setVisible(true);
   frame.show();
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFCrmSchemaObj schemaObj = swingSchema.getSchema();
   if (schemaObj == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj");
   }
   ICFSecurityServiceTypeObj selectedInstance = getSwingFocusAsServiceType();
   if (selectedInstance != null) {
     String classCode = selectedInstance.getClassCode();
     if ("SVCT".equals(classCode)) {
       JInternalFrame frame =
           swingSchema.getServiceTypeFactory().newAskDeleteJInternalFrame(selectedInstance);
       ((ICFCrmSwingServiceTypeJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
       frame.addInternalFrameListener(getViewEditInternalFrameListener());
       getDesktopPane().add(frame);
       frame.setVisible(true);
       frame.show();
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUnsupportedClassException(
               getClass(),
               S_ProcName,
               "selectedInstance",
               selectedInstance,
               "ICFCrmServiceTypeObj");
     }
   }
 }
Example #15
0
 public void init() {
   // 向内部窗口中添加组件
   iframe.add(new JScrollPane(new JTextArea(8, 40)));
   desktop.setPreferredSize(new Dimension(400, 300));
   // 把虚拟桌面添加到JFrame窗口中
   jf.add(desktop);
   // 设置内部窗口的大小、位置
   iframe.reshape(0, 0, 300, 200);
   // 显示并选中内部窗口
   iframe.show();
   desktop.add(iframe);
   JPanel jp = new JPanel();
   deskBn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 弹出内部对话框,以虚拟桌面作为父组件
           JOptionPane.showInternalMessageDialog(desktop, "属于虚拟桌面的对话框");
         }
       });
   internalBn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 弹出内部对话框,以内部窗口作为父组件
           JOptionPane.showInternalMessageDialog(iframe, "属于内部窗口的对话框");
         }
       });
   jp.add(deskBn);
   jp.add(internalBn);
   jf.add(jp, BorderLayout.SOUTH);
   jf.pack();
   jf.setVisible(true);
 }
  /**
   * Reacts to property change events 'editorClosing', 'closeFrame', and 'name'.
   *
   * @param e the property change event.
   */
  public void propertyChange(PropertyChangeEvent e) {

    // Handles the removal of editor frames from desktop
    String name = e.getPropertyName();

    if ("editorClosing".equals(name)) {

      // find NewValue in String array, and remove
      for (int n = 0; n < sessionNodeKeys.size(); n++) {
        if (e.getNewValue().equals((sessionNodeKeys.get(n)))) {
          sessionNodeKeys.remove(n);
        }
      }
    } else if ("closeFrame".equals(e.getPropertyName())) {
      if (getFramesMap().containsKey(e.getSource())) {
        Object frameObject = getFramesMap().get(e.getSource());
        JInternalFrame frame = (JInternalFrame) frameObject;
        frame.setVisible(false);
        frame.dispose();
      }
    } else if ("name".equals(e.getPropertyName())) {
      if (getFramesMap().containsKey(e.getSource())) {
        Object frameObject = getFramesMap().get(e.getSource());
        JInternalFrame frame = (JInternalFrame) frameObject;
        String _name = (String) (e.getNewValue());
        frame.setTitle(_name);
        setMainTitle(_name);
      }
    }
  }
 /**
  * Abre el Caso de Uso e inicia su ejecución para las ventanas
  * VentanaActualizarTiposGenericoContable y VentanaActualizarTiposGenerico
  *
  * @param nombreClaseVentana Nombre de la Clase de la Ventana que se va a mostrar.
  * @param nombreClaseGenerica Nombre de la Clase que se va a actualizar.
  * @param titulo Nombre de la parte del título que indica actividad (no poner todo completo, solo
  *     lo que se está actualizando). La ventana mostrará: "Actualizar " + titulo.
  * @return Referencia a la ventana creada.
  */
 public JInternalFrame iniciarCUGenerico(Class claseVentana, Class claseGenerica, String titulo) {
   JInternalFrame ventana = null;
   try {
     // Instanciar el CU.
     ventana = (JInternalFrame) claseVentana.newInstance();
     VentanaMenuPrincipal.getInstancia().getPanelPrincipal().add(ventana);
     // Establece la posicion de la ventana.
     generarPosicionVentana();
     ventana.setLocation(getPosicionXVentana(), getPosicionYVentana());
     // Muestra la ventana.
     ventana.setVisible(true);
     // Intenta establecer a la ventana como seleccionada,
     // Si no puede, lanza imprime la excepcion en la salida estandar.
     try {
       ventana.setSelected(true);
     } catch (java.beans.PropertyVetoException e) {
       log.warn("Error al establecer ventana como seleccionada.", e);
     }
     InterfazTipoGenerico tg = (InterfazTipoGenerico) claseGenerica.newInstance();
     ((VentanaActualizarTipos) ventana).opcionActualizarTipos(titulo, tg);
     log.debug(
         "Iniciado CU Genérico: "
             + claseVentana.getName()
             + " - Para la Clase: "
             + claseGenerica.getName());
   } catch (InstantiationException ex) {
     log.error("No se pudo instanciar la clase", ex);
   } catch (IllegalAccessException ex) {
     log.error("No se pudo instanciar la clase", ex);
   }
   return ventana;
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame frame = (JInternalFrame) cont;
     if (frame instanceof ICFSecuritySwingISOCurrencyJPanelCommon) {
       ICFSecuritySwingISOCurrencyJPanelCommon jpanelCommon =
           (ICFSecuritySwingISOCurrencyJPanelCommon) frame;
       jpanelCommon.setPanelMode(CFJPanel.PanelMode.Unknown);
       ICFSecurityISOCurrencyEditObj editObj =
           (ICFSecurityISOCurrencyEditObj) jpanelCommon.getSwingFocusAsISOCurrency().getEdit();
       if (editObj != null) {
         editObj.endEdit();
       }
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUnsupportedClassException(
               getClass(),
               S_ProcName,
               "frame",
               frame,
               "ICFSecuritySwingISOCurrencyJPanelCommon");
     }
     try {
       frame.setClosed(true);
     } catch (Exception x) {
     }
   }
 }
Example #19
0
 public void saveFrameConfiguration() {
   String frameTitle = jif.getTitle();
   pref.putInt(frameTitle + posXPreferenceKey, jif.getX());
   pref.putInt(frameTitle + posYPreferenceKey, jif.getY());
   pref.putInt(frameTitle + sizeXPreferenceKey, jif.getSize().width);
   pref.putInt(frameTitle + sizeYPreferenceKey, jif.getSize().height);
   pref.putBoolean(frameTitle + isVisiblePreferenceKey, jif.isVisible());
 }
  /**
   * Method to update the network title on the JInternalFrame, but not in the network panel.
   *
   * @param network CyNetwork
   * @param title String
   */
  public void updateNetworkTitle(CyNetwork network, String title) {
    final JInternalFrame frame = networkViewMap.get(network.getIdentifier());

    if (frame != null) {
      frame.setTitle(title);
      frame.repaint();
    }
  }
Example #21
0
 public void disposeCurrentFrame() {
   if (currentFrame != null) {
     lastLocation = currentFrame.getLocation();
     currentFrame.setVisible(false);
     currentFrame.dispose();
     currentFrame = null;
   }
 }
  public void centrarFrm(JInternalFrame hijo, VistaMDI padre) {

    hijo.setLocation(
        padre.getWidth() / 2 - hijo.getWidth() / 2,
        padre.getHeight() / 2 - hijo.getHeight() / 2 - 20);
    // CENTRA EL FORMULARIO

  }
 public void openHelpWindow() {
   JInternalFrame help = new MetalworksHelp();
   desktop.add(help, HELPLAYER);
   try {
     help.setVisible(true);
     help.setSelected(true);
   } catch (java.beans.PropertyVetoException e2) {
   }
 }
Example #24
0
  private synchronized void display(ExtSed sed) {

    manageAssociatedManagerWindows(sed);

    try {

      SpectrumContainer container =
          (SpectrumContainer) sed.getAttachment(IrisDisplayManager.FIT_MODEL);

      // There is no Sed attachment, so build a model manager and attach it.

      if (container == null) {
        if (buildAttachment(sed)) {
          return;
        }
      }

      // VAOPD-879: spectrum name must be identical with Sed name.
      if (container != null) {
        container.getSpectrum().setName(sed.getId());
      }

      // Now display the Sed.

      idm.display(sed, sed.getId());

      // and add its frame to the workspace.

      JInternalFrame frame = idm.getInternalFrame();

      // VAOPD-863
      frame.setTitle(sed.getId());

      if (container != null) {
        JFrame modelManagerFrame = container.getModelManager().getFrame();
        if (modelManagerFrame != null) {
          modelManagerFrame.setTitle(sed.getId());
        }
      }

      if (frame != currentFrame) {
        lastLocation = null;
        disposeCurrentFrame();
        currentFrame = frame;
        currentFrame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
        if (lastLocation != null) {
          currentFrame.setLocation(lastLocation);
        }
        frame.setTitle("Iris Visualizer");
        ws.addFrame(frame);
      }

    } catch (Exception ex) {
      LogEvent.getInstance().fire(this, new LogEntry("Error: " + ex.getMessage(), sed));
      Logger.getLogger("IrisVisualizer").log(Level.SEVERE, null, ex);
    }
  }
Example #25
0
 /**
  * Show the code window and all its component parts
  *
  * @param b
  */
 public void setVisible(boolean b) {
   //    System.out.println("kCodeWindow opaque >> editFrame="+editFrame.isOpaque()+ "
   // buttonFrame="+buttonFrame.isOpaque()+" triangleFrame="+triangleFrame.isOpaque());
   editFrame.setVisible(b);
   buttonFrame.setVisible(b);
   triangleFrame.setVisible(b);
   ((DrawingArea) desktop).fireCodeWindowEvent();
   if (b) textarea.requestFocus();
 }
 public void openInBox() {
   JInternalFrame doc = new MetalworksInBox();
   desktop.add(doc, DOCLAYER);
   try {
     doc.setVisible(true);
     doc.setSelected(true);
   } catch (java.beans.PropertyVetoException e2) {
   }
 }
 public void testRecordsFrameClosing()
     throws PropertyVetoException, InterruptedException, InvocationTargetException {
   JInternalFrame internalFrame = createInternalFrame();
   int initialListenerCount = internalFrameListenerCount(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new InternalFrameShownEvent("title")));
   recorder.componentShown(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new CloseInternalFrameEvent("title")));
   internalFrame.setClosed(true);
 }
 /**
  * Used to unset the focus of all the views. This is for the situation when a network is focused
  * but the network doesn't have a view.
  */
 protected void unsetFocus() {
   for (JInternalFrame f : networkViewMap.values()) {
     try {
       f.setSelected(false);
     } catch (PropertyVetoException pve) {
       logger.info("NetworkViewManager: Couldn't unset focus for internal frame.");
     }
   }
 }
Example #29
0
  public Object showWindow(final MkWindow macWindow, String title, boolean isModal) {
    listMkWindow.add(macWindow);
    if (isModal) {
      JDialog modalFrame = new JDialog(this, title, true);
      // macWindow.setJanela(modalFrame);
      final MkRun onCloseWindow = macWindow.onCloseWindow;
      modalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
      modalFrame.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              if (onCloseWindow != null) {
                onCloseWindow.execute();
              }
              disposeWindow(macWindow);
            }
          });
      modalFrame.setLayout(new BorderLayout());
      modalFrame.add(macWindow, BorderLayout.CENTER);
      modalFrame.pack();
      Dimension desktopSize = desktopPane.getSize();
      int x = (desktopSize.width - modalFrame.getWidth()) / 2;
      int y = (desktopSize.height - modalFrame.getHeight()) / 2;
      modalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y));
      if (macWindow.panelButton != null) {
        modalFrame.getRootPane().setDefaultButton((JButton) macWindow.panelButton.getComponent(0));
      }
      modalFrame.setVisible(true);
      return modalFrame;
    } else {
      JInternalFrame internalFrame = new JInternalFrame(title, true, true, true, true);
      internalFrame.setContentPane(macWindow);
      internalFrame.pack();
      //            internalFrame.setBounds(internalFrame.getBounds()); //pq?
      desktopPane.add(internalFrame);

      internalFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
      final MkRun onCloseWindow = macWindow.onCloseWindow;
      if (onCloseWindow != null) {
        internalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);

        internalFrame.addInternalFrameListener(
            new InternalFrameAdapter() {
              public void internalFrameClosing(InternalFrameEvent e) {
                onCloseWindow.execute();
              }
            });
      }

      Dimension desktopSize = desktopPane.getSize();
      int x = (desktopSize.width - internalFrame.getWidth()) / 2;
      int y = (desktopSize.height - internalFrame.getHeight()) / 2;
      internalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y));
      internalFrame.setVisible(true);
      return internalFrame;
    }
  }
 private void jCheckBox1ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jCheckBox1ActionPerformed
   javax.swing.JInternalFrame other = new AmmendMainStockCategoryintfr(connectDB, pConnDB);
   this.getParent().add(other, javax.swing.JLayeredPane.DEFAULT_LAYER);
   try {
     other.setSelected(true);
   } catch (java.beans.PropertyVetoException pvt) {
   }
   other.setVisible(true); // Add your handling code here:
 } // GEN-LAST:event_jCheckBox1ActionPerformed