/** * Updates the <code>Toolbar</code> represented by this folder. * * @param cookies array of instance cookies for the folder * @return the updated <code>ToolbarPool</code> representee */ protected Object createInstance(InstanceCookie[] cookies) throws java.io.IOException, ClassNotFoundException { // refresh the toolbar's content getToolbar().removeAll(); for (int i = 0; i < cookies.length; i++) { try { Object obj = cookies[i].instanceCreate(); if (obj instanceof Presenter.Toolbar) { obj = ((Presenter.Toolbar) obj).getToolbarPresenter(); } if (obj instanceof Component) { Component comp = (Component) obj; getToolbar().add(comp); } } catch (java.io.IOException ex) { } catch (ClassNotFoundException ex) { } } // invalidate the toolbar and its parent toolbar.invalidate(); java.awt.Container parent = toolbar.getParent(); if (parent != null) { parent.validate(); parent.repaint(); } return toolbar; }
/** * Shows this glass box on the glass pane. * * @param glassPane the glass pane * @param originX the location on the X-axis to position the glass box * @param originY the location on the Y-axis to position the glass box */ public void showOnGlassPane(Container glassPane, int originX, int originY) { Dimension gd = glassPane.getSize(); Dimension bd = getPreferredSize(); int x = Math.min(originX, gd.width - bd.width); int y = Math.min(originY, gd.height - bd.height); if (x < 0) { x = 0; } if (y < 0) { y = 0; } int width = x + bd.width < gd.width ? bd.width : gd.width; int height = y + bd.height < gd.height ? bd.height : gd.height; glassPane.setLayout(null); setBounds(x, y, width, height); glassPane.add(this); glassPane.setVisible(true); Container topLevel = getTopLevel(); topLevel.validate(); topLevel.repaint(); }
/** * Removes the frame, and, if necessary, the <code>desktopIcon</code>, from its parent. * * @param f the <code>JInternalFrame</code> to be removed */ public void closeFrame(JInternalFrame f) { JDesktopPane d = f.getDesktopPane(); if (d == null) { return; } boolean findNext = f.isSelected(); Container c = f.getParent(); JInternalFrame nextFrame = null; if (findNext) { nextFrame = d.getNextFrame(f); try { f.setSelected(false); } catch (PropertyVetoException e2) { } } if (c != null) { c.remove(f); // Removes the focus. c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); } removeIconFor(f); if (f.getNormalBounds() != null) f.setNormalBounds(null); if (wasIcon(f)) setWasIcon(f, null); if (nextFrame != null) { try { nextFrame.setSelected(true); } catch (PropertyVetoException e2) { } } else if (findNext && d.getComponentCount() == 0) { // It was selected and was the last component on the desktop. d.requestFocus(); } }
public void changePage(JPanel newJPanel) { // Skifte side metode som vil have et nyt JPanel Container panel = frame.getContentPane(); panel.removeAll(); panel.add(newJPanel); panel.repaint(); panel.revalidate(); }
/** * @param renderable * @param widget * @param container * @requires renderable != null && renderable.blockID != null && renderable.blockID != Block.NULL * && widget != null && container != null * @modifies renderable && children blocks connected to renderable * @effects removes renderable from container and widget and re-renders renderable block, widget, * and container appropriately. Repeats for all of renderable's children. */ private void removeBlock( RenderableBlock renderable, WorkspaceWidget widget, Container container) { widget.removeBlock(renderable); container.remove(renderable); container.validate(); container.repaint(); renderable.setParentWidget(null); // Workspace.getInstance().notifyListeners(new WorkspaceEvent(widget, renderable.getBlockID(), // WorkspaceEvent.BLOCK_REMOVED)); for (BlockConnector child : BlockLinkChecker.getSocketEquivalents( workspace.getEnv().getBlock(renderable.getBlockID()))) { if (child == null || child.getBlockID().equals(Block.NULL)) { continue; } RenderableBlock childRenderable = workspace.getEnv().getRenderableBlock(child.getBlockID()); if (childRenderable == null) { continue; } removeBlock(childRenderable, widget, container); } if (renderable.hasComment()) { renderable.removeComment(); } workspace.notifyListeners( new WorkspaceEvent( workspace, widget, renderable.getBlockID(), WorkspaceEvent.BLOCK_REMOVED)); }
private void removeOrder(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_removeOrder // let the user confirm removal int userSure = JOptionPane.showConfirmDialog( client, "Bestellung wirklich" + " löschen?", "Löschung bestätigen", JOptionPane.YES_NO_OPTION); if (userSure != JOptionPane.YES_OPTION) return; // remove the order from the database try { stmt.executeUpdate("DELETE FROM orderParts WHERE orderId = " + orderID); stmt.executeUpdate("DELETE FROM orders WHERE id = " + orderID); } catch (SQLException e) { JOptionPane.showMessageDialog( client, "Fehler bei der Kommunikation" + "mit der Datenbank.", "Netzwerkfehler", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); return; } // remove this panel java.awt.Container parent = getParent(); parent.remove(this); parent.validate(); parent.repaint(); } // GEN-LAST:event_removeOrder
public void run() { // System.out.println("PageLoader: u=" + url); if (url == null) { // restore the original cursor help.setCursor(cursor); // PENDING(prinz) remove this hack when // automatic validation is activated. Container parent = help.getParent(); parent.repaint(); } else { Document doc = help.getDocument(); try { help.setPage(url); } catch (Exception ioe) { help.setDocument(doc); getToolkit().beep(); } finally { // schedule the cursor to revert after // the paint has happended. url = null; SwingUtilities.invokeLater(this); } } }
private void repaintViewport() { if (!isDisplayable() || !isVisible()) return; Container p = getParent(); if (p instanceof JBViewport) { p.repaint(); } }
/** Convenience method to remove the desktopIcon of <b>f</b> is necessary. */ protected void removeIconFor(JInternalFrame f) { JInternalFrame.JDesktopIcon di = f.getDesktopIcon(); Container c = di.getParent(); if (c != null) { c.remove(di); c.repaint(di.getX(), di.getY(), di.getWidth(), di.getHeight()); } }
/** * Dismisses this glass box. This causes the glass box to be removed from it's parent and ensure * that the display is correctly updated. */ public void dismiss() { JComponent parent = (JComponent) getParent(); if (parent != null) { Container toplevel = parent.getTopLevelAncestor(); parent.remove(this); toplevel.validate(); toplevel.repaint(); } }
public void start() { snakePanel.init(); rootContainer.validate(); rootContainer.setVisible(true); rootContainer.repaint(); snakePanel.requestFocus(); snakePanel.start(); }
/** * Updates the layout in response to receiving notification of change from the model. This is * implemented to call <code>preferenceChanged</code> to reschedule a new layout if the <code> * ElementChange</code> record is not <code>null</code>. * * @param ec changes to the element this view is responsible for (may be <code>null</code> if * there were no changes) * @param e the change information from the associated document * @param a the current allocation of the view * @see #insertUpdate * @see #removeUpdate * @see #changedUpdate * @since 1.3 */ protected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a) { if ((ec != null) && (a != null)) { // should damage more intelligently preferenceChanged(null, true, true); Container host = getContainer(); if (host != null) { host.repaint(); } } }
public int doTick() { Color color = colors[0]; synchronized (colors) { System.arraycopy(colors, 1, colors, 0, colors.length - 1); colors[colors.length - 1] = color; } pan.repaint(); return 100; }
private void setPage(AbstractWizardPage newPage) { Container wizardPageContainer = wizard.getWizardPageContainer(); if (currentPage != null) { wizardPageContainer.remove(currentPage); } currentPage = newPage; currentPage.setWizardController(this); wizardPageContainer.add(currentPage); wizardPageContainer.validate(); wizardPageContainer.repaint(); updateButtons(); }
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(); }
/* */ private void update(DocumentEvent paramDocumentEvent, Shape paramShape) { /* 731 */ int i = this.lineCount; /* 732 */ breakLines(paramDocumentEvent.getOffset()); /* 733 */ if (i != this.lineCount) { /* 734 */ WrappedPlainView.this.preferenceChanged(this, false, true); /* */ /* 736 */ getContainer().repaint(); /* 737 */ } else if (paramShape != null) { /* 738 */ Container localContainer = getContainer(); /* 739 */ Rectangle localRectangle = (Rectangle) paramShape; /* 740 */ localContainer.repaint( localRectangle.x, localRectangle.y, localRectangle.width, localRectangle.height); /* */ } /* */ }
public void hide() { Component component = getComponent(); if (component != null) { Container parent = component.getParent(); if (parent != null) { Rectangle bounds = component.getBounds(); parent.remove(component); parent.repaint(bounds.x, bounds.y, bounds.width, bounds.height); } } owner = null; }
public int doTick() { xball = xball + v_xball; yball = yball + v_yball; if (xball >= 600) { v_xball = -v_xball; } if (xball <= 0) { v_xball = -v_xball; } if (yball >= 450) { v_yball = -v_yball; } if (yball <= 0) { v_yball = -v_yball; } pan.repaint(); return 50; }
private void removeChildrenBlock( RenderableBlock renderable, WorkspaceWidget widget, Container container) { widget.removeBlock(renderable); container.remove(renderable); container.validate(); container.repaint(); renderable.setParentWidget(null); // Workspace.getInstance().notifyListeners(new WorkspaceEvent(widget, renderable.getBlockID(), // WorkspaceEvent.BLOCK_REMOVED)); for (BlockConnector child : workspace.getEnv().getBlock(renderable.getBlockID()).getSockets()) { if (child == null || child.getBlockID().equals(Block.NULL)) { continue; } RenderableBlock childRenderable = workspace.getEnv().getRenderableBlock(child.getBlockID()); if (childRenderable == null) { continue; } removeBlock(childRenderable, widget, container); } // If it is a procedure block, we want to delete the entire stack if (workspace.getEnv().getBlock(renderable.getBlockID()).isProcedureDeclBlock()) { if (workspace.getEnv().getBlock(renderable.getBlockID()).getAfterBlockID() != Block.NULL) { removeAfterBlock( workspace .getEnv() .getRenderableBlock( workspace.getEnv().getBlock(renderable.getBlockID()).getAfterBlockID()), widget, container); this.disconnectBlock( workspace .getEnv() .getBlock(workspace.getEnv().getBlock(renderable.getBlockID()).getAfterBlockID()), widget); } } if (renderable.hasComment()) { renderable.removeComment(); } workspace.notifyListeners( new WorkspaceEvent( workspace, widget, renderable.getBlockID(), WorkspaceEvent.BLOCK_REMOVED)); }
void validate() { Container parent = SwingUtilities.getAncestorOfClass(CollapsiblePaneContainer.class, JXCollapsiblePane.this); if (parent != null) { parent = ((CollapsiblePaneContainer) parent).getValidatingContainer(); } else { parent = getParent(); } if (parent != null) { if (parent instanceof JComponent) { ((JComponent) parent).revalidate(); } else { parent.invalidate(); } parent.doLayout(); parent.repaint(); } }
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); } } }
public void blockDropped(RenderableBlock block) { // remove block WorkspaceWidget oldParent = block.getParentWidget(); if (oldParent != null) oldParent.removeBlock(block); Container parent = block.getParent(); if (parent != null) { parent.remove(block); parent.validate(); parent.repaint(); block.setParentWidget(null); } // fire to workspace that block was removed // DO FIRE AN EVENT IF BLOCK IS REMOVED BY USER!!!! // NOTE however that we do not throw na event for adding internally Workspace.getInstance() .notifyListeners( new WorkspaceEvent(this, block.getBlockID(), WorkspaceEvent.BLOCK_REMOVED)); }
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(); } } }
/** * Removes the frame from its parent and adds its <code>desktopIcon</code> to the parent. * * @param f the <code>JInternalFrame</code> to be iconified */ public void iconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon; Container c = f.getParent(); JDesktopPane d = f.getDesktopPane(); boolean findNext = f.isSelected(); desktopIcon = f.getDesktopIcon(); if (!wasIcon(f)) { Rectangle r = getBoundsForIconOf(f); desktopIcon.setBounds(r.x, r.y, r.width, r.height); setWasIcon(f, Boolean.TRUE); } if (c == null || d == null) { return; } if (c instanceof JLayeredPane) { JLayeredPane lp = (JLayeredPane) c; int layer = lp.getLayer(f); lp.putLayer(desktopIcon, layer); } // If we are maximized we already have the normal bounds recorded // don't try to re-record them, otherwise we incorrectly set the // normal bounds to maximized state. if (!f.isMaximum()) { f.setNormalBounds(f.getBounds()); } d.setComponentOrderCheckingEnabled(false); c.remove(f); c.add(desktopIcon); d.setComponentOrderCheckingEnabled(true); c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); if (findNext) { if (d.selectFrame(true) == null) { // The icon is the last frame. f.restoreSubcomponentFocus(); } } }
public void repaint() { pane.repaint(); }
/** Request that this view be repainted. Assumes the view is still at its last-drawn location. */ private void repaint(long delay) { if (container != null && fBounds != null) { container.repaint(delay, fBounds.x, fBounds.y, fBounds.width, fBounds.height); } }
public void updateSize() { this.setMinimumSize(this.prefixRowsPanel.getSize()); // --- update width of the JTextFieldResizing to the max size per // column // - begin --- if (this.prefixRowsPanel.getComponentCount() >= 3) { // -- get max width for each column - begin -- int maxWidthLeftColumn = 10; int maxWidthRightColumn = 150; Container textField = null; Dimension d = null; // walk through rows... for (int i = 0; i < this.prefixRowsPanel.getComponentCount(); i += 1) { // left text field... i += 1; // skip Label textField = (Container) this.prefixRowsPanel.getComponent(i); final Dimension leftSize = (textField instanceof JTextFieldResizing) ? ((JTextFieldResizing) textField).calculateSize() : textField.getPreferredSize(); maxWidthLeftColumn = Math.max(maxWidthLeftColumn, leftSize.width); // right text field... i += 1; i += 1; // skip Label textField = (Container) this.prefixRowsPanel.getComponent(i); final Dimension rightSize = (textField instanceof JTextFieldResizing) ? ((JTextFieldResizing) textField).calculateSize() : textField.getPreferredSize(); maxWidthRightColumn = Math.max(maxWidthRightColumn, rightSize.width); i += 1; // skip delete-label } // -- get max width for each column - end -- // -- update elements of each column - begin -- // walk through rows... for (int i = 0; i < this.prefixRowsPanel.getComponentCount(); i += 1) { i += 1; // skip Label // left text field... textField = (Container) this.prefixRowsPanel.getComponent(i); d = new Dimension(maxWidthLeftColumn, textField.getPreferredSize().height); textField.setPreferredSize(d); textField.setSize(d); textField.setMaximumSize(d); textField.setMinimumSize(d); textField.repaint(); // right text field... i += 1; i += 1; // skip Label textField = (Container) this.prefixRowsPanel.getComponent(i); d = new Dimension(maxWidthRightColumn, textField.getPreferredSize().height); textField.setPreferredSize(d); textField.setSize(d); textField.setMaximumSize(d); textField.setMinimumSize(d); textField.repaint(); i += 1; // skip delete-label } // -- update elements of each column - end -- } // --- update width of the JTextFieldResizing to the max size per // column // - begin --- // update height of the GraphBox... if (this.getBox() != null) { this.getBox().height = this.getPreferredSize().height; } this.setSize(this.getPreferredSize()); this.revalidate(); // re-validate the PrefixPanel }
public void actionPerformed(ActionEvent e) { step.setWidth(200); cp.repaint(); System.out.println(step.getSize()); }
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(); */ }
/** * 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; }