コード例 #1
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  /** Write file with position and size of the login box */
  public static void writePersistence() {

    Messages.postDebug("LoginBox", "LoginBox.writePersistence");
    // If the panel has not been created, don't try to write a file
    if (position == null) return;

    String filepath = FileUtil.savePath("USER/PERSISTENCE/LoginPanel");

    FileWriter fw;
    PrintWriter os;
    try {
      File file = new File(filepath);
      fw = new FileWriter(file);
      os = new PrintWriter(fw);
      os.println("Login Panel");

      os.println(height);
      os.println(width);
      double xd = position.getX();
      int xi = (int) xd;
      os.println(xi);
      double yd = position.getY();
      int yi = (int) yd;
      os.println(yi);

      os.close();
    } catch (Exception er) {
      Messages.postError("Problem creating  " + filepath);
      Messages.writeStackTrace(er);
    }
  }
コード例 #2
0
ファイル: VTabbedToolPanel.java プロジェクト: timburrow/ovj3
    public void mouseClicked(MouseEvent evt) {
      int btn = evt.getButton();
      if (btn == MouseEvent.BUTTON3) {
        JPopupMenu helpMenu = new JPopupMenu();
        String helpLabel = Util.getLabel("CSHMenu");
        JMenuItem helpMenuItem = new JMenuItem(helpLabel);
        helpMenuItem.setActionCommand("help");
        helpMenu.add(helpMenuItem);

        ActionListener alMenuItem =
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                String topic = "";
                try {
                  JComponent c1 = (JComponent) tabbedPane.getSelectedComponent();
                  // This component should contain the following embedded items.
                  // We want m_helplink out of the top VGroup.
                  //   PushpinObj
                  //     XMLToolPanel
                  //       JScrollpane
                  //         JViewport
                  //           JPanel
                  //             VGroup
                  // Work down to the VGroup, checking for class type along
                  // the way.
                  if (c1 instanceof PushpinObj) {
                    Component c2[] = c1.getComponents();
                    int cnt;
                    for (cnt = 0; cnt < c2.length; cnt++) {
                      // The PushpinObj can have multiple items, find the one we want
                      if (c2[cnt] instanceof XMLToolPanel) break;
                    }
                    if (cnt < c2.length && c2[cnt] instanceof XMLToolPanel) {
                      Component c3[] = ((JComponent) c2[cnt]).getComponents();
                      if (c3[0] instanceof JScrollPane) {
                        Component c4[] = ((JComponent) c3[0]).getComponents();
                        if (c4[0] instanceof JViewport) {
                          Component c5[] = ((JComponent) c4[0]).getComponents();
                          if (c5[0] instanceof JPanel) {
                            Component c6[] = ((JComponent) c5[0]).getComponents();
                            if (c6[0] instanceof VGroup) {
                              // Get the helplink info from the VGroup
                              topic = ((VGroup) c6[0]).getAttribute(VObjDef.HELPLINK);
                            }
                          }
                        }
                      }
                    }
                  }
                  // If no helplink found, try the Tab's name
                  if (topic == null || topic.length() == 0) {
                    topic = c1.getName();
                    if (topic.equals("Locator")) topic = getLocatorName();
                    topic = topic.replace(" ", "_");
                  }
                } catch (Exception ex) {
                }
                // Get the ID and display the help content
                CSH_Util.displayCSHelp(topic);
              }
            };
        helpMenuItem.addActionListener(alMenuItem);

        Point pt = evt.getPoint();
        helpMenu.show(VTabbedToolPanel.this, (int) pt.getX(), (int) pt.getY());
      }
    }