コード例 #1
0
 private void cancelButtonActionPerformed(ActionEvent e) {
   cont.remove(this);
   cont.setCurrent(previous);
   cont.add(cont.getCurrent());
   cont.revalidate();
   cont.repaint();
 }
コード例 #2
0
  private void repaintViewport() {
    if (!isDisplayable() || !isVisible()) return;

    Container p = getParent();
    if (p instanceof JBViewport) {
      p.repaint();
    }
  }
コード例 #3
0
 public void setWidth(int width) {
   int height = 50;
   editorPane.setSize(width, 2000);
   try {
     height = (int) editorPane.modelToView(editorPane.getDocument().getLength() - 1).getY() + 25;
   } catch (BadLocationException e) {
   }
   editorPane.setSize(width, height);
   sp.setSize(width + 1, height + 1);
   sp.revalidate();
   editorPane.revalidate();
   cp.repaint();
 }
コード例 #4
0
 private void saveButtonActionPerformed(ActionEvent e) {
   String animal = animalField.getText();
   String color = colorField.getText();
   String name = nameField.getText();
   try {
     facade.addNewTrial(animal, color, name);
   } catch (Exception ex) {
     showError();
     ex.printStackTrace();
     return;
   }
   cont.remove(this);
   cont.setCurrent(previous);
   cont.add(cont.getCurrent());
   cont.revalidate();
   cont.repaint();
 }
コード例 #5
0
    void validate() {
      Container parent =
          SwingUtilities.getAncestorOfClass(JCollapsiblePaneContainer.class, JCollapsiblePane.this);
      if (parent != null) {
        parent = ((JCollapsiblePaneContainer) parent).getValidatingContainer();
      } else {
        parent = getParent();
      }

      if (parent != null) {
        if (parent instanceof JComponent) {
          ((JComponent) parent).revalidate();
        } else {
          parent.invalidate();
        }
        parent.doLayout();
        parent.repaint();
      }
    }
コード例 #6
0
ファイル: HelpFrame.java プロジェクト: kelindev/javaStudy
    public void run() {
      if (url == null) {
        // restore the original cursor
        html.setCursor(cursor);

        Container parent = html.getParent();
        parent.repaint();
      } else {
        Document doc = html.getDocument();
        try {
          html.setPage(url);
        } catch (IOException ioe) {
          html.setDocument(doc);
          getToolkit().beep();
        } finally {
          url = null;
          SwingUtilities.invokeLater(this);
        }
      }
    }
コード例 #7
0
 private void setBounds(Point location, Dimension size) {
   if (myView != null) {
     if (size == null) {
       size = myView.getSize();
     }
     if (location == null) {
       location = myView.getLocation();
     } else {
       Component parent = myView instanceof Window ? null : myView.getParent();
       if (parent != null) {
         SwingUtilities.convertPointFromScreen(location, parent);
       }
     }
     myView.setBounds(location.x, location.y, size.width, size.height);
     if (myView.isVisible()) {
       myView.invalidate();
       myView.validate();
       myView.repaint();
     }
   }
 }
コード例 #8
0
    public void run() {
      if (url == null) {
        // restore the original cursor
        html.setCursor(cursor);

        // PENDING(prinz) remove this hack when
        // automatic validation is activated.
        Container parent = html.getParent();
        parent.repaint();
      } else {
        Document doc = html.getDocument();
        try {
          html.setPage(url);
        } catch (IOException ioe) {
          html.setDocument(doc);
          getToolkit().beep();
        } finally {
          // schedule the cursor to revert after
          // the paint has happended.
          url = null;
          SwingUtilities.invokeLater(this);
        }
      }
    }
コード例 #9
0
ファイル: VTabbedToolPanel.java プロジェクト: timburrow/ovj3
  public void showPinObj(PushpinIF pobj, boolean on) {
    Component comp = (Component) pobj;
    if (comp == null) return;
    Container p = comp.getParent();
    if (!on) {
      pobj.setPopup(false, true);
      if (p != null && p != tabbedPane) {
        p.remove(comp);
        p.validate();
        p.repaint();
      }
      if (popupComp == comp) popupComp = null;
      return;
    }

    if (popupComp != null) {
      if (popupComp != comp) {
        ((PushpinIF) popupComp).setPopup(false, true);
        p = popupComp.getParent();
        if (p != null && p != tabbedPane) {
          p.remove(popupComp);
        }
      }
      popupComp = null;
    }
    /*
    if (!isShowing()) {
        return;
    }
     */
    if (comp.isShowing()) {
      return;
    }
    Container p2 = null;
    p = pinPanel.getParent();
    while (p != null) {
      if (p instanceof JLayeredPane) p2 = p;
      p = p.getParent();
    }
    if (p2 == null) return;
    if (!isShowing()) {
      VnmrjIF vif = Util.getVjIF();
      vif.raiseToolPanel(on);
      setVisible(true);
    }

    popupComp = comp;
    p = p2;
    pobj.setPopup(true, true);
    /*
    Point pt0 = p.getLocationOnScreen();
    Point pt1 = getLocationOnScreen();
     */
    Point pt1 = getLocation();
    Dimension dim = getSize();
    int y0 = (int) ((float) dim.height * pobj.getRefY());
    int h = (int) ((float) dim.height * pobj.getRefH());
    int x = pt1.x + 2;
    int y = pt1.y + y0;
    p.add(comp, JLayeredPane.MODAL_LAYER);
    comp.setBounds(x, y, dim.width, dim.height - y0);
    ((JComponent) p).validate();
    /*
    p.repaint();
     */
  }
コード例 #10
0
 public void actionPerformed(ActionEvent e) {
   step.setWidth(200);
   cp.repaint();
   System.out.println(step.getSize());
 }
コード例 #11
0
ファイル: GuiUtility.java プロジェクト: dschachinger/colibri
  /**
   * This method represents the window in which the preferred parameters for the obix components can
   * be chosen.
   *
   * @param chosenComponents The list of {@link ObixObject} which have been chosen in the previous
   *     window.
   * @return The container in which the preferred parameters for the obix components can be chosen.
   */
  private Container chooseParameters(List<ObixObject> chosenComponents) {
    Container pane = new Container();
    pane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    Font titelF = new Font("Courier", Font.BOLD, 30);
    title = new JLabel("Please choose the appropriate Parameters for the datapoints");
    title.setFont(titelF);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 10;
    c.gridx = 0;
    c.gridy = 0;
    pane.add(title, c);

    List<String> parametersList = Configurator.getInstance().getAvailableParameterTypes();
    String[] parameterTypes = new String[parametersList.size()];
    parameterTypes = parametersList.toArray(parameterTypes);

    for (ObixObject o : chosenComponents) {
      c.gridy++;
      c.insets = new Insets(30, 10, 0, 0);

      JLabel uriLabel = new JLabel(o.getObixUri());
      uriLabel.setFont(new Font("Courier", Font.ITALIC, 15));
      c.gridx = 0;
      c.gridwidth = 10;
      pane.add(uriLabel, c);

      c.gridwidth = 1;
      c.insets = new Insets(10, 10, 0, 0);

      JLabel parameter1Label = new JLabel("Parameter 1 Type:");
      c.gridy++;
      pane.add(parameter1Label, c);

      JLabel parameter1ObixUnitLabel = new JLabel("OBIX unit: " + o.getObixUnitUri());
      c.gridx++;
      pane.add(parameter1ObixUnitLabel, c);

      JComboBox parameter1comboBox = new JComboBox(parameterTypes);
      c.gridx++;
      pane.add(parameter1comboBox, c);

      JButton param1AddStateButton = new JButton("Add State");
      Box vBox1 = Box.createVerticalBox();
      vBox1.setBorder(BorderFactory.createLineBorder(Color.black));

      JLabel parameter1UnitLabel = new JLabel("Set Parameter 1 Unit:");
      c.gridx++;
      pane.add(parameter1UnitLabel, c);

      JTextField parameter1UnitTextField = new JTextField(o.getParameter1().getParameterUnit());
      parameter1UnitTextField.setPreferredSize(new Dimension(500, 20));
      parameter1UnitTextField.setMinimumSize(new Dimension(500, 20));
      c.gridx++;
      pane.add(parameter1UnitTextField, c);

      JLabel parameter1ValueTypeLabel =
          new JLabel("valueType: " + o.getParameter1().getValueType());
      c.gridx++;
      pane.add(parameter1ValueTypeLabel, c);

      int param1UnitLabelxPosition = c.gridx;
      int param1UnitLabelyPosition = c.gridy;

      for (StateDescription s : o.getParameter1().getStateDescriptions()) {
        JLabel stateNameLabel = new JLabel("State Name: ");
        JTextField stateNameTextfield = new JTextField(20);
        stateNameTextfield.setText(s.getName().getName());
        vBox1.add(stateNameLabel);
        vBox1.add(stateNameTextfield);

        JLabel stateValueLabel = new JLabel("State Value: ");
        JTextField stateValueTextfield = new JTextField(20);
        stateValueTextfield.setText(s.getValue().getValue());
        vBox1.add(stateValueLabel);
        vBox1.add(stateValueTextfield);

        JLabel stateURILabel = new JLabel("State URI: ");
        JTextField stateURITextfield = new JTextField(20);
        stateURITextfield.setText(s.getStateDescriptionUri());
        vBox1.add(stateURILabel);
        vBox1.add(stateURITextfield);

        JButton deleteStateButton = new JButton("Delete State");
        vBox1.add(deleteStateButton);

        JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
        vBox1.add(horizontalLine);
        vBox1.add(horizontalLine);

        StateRepresentation stateRepresentation =
            (new StateRepresentation(
                param1AddStateButton,
                deleteStateButton,
                stateNameLabel,
                stateNameTextfield,
                stateValueLabel,
                stateValueTextfield,
                stateURILabel,
                stateURITextfield,
                horizontalLine,
                vBox1,
                o.getParameter1()));

        addDeleteStateListener(stateRepresentation);
        listOfStateRepresentations.add(stateRepresentation);

        pane.revalidate();
        pane.repaint();
      }

      addParameterBoxListener(
          parameter1comboBox,
          param1UnitLabelxPosition,
          param1UnitLabelyPosition,
          parameter1UnitLabel,
          parameter1UnitTextField,
          pane,
          param1AddStateButton,
          vBox1);

      /** Add state to parameter 1 function listener */
      param1AddStateButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              JLabel stateNameLabel = new JLabel("State Name: ");
              JTextField stateNameTextfield = new JTextField(20);
              vBox1.add(stateNameLabel);
              vBox1.add(stateNameTextfield);
              JLabel stateValueLabel = new JLabel("State Value: ");

              JTextField stateValueTextfield = new JTextField(20);
              vBox1.add(stateValueLabel);
              vBox1.add(stateValueTextfield);

              JLabel stateURILabel = new JLabel("State URI: ");
              JTextField stateURITextfield = new JTextField(20);
              vBox1.add(stateURILabel);
              vBox1.add(stateURITextfield);

              JButton deleteStateButton = new JButton("Delete State");
              vBox1.add(deleteStateButton);

              JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
              vBox1.add(horizontalLine);
              vBox1.add(horizontalLine);

              StateRepresentation stateRepresentation =
                  (new StateRepresentation(
                      param1AddStateButton,
                      deleteStateButton,
                      stateNameLabel,
                      stateNameTextfield,
                      stateValueLabel,
                      stateValueTextfield,
                      stateURILabel,
                      stateURITextfield,
                      horizontalLine,
                      vBox1,
                      o.getParameter1()));

              addDeleteStateListener(stateRepresentation);
              listOfStateRepresentations.add(stateRepresentation);
              pane.revalidate();
              pane.repaint();
            }
          });

      c.gridy++;
      c.gridx = 0;
      JLabel parameter2Label = new JLabel("Parameter 2 Type:");
      pane.add(parameter2Label, c);

      JComboBox parameter2comboBox = new JComboBox(parameterTypes);
      c.gridx++;
      c.gridx++;
      pane.add(parameter2comboBox, c);

      JLabel parameter2UnitLabel = new JLabel("Set Parameter 2 Unit: ");
      c.gridx++;
      pane.add(parameter2UnitLabel, c);

      JTextField parameter2UnitTextField = new JTextField(o.getParameter2().getParameterUnit());
      parameter2UnitTextField.setPreferredSize(new Dimension(500, 20));
      parameter2UnitTextField.setMinimumSize(new Dimension(500, 20));
      c.gridx++;
      pane.add(parameter2UnitTextField, c);

      JLabel parameter2ValueTypeLabel =
          new JLabel("valueType: " + o.getParameter2().getValueType());
      c.gridx++;
      pane.add(parameter2ValueTypeLabel, c);

      JButton param2AddStateButton = new JButton("Add State");
      Box vBox2 = Box.createVerticalBox();
      vBox2.setBorder(BorderFactory.createLineBorder(Color.black));

      int param2UnitLabelxPosition = c.gridx;
      int param2UnitLabelyPosition = c.gridy;

      addParameterBoxListener(
          parameter2comboBox,
          param2UnitLabelxPosition,
          param2UnitLabelyPosition,
          parameter2UnitLabel,
          parameter2UnitTextField,
          pane,
          param2AddStateButton,
          vBox2);

      /** Add state to parameter 2 function listener */
      param2AddStateButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              JLabel stateNameLabel = new JLabel("State Name: ");
              JTextField stateNameTextfield = new JTextField(20);
              vBox2.add(stateNameLabel);
              vBox2.add(stateNameTextfield);
              JLabel stateValueLabel = new JLabel("State Value: ");

              JTextField stateValueTextfield = new JTextField(20);
              vBox2.add(stateValueLabel);
              vBox2.add(stateValueTextfield);

              JLabel stateURILabel = new JLabel("State URI: ");
              JTextField stateURITextfield = new JTextField(20);
              vBox2.add(stateURILabel);
              vBox2.add(stateURITextfield);

              JButton deleteStateButton = new JButton("Delete State");
              vBox2.add(deleteStateButton);

              JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
              vBox2.add(horizontalLine);
              vBox2.add(horizontalLine);

              StateRepresentation stateRepresentation =
                  (new StateRepresentation(
                      param2AddStateButton,
                      deleteStateButton,
                      stateNameLabel,
                      stateNameTextfield,
                      stateValueLabel,
                      stateValueTextfield,
                      stateURILabel,
                      stateURITextfield,
                      horizontalLine,
                      vBox2,
                      o.getParameter2()));

              addDeleteStateListener(stateRepresentation);
              listOfStateRepresentations.add(stateRepresentation);

              pane.revalidate();
              pane.repaint();
            }
          });

      parameter1comboBox.setSelectedItem(o.getParameter1().getParameterType());
      parameter2comboBox.setSelectedItem(o.getParameter2().getParameterType());

      representationRows.add(
          new RepresentationRow(
              o,
              parameter1comboBox,
              parameter2comboBox,
              parameter1UnitTextField,
              parameter2UnitTextField));
    }

    JButton acceptButton = new JButton("Accept");
    c.insets = new Insets(50, 0, 0, 0);
    c.gridwidth = 10;
    c.gridx = 0;
    c.gridy++;
    pane.add(acceptButton, c);

    /** Accept button listener */
    Action acceptAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (StateRepresentation s : listOfStateRepresentations) {
              if (s.getStateNameTextField().getText().isEmpty()
                  || s.getStateUriTextField().getText().isEmpty()
                  || s.getStateValueTextField().getText().isEmpty()) {
                JOptionPane.showMessageDialog(
                    null,
                    "Each state parameter field must contain a text! "
                        + "There are some empty parameter fields, please change them before proceeding.");
                return;
              }
            }

            for (ObixObject o : chosenComponents) {
              o.getParameter1().getStateDescriptions().clear();
              o.getParameter2().getStateDescriptions().clear();
            }

            for (StateRepresentation s : listOfStateRepresentations) {
              // Save created State
              ArrayList<String> types = new ArrayList<String>();
              types.add("&colibri;AbsoluteState");
              types.add("&colibri;DiscreteState");

              Value val = new Value();
              val.setValue(s.getStateValueTextField().getText());
              val.setDatatype(s.getParameter().getValueType());

              Name name = new Name();
              name.setName(s.getStateNameTextField().getText());

              StateDescription state =
                  new StateDescription(s.getStateUriTextField().getText(), types, val, name);

              s.getParameter().addStateDescription(state);
            }
            List<ObixObject> chosenObjects = Collections.synchronizedList(new ArrayList<>());
            for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
              r.getObixObject()
                  .getParameter1()
                  .setParameterType((String) r.getParam1TypeComboBox().getSelectedItem());
              r.getObixObject()
                  .getParameter2()
                  .setParameterType((String) r.getParam2TypeComboBox().getSelectedItem());
              chosenObjects.add(r.getObixObject());
              if (!r.getParam1UnitTextField().getText().isEmpty()) {
                r.getObixObject()
                    .getParameter1()
                    .setParameterUnit(r.getParam1UnitTextField().getText());
              }
              if (!r.getParam2UnitTextField().getText().isEmpty()) {
                r.getObixObject()
                    .getParameter2()
                    .setParameterUnit(r.getParam2UnitTextField().getText());
              }
            }
            representationRows.clear();
            cards.removeAll();
            JScrollPane scrollPane = new JScrollPane(interactionWindow(chosenObjects));
            scrollPane.getVerticalScrollBar().setUnitIncrement(16);
            scrollPane.setBorder(new EmptyBorder(20, 20, 20, 20));
            cards.add(scrollPane);
            // Display the window.
            mainFrame.pack();
          }
        };
    acceptButton.addActionListener(acceptAction);

    return pane;
  }