/**
   * @param editor
   * @param idDialog
   * @param dialog
   * @param title
   */
  public static void setDialogVisible(
      @Nullable Editor editor, String idDialog, JDialog dialog, String title) {
    Point location = null;

    if (editor != null) {
      Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
      SwingUtilities.convertPointToScreen(caretLocation, editor.getComponent());

      String[] position = UtilsPreferences.getDialogPosition(idDialog).split("x");
      if (!(position[0].equals("0") && position[1].equals("0"))) {
        location = new Point(Integer.parseInt(position[0]), Integer.parseInt(position[1]));
      }
    }

    if (location == null) {
      // Center to screen
      dialog.setLocationRelativeTo(null);
    } else {
      dialog.setLocation(location.x, location.y);
    }

    dialog.setTitle(title);
    dialog.pack();
    dialog.setVisible(true);
  }
Exemplo n.º 2
0
  private void warning(String msg) {
    final JDialog warn;
    JButton ok;
    JLabel message;

    warn = new JDialog();
    warn.setTitle(msg);

    message = new JLabel("CryoBay: " + msg);
    ok = new JButton("Ok");

    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            warn.dispose();
          }
        });

    warn.getContentPane().setLayout(new BorderLayout());
    warn.getContentPane().add(message, "North");
    warn.getContentPane().add(ok, "South");

    warn.setSize(200, 80);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    warn.setLocation(screenSize.width / 2 - 100, screenSize.height / 2 - 40);
    warn.setResizable(false);
    warn.show();
  }
 /** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
Exemplo n.º 4
0
 /**
  * Set the title of the window to the given title
  *
  * @param title The window title
  */
 public void setWindowTitle(String title) {
   if (!windowOk()) {
     return;
   }
   if (dialog != null) {
     dialog.setTitle(title);
   }
   if (frame != null) {
     frame.setTitle(title);
   }
 }
Exemplo n.º 5
0
 public void displayDate() {
   for (int x = 7; x < button.length; x++) button[x].setText("");
   java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMMM yyyy");
   java.util.Calendar cal = java.util.Calendar.getInstance();
   cal.set(year, month, 1);
   int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
   int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
   for (int x = 6 + dayOfWeek, day = 1; day <= daysInMonth; x++, day++)
     button[x].setText("" + day);
   l.setText(sdf.format(cal.getTime()));
   d.setTitle("Date Picker");
 }
Exemplo n.º 6
0
 /** Create and show the gui */
 public void showDialog() {
   if (dialog == null) {
     JFrame parentFrame = persistenceManager.getIdv().getIdvUIManager().getFrame();
     dialog = new JDialog(parentFrame, "Loading Bundle");
     if (dialogTitle != null) {
       dialog.setTitle("Loading Bundle: " + dialogTitle);
     }
     dialog.getContentPane().add(contents);
   }
   dialog.pack();
   Point center = GuiUtils.getLocation(null);
   if (persistenceManager.getIdv().okToShowWindows()) {
     dialog.setLocation(20, 20);
     dialog.setVisible(true);
   }
 }
Exemplo n.º 7
0
  public static PlatePanel createPanelDialog(
      Plate plate, HeatMapModel heatmapModel, Window ownerDialog) {
    JDialog jDialog = new JDialog(ownerDialog);

    jDialog.setTitle("PlateViewer: " + plate.getBarcode());
    Random posJitter = new Random();
    jDialog.setBounds(200 + posJitter.nextInt(100), 200 + posJitter.nextInt(100), 700, 500);

    jDialog.setLayout(new BorderLayout());

    PlatePanel platePanel = new PlatePanel(plate, heatmapModel);
    jDialog.add(platePanel, BorderLayout.CENTER);

    jDialog.setVisible(true);

    return platePanel;
  }
Exemplo n.º 8
0
  @Override
  public void actionPerformed(ActionEvent e) {
    JDialog mydialog = new JDialog();
    mydialog.setSize(new Dimension(400, 500));
    mydialog.setTitle("JCR Workbench - Help");
    mydialog.setModalityType(Dialog.ModalityType.MODELESS);
    mydialog.setVisible(true);

    String url = HelpAction.class.getResource("quickStartHelp.html").toExternalForm();
    log.trace("loading help from: " + url);
    try {
      JEditorPane editorPane = new JEditorPane(url);
      JScrollPane scrolledContent = new JScrollPane(editorPane);
      mydialog.setContentPane(scrolledContent);
    } catch (IOException e1) {
      e1.printStackTrace();
    }
  }
Exemplo n.º 9
0
  /**
   * Uses a JEditorPane to open the given URL in a dialog
   *
   * @param url the url to load
   * @param title the title of the dialog
   * @param frame the parent frame
   * @param visible true if you want the dialog to be visible, false if you want it to be invisible
   *     to user
   * @param iconPath the path to the image icon for the dialog.
   */
  public static void openURLinDialog(
      String url, String title, String iconPath, JFrame frame, boolean visible) {
    // create panel with page in it
    final int WIDTH = 400;
    final int HEIGHT = 300;
    JPanel webView = createEditorPane(url, WIDTH, HEIGHT);

    // put it in a dialog
    JDialog dialog = new JDialog(frame);
    dialog.setTitle(title);
    dialog.setIconImage(GUI.createImageIcon(iconPath).getImage());
    dialog.setContentPane(webView);
    dialog.pack();
    dialog.setResizable(false);
    dialog.setModal(true);
    Utils.centerComponent(dialog, frame);

    // open it
    dialog.setVisible(visible);
  }
Exemplo n.º 10
0
  protected void populateDialog(JDialog dlg) {
    dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dlg.setResizable(false);
    dlg.setSize(new Dimension(350, 135));
    dlg.setTitle("New TurboVNC Connection");

    dlg.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (VncViewer.nViewers == 1) {
              if (cc.viewer instanceof VncViewer) {
                ((VncViewer) cc.viewer).exit(1);
              }
            } else {
              ret = false;
              endDialog();
            }
          }
        });

    dlg.getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 1;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.ipadx = 0;
    gbc.ipady = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;

    dlg.getContentPane().add(topPanel, gbc);
    dlg.getContentPane().add(buttonPanel);
    dlg.pack();
  }
Exemplo n.º 11
0
  public EchoAWT() throws UnknownHostException {

    super("채팅 프로그램");

    // 각종 정의
    h = new JPanel(new GridLayout(2, 3));
    m = new JPanel(new BorderLayout());
    f = new JPanel(new BorderLayout());
    s = new JPanel(new BorderLayout());
    login = new JPanel(new BorderLayout());

    // name = new JLabel(" 사용자 이름 ");
    name = new JLabel(" 메세지 입력 ");

    jta = new JTextArea();
    // clientList = new JTextArea(0, 10);
    clientList = new JList();

    jsp = new JScrollPane(jta);
    list = new JScrollPane(clientList);

    jtf = new JTextField("입력하세요.");
    hi = new JTextField("HOST IP 입력");
    pi = new JTextField("PORT 입력");
    localport = new JTextField("원하는 PORT 입력");
    lid = new JTextField("ID를 입력하세요.");
    lpw = new JTextField("PW를 입력하세요.");

    serveropen = new JButton("서버 오픈");
    textin = new JButton("입력");
    clientin = new JButton("서버 접속");
    conf = new JButton("로그인");
    join = new JButton("회원가입");

    addr = InetAddress.getLocalHost();

    // 사용자 해상도 및 창 크기 설정 및 가져오기.
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();

    setSize(500, 500);
    Dimension d = getSize();

    // 각종 버튼 및 텍스트 필드 리스너
    jtf.addActionListener(this);
    hi.addActionListener(this);
    pi.addActionListener(this);
    localport.addActionListener(this);
    lid.addActionListener(this);
    lpw.addActionListener(this);
    conf.addActionListener(this);
    join.addActionListener(this);

    serveropen.addActionListener(this);
    clientin.addActionListener(this);
    textin.addActionListener(this);

    jtf.addFocusListener(this);
    hi.addFocusListener(this);
    pi.addFocusListener(this);
    localport.addFocusListener(this);
    lid.addFocusListener(this);
    lpw.addFocusListener(this);

    // 서버 접속
    h.add(hi);
    h.add(pi);
    h.add(clientin);

    // 서버 생성
    h.add(new JLabel("IP : " + addr.getHostAddress(), (int) CENTER_ALIGNMENT));
    h.add(localport);
    h.add(serveropen);

    // 채팅글창 글 작성 막기
    jta.setEditable(false);

    // 접속자 리스트 width 제한
    clientList.setFixedCellWidth(d.width / 3);

    // 입력 창
    f.add(name, "West");
    f.add(jtf, "Center");
    f.add(textin, "East");

    // 접속자 확인창
    s.add(new JLabel("접속자", (int) CENTER_ALIGNMENT), "North");
    s.add(list, "Center");
    // clientList.setEditable(false);

    // 메인 창
    m.add(jsp, "Center");
    m.add(s, "East");

    // 프레임 설정
    add(h, "North");
    add(m, "Center");
    add(f, "South");

    // 로그인 다이얼로그
    jd = new JDialog();
    jd.setTitle("채팅 로그인");
    jd.add(login);
    jd.setSize(200, 200);
    Dimension dd = jd.getSize();
    jd.setLocation(screenSize.width / 2 - (dd.width / 2), screenSize.height / 2 - (dd.height / 2));
    jd.setVisible(true);

    // 로그인창
    JPanel lm = new JPanel(new GridLayout(4, 1));
    lm.add(lid);
    lm.add(new Label());
    lm.add(lpw);
    lm.add(new Label());

    JPanel bt = new JPanel();
    bt.add(conf);
    bt.add(join);

    login.add(new Label(), "North");
    login.add(new Label(), "West");
    login.add(new Label(), "East");
    login.add(lm, "Center");
    login.add(bt, "South");

    // 창의 위치, 보임, EXIT 단추 활성화.
    setLocation(screenSize.width / 2 - (d.width / 2), screenSize.height / 2 - (d.height / 2));

    setVisible(false);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
Exemplo n.º 12
0
  public void show(List<Rule> rules) {
    if (original != null) config.restoreState(original);
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiConfigWindowTitle"));

    Collections.sort(rules, new CategoryComparator());

    // close dialog when user presses Escape key:
    final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    final ActionListener actionListener =
        new ActionListener() {
          @Override
          public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) {
            dialog.setVisible(false);
          }
        };
    final JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    // JPanel
    final JPanel checkBoxPanel = new JPanel();
    checkBoxPanel.setLayout(new GridBagLayout());
    GridBagConstraints cons = new GridBagConstraints();
    cons.anchor = GridBagConstraints.NORTHWEST;
    cons.gridx = 0;
    cons.weightx = 1.0;
    cons.weighty = 1.0;
    cons.fill = GridBagConstraints.BOTH;
    DefaultMutableTreeNode rootNode = createTree(rules);
    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    treeModel.addTreeModelListener(
        new TreeModelListener() {

          @Override
          public void treeNodesChanged(TreeModelEvent e) {
            DefaultMutableTreeNode node =
                (DefaultMutableTreeNode) e.getTreePath().getLastPathComponent();
            int index = e.getChildIndices()[0];
            node = (DefaultMutableTreeNode) (node.getChildAt(index));
            if (node instanceof RuleNode) {
              RuleNode o = (RuleNode) node;
              if (o.getRule().isDefaultOff()) {
                if (o.isEnabled()) {
                  config.getEnabledRuleIds().add(o.getRule().getId());
                } else {
                  config.getEnabledRuleIds().remove(o.getRule().getId());
                }
              } else {
                if (o.isEnabled()) {
                  config.getDisabledRuleIds().remove(o.getRule().getId());
                } else {
                  config.getDisabledRuleIds().add(o.getRule().getId());
                }
              }
            }
            if (node instanceof CategoryNode) {
              CategoryNode o = (CategoryNode) node;
              if (o.isEnabled()) {
                config.getDisabledCategoryNames().remove(o.getCategory().getName());
              } else {
                config.getDisabledCategoryNames().add(o.getCategory().getName());
              }
            }
          }

          @Override
          public void treeNodesInserted(TreeModelEvent e) {}

          @Override
          public void treeNodesRemoved(TreeModelEvent e) {}

          @Override
          public void treeStructureChanged(TreeModelEvent e) {}
        });
    configTree = new JTree(treeModel);
    configTree.setRootVisible(false);
    configTree.setEditable(false);
    configTree.setCellRenderer(new CheckBoxTreeCellRenderer());
    TreeListener.install(configTree);
    checkBoxPanel.add(configTree, cons);

    MouseAdapter ma =
        new MouseAdapter() {
          private void handlePopupEvent(MouseEvent e) {
            final JTree tree = (JTree) e.getSource();

            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
            if (path == null) {
              return;
            }

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

            TreePath[] paths = tree.getSelectionPaths();

            boolean isSelected = false;
            if (paths != null) {
              for (TreePath selectionPath : paths) {
                if (selectionPath.equals(path)) {
                  isSelected = true;
                }
              }
            }
            if (!isSelected) {
              tree.setSelectionPath(path);
            }
            if (node.isLeaf()) {
              JPopupMenu popup = new JPopupMenu();
              final JMenuItem aboutRuleMenuItem =
                  new JMenuItem(messages.getString("guiAboutRuleMenu"));
              aboutRuleMenuItem.addActionListener(
                  new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent actionEvent) {
                      RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent();
                      Rule rule = node.getRule();
                      Language lang = config.getLanguage();
                      if (lang == null) {
                        lang = Language.getLanguageForLocale(Locale.getDefault());
                      }
                      Tools.showRuleInfoDialog(
                          tree,
                          messages.getString("guiAboutRuleTitle"),
                          rule.getDescription(),
                          rule,
                          messages,
                          lang.getShortNameWithCountryAndVariant());
                    }
                  });
              popup.add(aboutRuleMenuItem);
              popup.show(tree, e.getX(), e.getY());
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
              handlePopupEvent(e);
            }
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
              handlePopupEvent(e);
            }
          }
        };
    configTree.addMouseListener(ma);
    final JPanel treeButtonPanel = new JPanel();
    cons = new GridBagConstraints();
    cons.gridx = 0;
    cons.gridy = 0;
    final JButton expandAllButton = new JButton(messages.getString("guiExpandAll"));
    treeButtonPanel.add(expandAllButton, cons);
    expandAllButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            TreeNode root = (TreeNode) configTree.getModel().getRoot();
            TreePath parent = new TreePath(root);
            for (Enumeration categ = root.children(); categ.hasMoreElements(); ) {
              TreeNode n = (TreeNode) categ.nextElement();
              TreePath child = parent.pathByAddingChild(n);
              configTree.expandPath(child);
            }
          }
        });

    cons.gridx = 1;
    cons.gridy = 0;
    final JButton collapseAllbutton = new JButton(messages.getString("guiCollapseAll"));
    treeButtonPanel.add(collapseAllbutton, cons);
    collapseAllbutton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            TreeNode root = (TreeNode) configTree.getModel().getRoot();
            TreePath parent = new TreePath(root);
            for (Enumeration categ = root.children(); categ.hasMoreElements(); ) {
              TreeNode n = (TreeNode) categ.nextElement();
              TreePath child = parent.pathByAddingChild(n);
              configTree.collapsePath(child);
            }
          }
        });

    final JPanel motherTonguePanel = new JPanel();
    motherTonguePanel.add(new JLabel(messages.getString("guiMotherTongue")), cons);
    motherTongueBox = new JComboBox(getPossibleMotherTongues());
    if (config.getMotherTongue() != null) {
      motherTongueBox.setSelectedItem(config.getMotherTongue().getTranslatedName(messages));
    }
    motherTongueBox.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              Language motherTongue;
              if (motherTongueBox.getSelectedItem() instanceof String) {
                motherTongue =
                    getLanguageForLocalizedName(motherTongueBox.getSelectedItem().toString());
              } else {
                motherTongue = (Language) motherTongueBox.getSelectedItem();
              }
              config.setMotherTongue(motherTongue);
            }
          }
        });
    motherTonguePanel.add(motherTongueBox, cons);

    final JPanel portPanel = new JPanel();
    portPanel.setLayout(new GridBagLayout());
    // TODO: why is this now left-aligned?!?!
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.anchor = GridBagConstraints.WEST;
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.0f;
    if (!insideOOo) {
      serverCheckbox = new JCheckBox(Tools.getLabel(messages.getString("guiRunOnPort")));
      serverCheckbox.setMnemonic(Tools.getMnemonic(messages.getString("guiRunOnPort")));
      serverCheckbox.setSelected(config.getRunServer());
      portPanel.add(serverCheckbox, cons);
      serverCheckbox.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
              serverPortField.setEnabled(serverCheckbox.isSelected());
              serverSettingsCheckbox.setEnabled(serverCheckbox.isSelected());
            }
          });
      serverCheckbox.addItemListener(
          new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
              config.setRunServer(serverCheckbox.isSelected());
            }
          });

      serverPortField = new JTextField(Integer.toString(config.getServerPort()));
      serverPortField.setEnabled(serverCheckbox.isSelected());
      serverSettingsCheckbox = new JCheckBox(Tools.getLabel(messages.getString("useGUIConfig")));
      // TODO: without this the box is just a few pixels small, but why??:
      serverPortField.setMinimumSize(new Dimension(100, 25));
      cons.gridx = 1;
      portPanel.add(serverPortField, cons);
      serverPortField
          .getDocument()
          .addDocumentListener(
              new DocumentListener() {

                @Override
                public void insertUpdate(DocumentEvent e) {
                  changedUpdate(e);
                }

                @Override
                public void removeUpdate(DocumentEvent e) {
                  changedUpdate(e);
                }

                @Override
                public void changedUpdate(DocumentEvent e) {
                  try {
                    int serverPort = Integer.parseInt(serverPortField.getText());
                    if (serverPort > -1 && serverPort < 65536) {
                      serverPortField.setForeground(null);
                      config.setServerPort(serverPort);
                    } else {
                      serverPortField.setForeground(Color.RED);
                    }
                  } catch (NumberFormatException ex) {
                    serverPortField.setForeground(Color.RED);
                  }
                }
              });

      cons.gridx = 0;
      cons.gridy = 10;
      serverSettingsCheckbox.setMnemonic(Tools.getMnemonic(messages.getString("useGUIConfig")));
      serverSettingsCheckbox.setSelected(config.getUseGUIConfig());
      serverSettingsCheckbox.setEnabled(config.getRunServer());
      serverSettingsCheckbox.addItemListener(
          new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
              config.setUseGUIConfig(serverSettingsCheckbox.isSelected());
            }
          });
      portPanel.add(serverSettingsCheckbox, cons);
    }

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
    okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
    okButton.addActionListener(this);
    cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
    cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
    cancelButton.addActionListener(this);
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    buttonPanel.add(okButton, cons);
    buttonPanel.add(cancelButton, cons);

    final Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    contentPane.add(new JScrollPane(checkBoxPanel), cons);

    cons.gridx = 0;
    cons.gridy = 1;
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    contentPane.add(treeButtonPanel, cons);

    cons.gridx = 0;
    cons.gridy = 2;
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.WEST;
    contentPane.add(motherTonguePanel, cons);

    cons.gridx = 0;
    cons.gridy = 3;
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.WEST;
    contentPane.add(portPanel, cons);

    cons.gridx = 0;
    cons.gridy = 4;
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.EAST;
    contentPane.add(buttonPanel, cons);

    dialog.pack();
    dialog.setSize(500, 500);
    // center on screen:
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    final Dimension frameSize = dialog.getSize();
    dialog.setLocation(
        screenSize.width / 2 - frameSize.width / 2, screenSize.height / 2 - frameSize.height / 2);
    dialog.setLocationByPlatform(true);
    dialog.setVisible(true);
  }
  @Override
  public boolean onStart() {
    window = new JFrame("Interface Explorer");
    treeModel = new InterfaceTreeModel();
    treeModel.update("");
    tree = new JTree(treeModel);
    tree.setRootVisible(false);
    tree.setEditable(false);
    renderer = new HighlightTreeCellRenderer(tree.getCellRenderer());
    tree.setCellRenderer(renderer);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          private void addInfo(final String key, final String value, final boolean highlight) {
            final JPanel row = new JPanel();
            row.setAlignmentX(Component.LEFT_ALIGNMENT);
            row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
            for (final String data : new String[] {key, value}) {
              final JLabel label = new JLabel(data);
              label.setAlignmentY(Component.TOP_ALIGNMENT);
              if (highlight) {
                label.setForeground(Color.magenta);
              }
              row.add(label);
            }
            infoArea.add(row);
          }

          public void valueChanged(final TreeSelectionEvent e) {
            final Object node = tree.getLastSelectedPathComponent();
            if (node == null || node instanceof RSInterfaceWrap) {
              return;
            }
            infoArea.removeAll();
            RSComponent iface = null;
            if (node instanceof RSComponentWrap) {
              iface = ((RSComponentWrap) node).wrapped;
            }
            if (iface == null) {
              return;
            }
            List<Integer> changes = new ArrayList<Integer>();
            for (int i = 0; i < HighLightWraps.size(); i++) {
              if (iface.getParent() == null) {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              } else {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getParent().getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getParent().getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              }
            }
            addInfo("Type: ", "" + iface.getType(), changes.contains(1));
            addInfo("SpecialType: ", "" + iface.getSpecialType(), changes.contains(2));
            addInfo("Bounds Index: ", "" + iface.getBoundsArrayIndex(), changes.contains(3));
            if (iface.getArea() != null) {
              Rectangle size = iface.getArea();
              addInfo("Size: ", size.width + "," + size.height, changes.contains(15));
            }
            addInfo("Model ID: ", "" + iface.getModelID(), changes.contains(4));
            addInfo("Texture ID: ", "" + iface.getBackgroundColor(), changes.contains(5));
            addInfo("Parent ID: ", "" + iface.getParentID(), changes.contains(6));
            addInfo("Text: ", "" + iface.getText(), changes.contains(7));
            addInfo("Tooltip: ", "" + iface.getTooltip(), changes.contains(8));
            addInfo("SelActionName: ", "" + iface.getSelectedActionName(), changes.contains(9));
            if (iface.getActions() != null) {
              String actions = "";
              for (final String action : iface.getActions()) {
                if (!actions.equals("")) {
                  actions += "\n";
                }
                actions += action;
              }
              addInfo("Actions: ", actions, changes.contains(10));
            }
            addInfo("Component ID: ", "" + iface.getComponentID(), changes.contains(11));
            addInfo(
                "Component Stack Size: ", "" + iface.getComponentStackSize(), changes.contains(12));
            addInfo(
                "Relative Location: ",
                "(" + iface.getRelativeX() + "," + iface.getRelativeY() + ")",
                changes.contains(13));
            addInfo(
                "Absolute Location: ",
                "(" + iface.getAbsoluteX() + "," + iface.getAbsoluteY() + ")",
                changes.contains(14));
            addInfo(
                "Rotation: ",
                "x: "
                    + iface.getXRotation()
                    + "  y: "
                    + iface.getYRotation()
                    + "  z: "
                    + iface.getZRotation(),
                changes.contains(16));
            setHighlightArea(iface.getArea());
            infoArea.validate();
            infoArea.repaint();
          }
        });
    final JDialog Help = new JDialog();
    JScrollPane jScrollPane1;
    JTextArea jTextArea1;
    jScrollPane1 = new JScrollPane();
    jTextArea1 = new JTextArea();
    Help.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Help.setTitle("Help");
    Help.setResizable(false);
    jTextArea1.setColumns(20);
    jTextArea1.setEditable(false);
    jTextArea1.setFont(new java.awt.Font("MS UI Gothic", 0, 12));
    jTextArea1.setLineWrap(true);
    jTextArea1.setRows(5);
    jTextArea1.setText(
        "Once toggled the listener feature of the interface explorer will detect any changes made to Runescapes interfaces in realtime. If a change is found that interface and data will then be highlighted within the explorers tree model. To use the listener feature you would :\n\n1) Toggle the listener button as active\n2) Wait or commit changes in Runescape\n3) Repaint tree using repaint button or reclick interface folders in GUI\n\n\nTips : While listening for changes the tree model in the GUI will not update itself, changing colors. To refresh the GUI either use the repaint button or close and open Interface folder already within the tree model.");
    jTextArea1.setWrapStyleWord(true);
    jScrollPane1.setViewportView(jTextArea1);
    final GroupLayout layout = new GroupLayout(Help.getContentPane());
    Help.getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jScrollPane1, GroupLayout.PREFERRED_SIZE, 220, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    Help.pack();
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.WEST);
    infoArea = new JPanel();
    infoArea.setLayout(new BoxLayout(infoArea, BoxLayout.Y_AXIS));
    scrollPane = new JScrollPane(infoArea);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.CENTER);
    final ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            treeModel.update(searchBox.getText());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener toggleListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            if (listenerButton.isSelected()) {
              log("Cleared");
              HighLightWraps.clear();
            }
            check();
          }
        };
    final ActionListener repaintListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            log("Refreshed Tree");
            treeModel.fireTreeStructureChanged(treeModel.getRoot());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener helpListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            Help.setVisible(true);
          }
        };
    final JPanel toolArea = new JPanel();
    toolArea.setLayout(new FlowLayout(FlowLayout.LEFT));
    toolArea.add(new JLabel("Filter:"));
    searchBox = new JTextField(20);
    searchBox.addActionListener(actionListener);
    toolArea.add(searchBox);
    final JButton updateButton = new JButton("Update");
    final JButton repaintButton = new JButton("Repaint");
    final JButton helpButton = new JButton("Help");
    helpButton.addActionListener(helpListener);
    listenerButton.addActionListener(toggleListener);
    updateButton.addActionListener(actionListener);
    repaintButton.addActionListener(repaintListener);
    toolArea.add(updateButton);
    toolArea.add(listenerButton);
    toolArea.add(repaintButton);
    toolArea.add(helpButton);
    window.add(toolArea, BorderLayout.NORTH);
    window.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    window.pack();
    window.setVisible(true);
    return true;
  }
  public void createDialogBox(String Roll, String ExamYear) {
    RPS = new JDialog();

    this.NumberOfCourses = DataTransfer.Courses.size();
    this.Roll = Roll;
    this.ExamYear = ExamYear;
    this.Session = setSession();
    final int Final = NumberOfCourses;
    final int Height = (Final * 40 + 270 > 600) ? Final * 40 + 270 : 600;

    Panel =
        new JPanel() {
          protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(
                new ImageIcon(getClass().getResource("/Icons/8.jpg")).getImage(),
                0,
                0,
                950,
                Height,
                null);
            ButtonBorder.paintBorder(this, g, 284, 84 + Final * 40 + 60 + 60, 252, 32);
          }
        };

    Panel.setPreferredSize(
        new Dimension(
            600,
            NumberOfCourses * 40
                + 150
                + 60
                + 60)); // 50+(100*5+3*5)+50, 120+NumberOfCourses*30+(NumberOfCourses-1)*10+50+60
    Panel.setLayout(null);

    RollLabel = new JLabel("Roll  :  " + this.Roll, SwingConstants.CENTER);
    RollLabel.setForeground(Color.WHITE);
    RollLabel.setFont(new Font("SERRIF", Font.BOLD, 15));
    RollLabel.setBounds(112, 20, 615, 20);
    Panel.add(RollLabel);

    SessionLabel = new JLabel("Session  :  " + this.Session, SwingConstants.CENTER);
    SessionLabel.setForeground(Color.WHITE);
    SessionLabel.setFont(new Font("SERRIF", Font.BOLD, 15));
    SessionLabel.setBounds(112, 40, 615, 20);
    Panel.add(SessionLabel);

    ColumnName = new JLabel("", SwingConstants.LEFT);
    ColumnName.setText(
        "     COURSE NO.        TOTAL MARKS      GRADE POINT      LETTER GRADE        COURSE CREDIT                 EXAM-TYPE");
    ColumnName.setForeground(Color.WHITE);
    ColumnName.setFont(new Font("SERRIF", Font.BOLD, 10));
    ColumnName.setBounds(112, 80, 635, 30);
    Panel.add(ColumnName);

    TakenLabel1 = new JLabel("Credit Hour Taken  :  ", SwingConstants.RIGHT);
    TakenLabel1.setForeground(Color.WHITE);
    TakenLabel1.setFont(new Font("SERRIF", Font.ITALIC, 12));
    TakenLabel1.setBounds(112, 85 + NumberOfCourses * 40 + 60, 130, 20);
    Panel.add(TakenLabel1);

    TakenLabel2 = new JLabel("", SwingConstants.LEFT);
    TakenLabel2.setForeground(Color.WHITE);
    TakenLabel2.setFont(new Font("SERRIF", Font.ITALIC, 12));
    TakenLabel2.setBounds(242, 85 + NumberOfCourses * 40 + 60, 50, 20);
    Panel.add(TakenLabel2);

    CompletedLabel1 = new JLabel("Credit Hour Completed  :  ", SwingConstants.RIGHT);
    CompletedLabel1.setForeground(Color.WHITE);
    CompletedLabel1.setFont(
        new Font("SERRIF", Font.ITALIC, 12)); // 50,85+NumberOfCourses*40+60+20,150,20
    CompletedLabel1.setBounds(342, 85 + NumberOfCourses * 40 + 60, 150, 20);
    Panel.add(CompletedLabel1);

    CompletedLabel2 = new JLabel("opps", SwingConstants.LEFT);
    CompletedLabel2.setForeground(Color.WHITE);
    CompletedLabel2.setFont(new Font("SERRIF", Font.ITALIC, 12));
    CompletedLabel2.setBounds(492, 85 + NumberOfCourses * 40 + 60, 50, 20);
    Panel.add(CompletedLabel2);

    GPALabel1 = new JLabel("GPA  :  ", SwingConstants.RIGHT);
    GPALabel1.setForeground(Color.WHITE);
    GPALabel1.setFont(new Font("SERRIF", Font.ITALIC, 12));
    GPALabel1.setBounds(552, 85 + NumberOfCourses * 40 + 60, 80, 20);
    Panel.add(GPALabel1);

    GPALabel2 = new JLabel("36.25", SwingConstants.LEFT);
    GPALabel2.setForeground(Color.WHITE);
    GPALabel2.setFont(new Font("SERRIF", Font.ITALIC, 12));
    GPALabel2.setBounds(632, 85 + NumberOfCourses * 40 + 60, 50, 20);
    Panel.add(GPALabel2);

    DocButton = new JButton("Create Document");
    DocButton.setFont(new Font("SERRIF", Font.BOLD, 15));
    DocButton.setBounds(
        285,
        85 + NumberOfCourses * 40 + 60 + 60,
        250,
        30); // 50+NumberOfCourses*30+(NumberOfCourses-1)*10+35
    DocButton.addActionListener(this);
    Panel.add(DocButton);

    CheckAll = new JCheckBox("Uncheck all");
    CheckAll.setForeground(Color.WHITE);
    CheckAll.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 12));
    CheckAll.setOpaque(false);
    CheckAll.setSelected(true);
    CheckAll.addActionListener(this);

    setComponentsOnTheGrid();

    Scroll =
        new JScrollPane(
            Panel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    RPS.add(Scroll);

    RPS.setModal(true);
    RPS.setTitle(" Result : Particular Student ");
    RPS.setResizable(false);
    RPS.setSize(840, 565);
    RPS.setLocation(
        250, 100 + (565 - RPS.getHeight()) / 2); // setiing RPS dialogbox in the middle of MenuFrame
    RPS.setVisible(true);
  }
Exemplo n.º 15
0
  public static boolean showLicensing() {
    if (Config.getLicenseResource() == null) return true;
    ClassLoader cl = Main.class.getClassLoader();
    URL url = cl.getResource(Config.getLicenseResource());
    if (url == null) return true;

    String license = null;
    try {
      URLConnection con = url.openConnection();
      int size = con.getContentLength();
      byte[] content = new byte[size];
      InputStream in = new BufferedInputStream(con.getInputStream());
      in.read(content);
      license = new String(content);
    } catch (IOException ioe) {
      Config.trace("Got exception when reading " + Config.getLicenseResource() + ": " + ioe);
      return false;
    }

    // Build dialog
    JTextArea ta = new JTextArea(license);
    ta.setEditable(false);
    final JDialog jd = new JDialog(_installerFrame, true);
    Container comp = jd.getContentPane();
    jd.setTitle(Config.getLicenseDialogTitle());
    comp.setLayout(new BorderLayout(10, 10));
    comp.add(new JScrollPane(ta), "Center");
    Box box = new Box(BoxLayout.X_AXIS);
    box.add(box.createHorizontalStrut(10));
    box.add(new JLabel(Config.getLicenseDialogQuestionString()));
    box.add(box.createHorizontalGlue());
    JButton acceptButton = new JButton(Config.getLicenseDialogAcceptString());
    JButton exitButton = new JButton(Config.getLicenseDialogExitString());
    box.add(acceptButton);
    box.add(box.createHorizontalStrut(10));
    box.add(exitButton);
    box.add(box.createHorizontalStrut(10));
    jd.getRootPane().setDefaultButton(acceptButton);
    Box box2 = new Box(BoxLayout.Y_AXIS);
    box2.add(box);
    box2.add(box2.createVerticalStrut(5));
    comp.add(box2, "South");
    jd.pack();

    final boolean accept[] = new boolean[1];
    acceptButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            accept[0] = true;
            jd.hide();
            jd.dispose();
          }
        });

    exitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            accept[0] = false;
            jd.hide();
            jd.dispose();
          }
        });

    // Apply any defaults the user may have, constraining to the size
    // of the screen, and default (packed) size.
    Rectangle size = new Rectangle(0, 0, 500, 300);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    size.width = Math.min(screenSize.width, size.width);
    size.height = Math.min(screenSize.height, size.height);
    // Center the window
    jd.setBounds(
        (screenSize.width - size.width) / 2,
        (screenSize.height - size.height) / 2,
        size.width,
        size.height);

    // Show dialog
    jd.show();

    return accept[0];
  }
 private static void setWindowTitle(Window window, String title) {
   if (window instanceof JDialog) {
     ((JDialog) window).setTitle(title);
   } else if (window instanceof JFrame) ((JFrame) window).setTitle(title);
 }
Exemplo n.º 17
0
  private void plotDataOnGraphics(
      Graphics g,
      final MainWindow mainWindow,
      final int w,
      final int h,
      final HiC hic,
      final JPanel hiCPanel) {
    // Print the panel on created graphics.
    if (w == mainWindow.getWidth() && h == mainWindow.getHeight()) {
      hiCPanel.printAll(g);
    } else {
      JDialog waitDialog = new JDialog();
      JPanel panel1 = new JPanel();
      panel1.add(new JLabel("  Creating and saving " + w + " by " + h + " image  "));
      // panel1.setPreferredSize(new Dimension(250,50));
      waitDialog.add(panel1);
      waitDialog.setTitle("Please wait...");
      waitDialog.pack();
      waitDialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

      waitDialog.setLocation(100, 100);
      waitDialog.setVisible(true);
      mainWindow.setVisible(false);

      Dimension minSize = mainWindow.getMinimumSize();
      Dimension prefSize = mainWindow.getPreferredSize();

      hic.centerBP(0, 0);
      mainWindow.setMinimumSize(new Dimension(w, h));
      mainWindow.setPreferredSize(new Dimension(w, h));
      mainWindow.pack();

      mainWindow.setState(Frame.ICONIFIED);
      mainWindow.setState(Frame.NORMAL);
      mainWindow.setVisible(true);
      mainWindow.setVisible(false);

      final Runnable painter =
          new Runnable() {
            public void run() {
              hiCPanel.paintImmediately(0, 0, w, h);
            }
          };

      Thread thread =
          new Thread(painter) {
            public void run() {
              try {
                SwingUtilities.invokeAndWait(painter);
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          };

      thread.start();
      hiCPanel.printAll(g);
      mainWindow.setPreferredSize(prefSize);
      mainWindow.setMinimumSize(minSize);
      mainWindow.setSize(new Dimension(w, h));
      waitDialog.setVisible(false);
      waitDialog.dispose();
      mainWindow.setVisible(true);
    }
  }