Пример #1
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);
 }
 protected void installDesktopManager() {
   desktopManager = desktop.getDesktopManager();
   if (desktopManager == null) {
     desktopManager = new BasicDesktopManager();
     desktop.setDesktopManager(desktopManager);
   }
 }
 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) {
     }
   }
 }
Пример #4
0
 public void verificaTelaAberta(String nomeTela) {
   if (ctlTela == null) {
     switch (nomeTela) {
       case "Pedido":
         ctlTela = new ctlPedido(nomeTela, this);
         break;
       case "Receber Pedidos Pendentes":
         ctlTela = new ctlReceberPedidosPendentes(nomeTela, this);
         break;
       case "Realizar Entrega":
         ctlTela = new ctlRealizarEntrega(nomeTela, this);
         break;
       case "Efetuar Pagamento":
         ctlTela = new ctlEfetuarPagamento(nomeTela, this);
         break;
       case "Cadastrar Cliente":
         ctlTela = new ctlCadCliente(nomeTela, this);
         break;
       case "Cadastrar Produto":
         ctlTela = new ctlCadProduto(nomeTela, this);
         break;
     }
     try {
       ctlTela.setMaximum(true);
       jdPane.moveToFront(ctlTela);
     } catch (PropertyVetoException ex) {
       Logger.getLogger(frmMenu.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 }
Пример #5
0
  public MainUI() {
    super("Neato Burrito");

    dLog.trace("In MainUI: " + MainUI.class.getCanonicalName());

    this.setBounds(0, 0, 500, 500);
    Container container = getContentPane();
    container.add(theDesktop);
    setJMenuBar(menubar);
    JMenu fileMenu = new JMenu("File");
    JMenuItem exitItem = new JMenuItem("Exit");
    exitItem.setMnemonic('X');
    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    fileMenu.add(exitItem);
    menubar.add(fileMenu);

    StatusUI statUI = new StatusUI();
    statUI.setVisible(true);
    theDesktop.add(statUI);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    setVisible(true);
  }
Пример #6
0
 /** This method will create a new frame to place a new Sudoku puzzle. */
 protected void createNewGameFrame() {
   newGameFrame = new SudokuInternal();
   newGameFrame.setVisible(true);
   newGameFrame.setSize(500, 280);
   newGameFrame.doneButton.addActionListener(new DoneActionListener());
   desktop.add(newGameFrame);
 }
Пример #7
0
  public MapEditor(LocalSettings localSettings) throws HeadlessException {
    setTitle(TITLE);
    setSize(WIDTH, HEIGHT);

    this.localSettings = localSettings;

    mainpane = new JDesktopPane();
    mainpane.setSize(WIDTH, HEIGHT);
    mainpane.setBackground(Color.GRAY);
    setContentPane(mainpane);

    LwjglApplicationConfiguration configuration = new LwjglApplicationConfiguration();
    configuration.width = WIDTH;
    configuration.height = HEIGHT;

    levelHolder = new LevelHolder();
    final LwjglCanvas lwjglCanvas = new LwjglCanvas(levelHolder, configuration);
    canvas = lwjglCanvas;
    levelHolderFrame = new JInternalFrame("EnJine2D Map", false, false, false, true);
    levelHolderFrame.setSize(WIDTH, HEIGHT);
    levelHolderFrame.setVisible(true);

    palette = new Palette("Palette", true, false, true, true);
    palette.setVisible(true);
    palette.setLevelHolder(levelHolder);
    levelHolder.setPalette(palette);

    getContentPane().add(palette);
    getContentPane().add(levelHolderFrame);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            levelHolderFrame.getContentPane().add(lwjglCanvas.getCanvas());
            setVisible(true);
          }
        });

    loadSettings();

    levelHolderFrame.addComponentListener(this);
    palette.addComponentListener(this);

    addWindowListener(this);
  }
 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 openHelpWindow() {
   JInternalFrame help = new MetalworksHelp();
   desktop.add(help, HELPLAYER);
   try {
     help.setVisible(true);
     help.setSelected(true);
   } catch (java.beans.PropertyVetoException e2) {
   }
 }
Пример #10
0
 /** This method will create a frame to show the user all the scores in order. */
 protected void createHighscoreFrame() {
   highScoreFrame = new Highscore();
   highScoreFrame.setVisible(true);
   highScoreFrame.setBounds(
       250, // left
       10, // top
       10, // bottom
       10); // right
   highScoreFrame.newGame.addActionListener(new NewGameButtonListener());
   highScoreFrame.pack();
   desktop.add(highScoreFrame);
 }
 public boolean isEnabled(Object sender) {
   if (sender instanceof JDesktopPane) {
     JDesktopPane dp = (JDesktopPane) sender;
     String action = getName();
     if (action == Actions.NEXT_FRAME || action == Actions.PREVIOUS_FRAME) {
       return true;
     }
     JInternalFrame iFrame = dp.getSelectedFrame();
     if (iFrame == null) {
       return false;
     } else if (action == Actions.CLOSE) {
       return iFrame.isClosable();
     } else if (action == Actions.MINIMIZE) {
       return iFrame.isIconifiable();
     } else if (action == Actions.MAXIMIZE) {
       return iFrame.isMaximizable();
     }
     return true;
   }
   return false;
 }
Пример #12
0
 private void handleSpecialCase(String cname, int condition) {
   Component comp = null;
   JComponent mapComp = null;
   try {
     if (cname.equals("javax.swing.JApplet")
         || cname.equals("javax.swing.JDialog")
         || cname.equals("javax.swing.JFrame")
         || cname.equals("javax.swing.JWindow")) {
       comp = (Component) Class.forName(cname).newInstance();
       mapComp = (JComponent) ((JApplet) comp).getLayeredPane();
       results.setText("Map entries for " + cname + " (delegated to JRootPane):\n\n");
     } else if (cname.equals("javax.swing.JInternalFrame")) {
       JDesktopPane jdp = new JDesktopPane();
       JInternalFrame jif = new JInternalFrame("Demo");
       jif.setVisible(true);
       jdp.add(jif);
       mapComp = jif;
     }
     if (inputB.isSelected()) {
       loadInputMap(mapComp.getInputMap(condition), "");
       results.append("\n");
     }
     if (actionB.isSelected()) {
       loadActionMap(mapComp.getActionMap(), "");
       results.append("\n");
     }
     if (bindingB.isSelected()) {
       loadBindingMap(mapComp, condition);
     }
   } catch (ClassCastException cce) {
     results.setText(cname + " is not a subclass of JComponent.");
   } catch (ClassNotFoundException cnfe) {
     results.setText(cname + " was not found.");
   } catch (InstantiationException ie) {
     results.setText(cname + " could not be instantiated.");
   } catch (Exception e) {
     results.setText("Exception found:\n" + e);
     e.printStackTrace();
   }
 }
Пример #13
0
 /** This method will create a frame to show the user his or her Sudoku performance. */
 protected void createScoreFrame() {
   // test = new Score();
   scoreFrame.discard.addActionListener(new DiscardButtonListener());
   scoreFrame.submit.addActionListener(new SubmitHighscoreButtonListener());
   scoreFrame.setLayer(JLayeredPane.PALETTE_LAYER);
   scoreFrame.setVisible(true);
   scoreFrame.setBounds(
       250, // left
       10, // top
       10, // bottom
       10); // right
   scoreFrame.setSize(300, 400);
   scoreFrame.setTitle("Score");
   scoreFrame.pack();
   desktop.add(scoreFrame);
 }
Пример #14
0
  protected void setUpSRSFrame(URL url, String search) throws IOException {
    if (BigPane.srsFrame == null) {
      BigPane.setUpSRSFrame((2 * desktop.getHeight()) / 3, desktop);
      Border loweredbevel = BorderFactory.createLoweredBevelBorder();
      Border raisedbevel = BorderFactory.createRaisedBevelBorder();
      Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);

      JTextField statusField = new JTextField();
      statusField.setBorder(compound);
      statusField.setEditable(false);
      BigPane.srsFrame.getContentPane().add(statusField, BorderLayout.SOUTH);
    }

    Annotation edPane = new Annotation(url);
    JScrollPane jsp = new JScrollPane(edPane);
    JTabbedPane jtab = (JTabbedPane) BigPane.srsFrame.getContentPane().getComponent(0);
    jtab.insertTab(search, null, jsp, null, 0);
    BigPane.srsFrame.setVisible(true);
  }
Пример #15
0
  public void selectEntityFrame(DustEntity entity, boolean createIfMissing) {
    EntityFrame iFrm = mapEntityFrames.get(entity);

    if (null == iFrm) {
      if (createIfMissing) {
        iFrm = new EntityFrame(entity);

        mapEntityFrames.put(entity, iFrm);
        desktop.add(iFrm);
      }
    }

    if (null != iFrm) {
      iFrm.show();
      iFrm.toFront();
      try {
        iFrm.setSelected(true);
      } catch (PropertyVetoException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
    public void actionPerformed(ActionEvent e) {
      JDesktopPane dp = (JDesktopPane) e.getSource();
      String key = getName();

      if (CLOSE == key || MAXIMIZE == key || MINIMIZE == key || RESTORE == key) {
        setState(dp, key);
      } else if (ESCAPE == key) {
        if (sourceFrame == dp.getSelectedFrame() && focusOwner != null) {
          focusOwner.requestFocus();
        }
        moving = false;
        resizing = false;
        sourceFrame = null;
        focusOwner = null;
      } else if (MOVE == key || RESIZE == key) {
        sourceFrame = dp.getSelectedFrame();
        if (sourceFrame == null) {
          return;
        }
        moving = (key == MOVE) ? true : false;
        resizing = (key == RESIZE) ? true : false;

        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if (!SwingUtilities.isDescendingFrom(focusOwner, sourceFrame)) {
          focusOwner = null;
        }
        sourceFrame.requestFocus();
      } else if (LEFT == key
          || RIGHT == key
          || UP == key
          || DOWN == key
          || SHRINK_RIGHT == key
          || SHRINK_LEFT == key
          || SHRINK_UP == key
          || SHRINK_DOWN == key) {
        JInternalFrame c = dp.getSelectedFrame();
        if (sourceFrame == null
            || c != sourceFrame
            || KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()
                != sourceFrame) {
          return;
        }
        Insets minOnScreenInsets = UIManager.getInsets("Desktop.minOnScreenInsets");
        Dimension size = c.getSize();
        Dimension minSize = c.getMinimumSize();
        int dpWidth = dp.getWidth();
        int dpHeight = dp.getHeight();
        int delta;
        Point loc = c.getLocation();
        if (LEFT == key) {
          if (moving) {
            c.setLocation(
                loc.x + size.width - MOVE_RESIZE_INCREMENT < minOnScreenInsets.right
                    ? -size.width + minOnScreenInsets.right
                    : loc.x - MOVE_RESIZE_INCREMENT,
                loc.y);
          } else if (resizing) {
            c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y);
            c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);
          }
        } else if (RIGHT == key) {
          if (moving) {
            c.setLocation(
                loc.x + MOVE_RESIZE_INCREMENT > dpWidth - minOnScreenInsets.left
                    ? dpWidth - minOnScreenInsets.left
                    : loc.x + MOVE_RESIZE_INCREMENT,
                loc.y);
          } else if (resizing) {
            c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);
          }
        } else if (UP == key) {
          if (moving) {
            c.setLocation(
                loc.x,
                loc.y + size.height - MOVE_RESIZE_INCREMENT < minOnScreenInsets.bottom
                    ? -size.height + minOnScreenInsets.bottom
                    : loc.y - MOVE_RESIZE_INCREMENT);
          } else if (resizing) {
            c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT);
            c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);
          }
        } else if (DOWN == key) {
          if (moving) {
            c.setLocation(
                loc.x,
                loc.y + MOVE_RESIZE_INCREMENT > dpHeight - minOnScreenInsets.top
                    ? dpHeight - minOnScreenInsets.top
                    : loc.y + MOVE_RESIZE_INCREMENT);
          } else if (resizing) {
            c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);
          }
        } else if (SHRINK_LEFT == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.width - minSize.width;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.x + size.width - delta < minOnScreenInsets.left) {
            delta = loc.x + size.width - minOnScreenInsets.left;
          }
          c.setSize(size.width - delta, size.height);
        } else if (SHRINK_RIGHT == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.width - minSize.width;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.x + delta > dpWidth - minOnScreenInsets.right) {
            delta = (dpWidth - minOnScreenInsets.right) - loc.x;
          }

          c.setLocation(loc.x + delta, loc.y);
          c.setSize(size.width - delta, size.height);
        } else if (SHRINK_UP == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.height - minSize.height;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.y + size.height - delta < minOnScreenInsets.bottom) {
            delta = loc.y + size.height - minOnScreenInsets.bottom;
          }

          c.setSize(size.width, size.height - delta);
        } else if (SHRINK_DOWN == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.height - minSize.height;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.y + delta > dpHeight - minOnScreenInsets.top) {
            delta = (dpHeight - minOnScreenInsets.top) - loc.y;
          }

          c.setLocation(loc.x, loc.y + delta);
          c.setSize(size.width, size.height - delta);
        }
      } else if (NEXT_FRAME == key || PREVIOUS_FRAME == key) {
        dp.selectFrame((key == NEXT_FRAME) ? true : false);
      } else if (NAVIGATE_NEXT == key || NAVIGATE_PREVIOUS == key) {
        boolean moveForward = true;
        if (NAVIGATE_PREVIOUS == key) {
          moveForward = false;
        }
        Container cycleRoot = dp.getFocusCycleRootAncestor();

        if (cycleRoot != null) {
          FocusTraversalPolicy policy = cycleRoot.getFocusTraversalPolicy();
          if (policy != null && policy instanceof SortingFocusTraversalPolicy) {
            SortingFocusTraversalPolicy sPolicy = (SortingFocusTraversalPolicy) policy;
            boolean idc = sPolicy.getImplicitDownCycleTraversal();
            try {
              sPolicy.setImplicitDownCycleTraversal(false);
              if (moveForward) {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(dp);
              } else {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(dp);
              }
            } finally {
              sPolicy.setImplicitDownCycleTraversal(idc);
            }
          }
        }
      }
    }
 protected void uninstallDesktopManager() {
   if (desktop.getDesktopManager() instanceof UIResource) {
     desktop.setDesktopManager(null);
   }
   desktopManager = null;
 }
Пример #18
0
  /** The graphic handling and deployment. */
  private void initComponents() {
    jDesktopPane1 = new javax.swing.JDesktopPane();
    jInternalFrame1 = new javax.swing.JInternalFrame();
    tf = new javax.swing.JTextField();
    b1 = new javax.swing.JButton();
    jInternalFrame3 = new javax.swing.JInternalFrame();
    ta = new javax.swing.JTextArea();
    jsp_ta = new javax.swing.JScrollPane(ta);
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    jMenuItem4 = new javax.swing.JMenuItem();

    jInternalFrame1
        .getContentPane()
        .setLayout(
            new javax.swing.BoxLayout(
                jInternalFrame1.getContentPane(), javax.swing.BoxLayout.X_AXIS));

    jInternalFrame1.setIconifiable(true);
    jInternalFrame1.setMaximizable(true);
    jInternalFrame1.setResizable(true);
    jInternalFrame1.setTitle("Message editor");
    jInternalFrame1.setToolTipText(
        "Move and resize all of these to make the chat room appearance match your preferences.");
    jInternalFrame1.setVisible(true);
    tf.setFont(new java.awt.Font("Lucida Sans", 0, 12));
    jInternalFrame1.getContentPane().add(tf);

    b1.setText("Send Message");
    jInternalFrame1.getContentPane().add(b1);

    jInternalFrame1.setBounds(10, 10, 440, 60);
    jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);

    jInternalFrame3.setIconifiable(true);
    jInternalFrame3.setMaximizable(true);
    jInternalFrame3.setResizable(true);
    jInternalFrame3.setTitle("Messages");
    jInternalFrame3.setToolTipText(
        "Move and resize all of these to make the chat room appearance match your preferences.");
    jInternalFrame3.setVisible(true);
    ta.setBackground(new Color(255, 255, 255));
    ta.setEditable(false);
    ta.setFont(new java.awt.Font("Lucida Sans", 0, 12));
    // jsp_ta.setAutoscrolls(true);
    jsp_ta.setDoubleBuffered(true);

    jInternalFrame3.getContentPane().add(jsp_ta, java.awt.BorderLayout.CENTER);

    jInternalFrame3.setBounds(10, 80, 420, 240);

    jDesktopPane1.add(jInternalFrame3, javax.swing.JLayeredPane.DEFAULT_LAYER);

    getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);

    jMenu1.setText("Private room options");
    jMenu1.setMnemonic(KeyEvent.VK_O);
    jMenu1.setToolTipText("Choose some options.");
    jMenuItem3.setText("Save conversation");
    jMenuItem3.setMnemonic(KeyEvent.VK_S);
    jMenuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    jMenu1.add(jMenuItem3);
    jMenu1.add(jSeparator1);
    jMenuItem4.setText("Exit");
    jMenuItem4.setMnemonic(KeyEvent.VK_E);
    jMenuItem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
    jMenu1.add(jMenuItem4);
    jMenuBar1.add(jMenu1);
    setJMenuBar(jMenuBar1);

    this.pack();

    b1.addActionListener(this);
    tf.addActionListener(this);
    jMenuItem3.addActionListener(this);
    jMenuItem4.addActionListener(this);

    posx = (int) Math.random() * 640;
    posy = (int) Math.random() * 480;

    this.pack();
    this.setSize(dimx, dimy);
    this.setLocation(posx, posy);
    this.show();
  }
 /**
  * Uninstalls the <code>PropertyChangeListener</code> returned from <code>
  * createPropertyChangeListener</code> from the <code>JDesktopPane</code>.
  *
  * @since 1.5
  * @see #createPropertyChangeListener
  */
 protected void uninstallListeners() {
   desktop.removePropertyChangeListener(pcl);
   pcl = null;
 }
Пример #20
0
  /**
   * Method to handle hyper link events.
   *
   * @param event hyper link event
   */
  public void hyperlinkUpdate(HyperlinkEvent event) {
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      setCursor(cbusy);
      try {
        URL url = event.getURL();

        int ind1 = event.getDescription().indexOf("[");
        int ind2 = event.getDescription().lastIndexOf("]");

        String search = "";
        if (ind1 > -1 && ind2 > -1) search = event.getDescription().substring(ind1 + 1, ind2);
        else {
          ind1 = event.getDescription().indexOf("=") + 1; // genedb
          if (ind1 > -1) search = event.getDescription().substring(ind1);
        }

        if (desktop != null) {
          if (BigPane.srsTabPane.isSelected()) setUpSRSFrame(url, search);

          if (BigPane.srsWin.isSelected()) {
            int hgt = (2 * desktop.getHeight()) / 3;
            Annotation edPane = new Annotation(url);
            JScrollPane jsp = new JScrollPane(edPane);
            JInternalFrame jif =
                new JInternalFrame(
                    "SRS " + search,
                    true, // resizable
                    true, // closable
                    true, // maximizable
                    true); // iconifiable);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(new CommonMenu(jif));
            jif.setJMenuBar(menuBar);
            jif.getContentPane().add(jsp);
            jif.setLocation(0, 0);
            jif.setSize(800, hgt);
            jif.setVisible(true);
            desktop.add(jif);
          }

          if (BigPane.srsBrowser.isSelected()) BrowserControl.displayURL(event.getDescription());
        } else {
          setPage(url);
          back.add(url);
        }
      } catch (IOException ioe) {
        String msg = event.getDescription();
        if (msg.length() > 50) msg = msg.substring(0, 50) + "....";

        JOptionPane.showMessageDialog(
            this, "Cannot reach URL:\n" + msg, "Cannot Connect", JOptionPane.INFORMATION_MESSAGE);
        //      ioe.printStackTrace();
        //      ("Can't follow link to " +
        //                event.getURL().toExternalForm() );
      }

      setCursor(cdone);
    } else if (event.getEventType() == HyperlinkEvent.EventType.ENTERED) {
      try {
        JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1);
        statusField.setText(event.getDescription());
      } catch (Exception exp) {
      }

    } else if (event.getEventType() == HyperlinkEvent.EventType.EXITED) {
      try {
        JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1);
        statusField.setText("");
      } catch (Exception exp) {
      }
    }
  }
Пример #21
0
  public MainWindow() {
    JMenuItem showTextItem, showContentItem, showStatsItem;
    JMenuItem consoleWinItem, treeWinItem, traceWinItem;

    // our libgist execution thread
    opThread = new OpThread(this);
    Libgist.setBreakHandler(opThread);
    opThread.start();
    cmd = new LibgistCommand();

    menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    // create toolbar and console window with text area

    getContentPane().removeAll();
    getContentPane().setLayout(new BorderLayout());
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    // desktop pane + console frame
    desktop = new JDesktopPane();
    desktop.setOpaque(true);
    desktop.setBackground(Color.lightGray);
    consoleFrame = new ConsoleWindow(200, desktop);
    desktop.add(consoleFrame, JLayeredPane.PALETTE_LAYER);

    // debugging actions for toolbar:
    // notify opThread of what to do when it hits a breakpoint
    stepAction =
        new AbstractAction("Step") {
          public void actionPerformed(ActionEvent e) {
            opThread.step();
          }
        };
    cancelAction =
        new AbstractAction("Cancel") {
          public void actionPerformed(ActionEvent e) {
            scriptWasCancelled = true; // don't call it after next line!
            opThread.cancel();
          }
        };
    nextAction =
        new AbstractAction("Next") {
          public void actionPerformed(ActionEvent e) {
            opThread.next();
          }
        };
    contAction =
        new AbstractAction("Continue") {
          public void actionPerformed(ActionEvent e) {
            opThread.cont();
          }
        };

    // opThread is currently executing a script and we want it to stop:
    // tell libgist directly to suspend execution once opThread is done
    // with the current operation
    stopAction =
        new AbstractAction("Stop") {
          public void actionPerformed(ActionEvent e) {
            Libgist.singleStep();
          }
        };

    // toolbar
    JToolBar toolbar = new JToolBar();
    toolbar.add(stepAction).setText("Step");
    toolbar.add(nextAction).setText("Next");
    toolbar.add(contAction).setText("Continue");
    toolbar.add(stopAction).setText("Stop");
    toolbar.add(cancelAction).setText("Cancel");

    panel.add(toolbar, BorderLayout.NORTH);
    panel.add(desktop, BorderLayout.CENTER);
    getContentPane().add(panel);

    createFileMenu();
    createOpsMenu();
    createDebugMenu();
    createTreeStatsMenu();
    createAnalysisMenu();
    createWindowsMenu();

    setGuiState(INITSTATE); // nothing opened yet

    // addWindowListener(this); // So we do the right thing on window closing.
  }
Пример #22
0
  public LabFrame() throws HeadlessException {
    super(title);
    JPanel pnl, pnl1;

    data = new LabData();

    alRootEntities.addAll(data.findRootEntities());

    JMenuBar mb = new JMenuBar();

    for (MenuElement e : menus) {
      mb.add(e.getItem());
    }
    setJMenuBar(mb);

    splMain = new JSplitPane();
    getContentPane().add(splMain);

    desktop = new JDesktopPane();
    desktop.setPreferredSize(new Dimension(400, 200));

    splMain.setRightComponent(desktop);

    lmEntities = new EntityListModel();

    lstEntities = new JList(lmEntities);
    lstEntities.getSelectionModel().addListSelectionListener(lmEntities);
    lstEntities.addMouseListener(dblClickListener);

    JScrollPane scpList = new JScrollPane(lstEntities);
    pnl = new JPanel(new BorderLayout(4, 4));

    pnl.add(scpList, BorderLayout.CENTER);

    pnl1 = new JPanel(null);
    pnl1.setLayout(new BoxLayout(pnl1, BoxLayout.X_AXIS));
    pnl1.add(Box.createHorizontalGlue());
    pnl1.add(new JButton(actNewEntity));
    pnl1.add(Box.createHorizontalGlue());
    pnl1.add(new JButton(actDelEntity));
    pnl1.add(Box.createHorizontalGlue());
    pnl.add(pnl1, BorderLayout.SOUTH);

    splMain.setLeftComponent(pnl);

    il =
        new InternalFrameAdapter() {

          @Override
          public void internalFrameClosed(InternalFrameEvent e) {
            Object sel = ((EntityFrame) e.getInternalFrame()).content;
            mapEntityFrames.remove(sel);
          }

          @Override
          public void internalFrameActivated(InternalFrameEvent e) {
            setTitle(title + " - " + e.getInternalFrame().getTitle());
            Object sel = ((EntityFrame) e.getInternalFrame()).content;
            lstEntities.setSelectedValue(sel, true);
          }
        };
    pack();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setVisible(true);

    updateState();
  }
 protected void installDefaults() {
   if (desktop.getBackground() == null || desktop.getBackground() instanceof UIResource) {
     desktop.setBackground(UIManager.getColor("Desktop.background"));
   }
   LookAndFeel.installProperty(desktop, "opaque", Boolean.TRUE);
 }
 public void actionPerformed(ActionEvent evt) {
   JDesktopPane dp = (JDesktopPane) evt.getSource();
   dp.selectFrame(true);
 }
 /**
  * Installs the <code>PropertyChangeListener</code> returned from <code>
  * createPropertyChangeListener</code> on the <code>JDesktopPane</code>.
  *
  * @since 1.5
  * @see #createPropertyChangeListener
  */
 protected void installListeners() {
   pcl = createPropertyChangeListener();
   desktop.addPropertyChangeListener(pcl);
 }
Пример #26
0
  public void updateGuiState(int priorState, LibgistCommand cmd, boolean success) {
    switch (cmd.cmdType) {
      case LibgistCommand.CREATE:
      case LibgistCommand.OPEN:
        resetState();
        if (!success) return; // done
        setGuiState(IDXOPENSTATE);
        isOpen = true;
        idxName = cmd.indexName.toString();
        if (cmd.cmdType == LibgistCommand.CREATE) {
          resetConfig();
        } else {
          restoreConfig();
        }
        // setTitle("amdb: " + filename);
        setTree(idxName);
        try {
          treeView = new TreeView(desktop); // creates a display of the opened index
          desktop.add(treeView, JLayeredPane.PALETTE_LAYER);
        } catch (LibgistException e) {
          // what to do now?
          consoleFrame.echoInfo("new TreeView() failed");
        }
        break;

      case LibgistCommand.CLOSE:
        saveConfig();
        resetState();
        break;

      case LibgistCommand.OPENANL:
        resetState();
        if (!success) return; // done
        // enable menu items and open tree view
        setGuiState(ANLOPENSTATE);
        // setTitle("amdb: " + filename);
        setTree(idxName);
        try {
          treeView = new TreeView(desktop); // creates a display of the opened index
          desktop.add(treeView, JLayeredPane.PALETTE_LAYER);
        } catch (LibgistException e) {
          // what to do now?
          consoleFrame.echoInfo("new TreeView() failed");
        }

        // get ready to display dialogs
        if (analysisInfo.actualHasWkldStats) {
          wkldStatsDlg.init(treeView);
        }
        if (analysisInfo.actualHasSplitStats) {
          splitStatsDlg.init(treeView);
        }
        if (analysisInfo.actualHasPenaltyStats) {
          penaltyStatsDlg.init(treeView);
        }
        break;

      case LibgistCommand.CLOSEANL:
        treeView.dispose();
        treeView = null;
        setGuiState(INITSTATE);
        setTree("");
        break;

        // if these didn't work, we don't care
      case LibgistCommand.INSERT:
      case LibgistCommand.REMOVE:
      case LibgistCommand.FETCH:
      case LibgistCommand.FLUSH:
      case LibgistCommand.CREATEANL:
      case LibgistCommand.SCRIPT:
        setGuiState(priorState);
        break;
    }
  }
Пример #27
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }