Exemplo n.º 1
0
  public int showDialog() {
    panel = new JPanel(new GridBagLayout());

    double lower = Double.NEGATIVE_INFINITY;
    double upper = Double.POSITIVE_INFINITY;

    if (parameter.isZeroOne) {
      lower = 0.0;
      upper = 1.0;
    } else if (parameter.isNonNegative) {
      lower = 0.0;
    }

    panel = new JPanel(new GridBagLayout());

    setupComponents();

    JOptionPane optionPane =
        new JOptionPane(
            panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));

    final JDialog dialog = optionPane.createDialog(frame, "Linked Parameter Setup");

    priorSettingsPanel.setDialog(dialog);
    priorSettingsPanel.setParameter(parameter);

    if (OSType.isMac()) {
      dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300));
    } else {
      Toolkit tk = Toolkit.getDefaultToolkit();
      Dimension d = tk.getScreenSize();
      if (d.height < 700 && panel.getHeight() > 450) {
        dialog.setSize(new Dimension(panel.getWidth() + 100, 550));
      } else {
        // setSize because optionsPanel is shrunk in dialog
        dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100));
      }

      //            System.out.println("panel width = " + panel.getWidth());
      //            System.out.println("panel height = " + panel.getHeight());
    }

    dialog.pack();
    dialog.setResizable(true);
    dialog.setVisible(true);

    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
      result = value;
    }

    return result;
  }
Exemplo n.º 2
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.º 3
0
  public void initComponents() {
    final Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);
    JFrame parent = new JFrame();
    final JDialog dialog = new JDialog(parent, "QUIZ", true);

    browser.addLoadListener(
        new LoadAdapter() {
          @Override
          public void onFinishLoadingFrame(FinishLoadingEvent event) {
            if (event.isMainFrame()) {
              String videoUrl =
                  "https://www.youtube.com/embed/" + url + "?rel=0&amp;controls=0&amp;showinfo=0";
              DOMDocument document = event.getBrowser().getDocument();
              DOMNode root = document.findElement(By.id("video"));
              DOMElement iframe = document.createElement("iframe");
              iframe.setAttribute("src", videoUrl);
              iframe.setAttribute("frameborder", "0");
              root.appendChild(iframe);
              DOMNode root2 = document.findElement(By.id("text"));
              DOMElement p = document.createElement("p");
              p.setAttribute("class", "text");
              DOMNode n = document.createTextNode(question.getText());
              root2.appendChild(p);
              p.appendChild(n);
              DOMNode answers = document.findElement(By.id("answers"));
              if (question.getAnswerType().equals(AnswerType.MULTIPLE_CHOICE)) {
                DOMNode form = document.createElement("form");

                AnswerManager am = new AnswerManager(session);
                List<String> answerList = am.getAnswerByQuestionId(question.getId());

                for (String answer : answerList) {
                  DOMElement trueBox = document.createElement("input");
                  trueBox.setAttribute("type", "radio");
                  trueBox.setAttribute("name", "tf");
                  DOMNode dataTrue = document.createTextNode(answer);
                  DOMElement labeltrue = document.createElement("label");
                  labeltrue.appendChild(dataTrue);

                  form.appendChild(trueBox);
                  form.appendChild(labeltrue);
                  DOMElement br = document.createElement("br");
                  form.appendChild(br);
                }

                answers.appendChild(form);
              }

              if (question.getAnswerType().equals(AnswerType.TRUE_FALSE)) {
                DOMNode form = document.createElement("form");
                DOMElement trueBox = document.createElement("input");
                trueBox.setAttribute("type", "radio");
                trueBox.setAttribute("name", "tf");
                DOMNode dataTrue = document.createTextNode("true");
                DOMElement labeltrue = document.createElement("label");
                labeltrue.appendChild(dataTrue);
                DOMElement falseBox = document.createElement("input");
                DOMNode dataFalse = document.createTextNode("false");
                DOMElement labelFalse = document.createElement("label");
                labelFalse.appendChild(dataFalse);
                falseBox.setAttribute("type", "radio");
                falseBox.setAttribute("name", "tf");
                form.appendChild(labeltrue);
                form.appendChild(trueBox);
                DOMElement br = document.createElement("br");
                form.appendChild(br);
                form.appendChild(labelFalse);
                form.appendChild(falseBox); //
                answers.appendChild(form);
              }
            }
          }
        });

    browser.loadURL("http://dtprojecten.ehb.be/~PR-Ready/question/videoFrame.html?853954951951959");
    dialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();
          }
        });

    browser.registerFunction(
        "nextQuestion",
        new BrowserFunction() {

          public JSValue invoke(JSValue... jsValues) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();
            quizLauncher.setIncrement(quizLauncher.getIncrement() + 1);
            quizLauncher.windowChoice();
            return JSValue.createUndefined();
          }
        });

    browser.registerFunction(
        "previousQuestion",
        new BrowserFunction() {

          public JSValue invoke(JSValue... jsValues) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();
            quizLauncher.setIncrement(quizLauncher.getIncrement() - 1);
            quizLauncher.windowChoice();
            return JSValue.createUndefined();
          }
        });

    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dialog.add(new BrowserView(browser), BorderLayout.CENTER);
    dialog.setResizable(false);
    dialog.setUndecorated(true);
    dialog.setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
    dialog.setLocationRelativeTo(parent);
    dialog.setVisible(true);
  }