コード例 #1
0
 public void testIntProperty() throws Exception {
   JComponent rootComponent = getInstrumentedRootComponent("TestIntProperty.form", "BindingTest");
   assertEquals(1, rootComponent.getComponentCount());
   JTextField textField = (JTextField) rootComponent.getComponent(0);
   assertEquals(37, textField.getColumns());
   assertEquals(false, textField.isEnabled());
 }
コード例 #2
0
ファイル: UIUtils.java プロジェクト: ypkkhatri/gmt
  public static void hideOnEscape(Object ob) {
    if (ob instanceof JComponent) {
      final JComponent comp = (JComponent) ob;
      InputMap inputMap = comp.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
      ActionMap actionMap = comp.getRootPane().getActionMap();

      inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), actionMap);
      actionMap.put(
          actionMap,
          new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
              comp.setVisible(false);
            }
          });
    } else if (ob instanceof JDialog) {
      final JDialog dialog = (JDialog) ob;
      InputMap inputMap = dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
      ActionMap actionMap = dialog.getRootPane().getActionMap();

      inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), actionMap);
      actionMap.put(
          actionMap,
          new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
              dialog.dispose();
            }
          });
    }
  }
コード例 #3
0
 private static void drawSelection(JTree tree, Graphics g, final int width) {
   int y = 0;
   final int[] rows = tree.getSelectionRows();
   final int height = tree.getRowHeight();
   for (int row : rows) {
     final TreeCellRenderer renderer = tree.getCellRenderer();
     final Object value = tree.getPathForRow(row).getLastPathComponent();
     if (value == null) continue;
     final Component component =
         renderer.getTreeCellRendererComponent(tree, value, false, false, false, row, false);
     if (component.getFont() == null) {
       component.setFont(tree.getFont());
     }
     g.translate(0, y);
     component.setBounds(0, 0, width, height);
     boolean wasOpaque = false;
     if (component instanceof JComponent) {
       final JComponent j = (JComponent) component;
       if (j.isOpaque()) wasOpaque = true;
       j.setOpaque(false);
     }
     component.paint(g);
     if (wasOpaque) {
       ((JComponent) component).setOpaque(true);
     }
     y += height;
     g.translate(0, -y);
   }
 }
コード例 #4
0
 public void testCardLayout() throws Exception {
   JComponent rootComponent = getInstrumentedRootComponent("TestCardLayout.form", "BindingTest");
   assertTrue(rootComponent.getLayout() instanceof CardLayout);
   CardLayout cardLayout = (CardLayout) rootComponent.getLayout();
   assertEquals(10, cardLayout.getHgap());
   assertEquals(20, cardLayout.getVgap());
 }
コード例 #5
0
    public void paint(Graphics g, JComponent comp) {
        // paint to the buffered image
        comp.setBackground(UIHelper.LIGHT_GREEN_COLOR);
        comp.setForeground(UIHelper.BG_COLOR);

        super.paint(g, comp);
    }
コード例 #6
0
 private static void drawSelection(JTable table, int column, Graphics g, final int width) {
   int y = 0;
   final int[] rows = table.getSelectedRows();
   final int height = table.getRowHeight();
   for (int row : rows) {
     final TableCellRenderer renderer = table.getCellRenderer(row, column);
     final Component component =
         renderer.getTableCellRendererComponent(
             table, table.getValueAt(row, column), false, false, row, column);
     g.translate(0, y);
     component.setBounds(0, 0, width, height);
     boolean wasOpaque = false;
     if (component instanceof JComponent) {
       final JComponent j = (JComponent) component;
       if (j.isOpaque()) wasOpaque = true;
       j.setOpaque(false);
     }
     component.paint(g);
     if (wasOpaque) {
       ((JComponent) component).setOpaque(true);
     }
     y += height;
     g.translate(0, -y);
   }
 }
コード例 #7
0
 /**
  * DOCUMENT ME!
  *
  * @param context DOCUMENT ME!
  * @param g DOCUMENT ME!
  * @param c DOCUMENT ME!
  */
 void paintBackground(SeaGlassContext context, Graphics g, JComponent c) {
   context.getPainter().paintTextFieldBackground(context, g, 0, 0, c.getWidth(), c.getHeight());
   // If necessary, paint the placeholder text.
   if (placeholderText != null && ((JTextComponent) c).getText().length() == 0 && !c.hasFocus()) {
     paintPlaceholderText(context, g, c);
   }
 }
  @Override
  public JComponent createOptionsPanel() {
    final JComponent panel = new JPanel(new GridBagLayout());

    final JPanel annotationsPanel =
        SpecialAnnotationsUtil.createSpecialAnnotationsListControl(
            annotationNames, InspectionGadgetsBundle.message("ignore.if.annotated.by"));
    final CheckBox checkBox =
        new CheckBox(
            InspectionGadgetsBundle.message("primitive.fields.ignore.option"),
            this,
            "m_ignorePrimitives");

    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    panel.add(annotationsPanel, constraints);

    constraints.gridy = 1;
    constraints.weighty = 0.0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    panel.add(checkBox, constraints);

    return panel;
  }
コード例 #9
0
  /**
   * Long description in header produces expected line-wrap in footer.
   *
   * <p>Note: the frame is not packed to simulate the appframework context.
   */
  public void interactiveHTMLTextWrapLong() {
    //      Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
    //
    //                    public void eventDispatched(AWTEvent event) {
    //                        if (event.getID() != MouseEvent.MOUSE_MOVED) {
    //                            System.out.println("e:" + event);
    //                        }
    //                    }}, Long.MAX_VALUE);
    JXHeader header = createHeader();
    JXHeader footer = new JXHeader();
    footer.setTitle("Notes:");
    String footerDescription =
        "<html>"
            + " <ul> "
            + " <li> code: in the jdnc-incubator, section kleopatra, package appframework."
            + " <li> technique: back the view by a shared presentation model "
            + " <li> technique: veto selection change until editing is completed "
            + " <li> issue: selection of tab should be vetoable "
            + " <li> issue: empty selection should disable editing pane "
            + " </ul> "
            + " </html>";
    footer.setDescription(footerDescription);

    JComponent panel = new JPanel(new BorderLayout());
    panel.add(header, BorderLayout.NORTH);
    //        panel.add(new JScrollPane(table));
    panel.add(footer, BorderLayout.SOUTH);
    //      JXFrame frame = new JXFrame("html wrapping in SOUTH: long text in NORTH");
    //      frame.add(panel);
    JXFrame frame = wrapInFrame(panel, "html wrapping in SOUTH: long text in NORTH");
    //        addComponentOrientationToggle(frame);
    frame.setSize(800, 600);
    //        show(frame);
    frame.setVisible(true);
  }
コード例 #10
0
  /**
   * Create a new tab to the FlexiBar, with the specified title and the specified component inside
   * the tab.
   *
   * @param title the title of the tab to be added
   * @param comp the component inserted in the tab
   */
  public void add(String title, JComponent comp) {
    JButton button = new JButton(title);
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            System.out.println("click");
            setSelected((JButton) arg0.getSource());
          }
        });
    button.setMinimumSize(new Dimension(this.B_WIDTH, this.B_HEIGHT));
    button.setMaximumSize(new Dimension(this.B_WIDTH, this.B_HEIGHT));
    button.setPreferredSize(new Dimension(this.B_WIDTH, this.B_HEIGHT));
    button.setAlignmentX(LEFT_ALIGNMENT);
    comp.setMinimumSize(new Dimension(this.P_WIDTH, this.P_HEIGHT));
    comp.setMaximumSize(new Dimension(this.P_WIDTH, this.P_HEIGHT));
    // comp.setPreferredSize(new Dimension(this.P_WIDTH,this.P_HEIGHT));
    comp.setAlignmentX(LEFT_ALIGNMENT);
    if (currentSelected == -1) {
      comp.setVisible(true);
      currentSelected = 0;
    } else comp.setVisible(false);

    listComponent.add(button);
    listComponent.add(comp);

    panel.add(button);
    panel.add(comp);
  }
コード例 #11
0
  /**
   * Short description in header produces unexpected line wraps in footer.
   *
   * <p>Note: the frame is not packed to simulate the appframework context.
   */
  public void interactiveHTMLTextWrapShort() {
    JXHeader header = new JXHeader();
    header.setTitle("AlbumManager");
    String headerShort =
        "An adaption from JGoodies Binding Tutorial in the context"
            + " of BeansBinding/AppFramework. ";
    header.setDescription(headerShort);
    header.setIcon(XTestUtils.loadDefaultIcon());
    JXHeader footer = new JXHeader();
    footer.setTitle("Notes:");
    String footerDescription =
        "<html>"
            + " <ul> "
            + " <li> code: in the jdnc-incubator, section kleopatra, package appframework."
            + " <li> technique: back the view by a shared presentation model "
            + " <li> technique: veto selection change until editing is completed "
            + " <li> issue: selection of tab should be vetoable "
            + " <li> issue: empty selection should disable editing pane "
            + " </ul> "
            + " </html>";
    footer.setDescription(footerDescription);

    JComponent panel = new JPanel(new BorderLayout());
    panel.add(header, BorderLayout.NORTH);
    panel.add(footer, BorderLayout.SOUTH);
    JXFrame frame = new JXFrame("html wrapping in SOUTh: short text in NORTH");
    frame.add(panel);
    frame.setSize(800, 400);
    frame.setVisible(true);
  }
コード例 #12
0
  /** {@inheritDoc} */
  @Override
  public void installUI(JComponent c) {
    super.installUI(c);

    this.pane = (JXErrorPane) c;

    installDefaults();
    installComponents();
    installListeners();

    // if the report action needs to be defined, do so
    Action a = c.getActionMap().get(JXErrorPane.REPORT_ACTION_KEY);
    if (a == null) {
      final JXErrorPane pane = (JXErrorPane) c;
      AbstractActionExt reportAction =
          new AbstractActionExt() {
            public void actionPerformed(ActionEvent e) {
              ErrorReporter reporter = pane.getErrorReporter();
              if (reporter != null) {
                reporter.reportError(pane.getErrorInfo());
              }
            }
          };
      configureReportAction(reportAction);
      c.getActionMap().put(JXErrorPane.REPORT_ACTION_KEY, reportAction);
    }
  }
コード例 #13
0
  private static boolean fitsLayeredPane(
      JLayeredPane pane, JComponent component, RelativePoint desiredLocation, HintHint hintHint) {
    if (hintHint.isAwtTooltip()) {
      Dimension size = component.getPreferredSize();
      Dimension paneSize = pane.getSize();

      Point target = desiredLocation.getPointOn(pane).getPoint();
      Balloon.Position pos = hintHint.getPreferredPosition();
      int pointer = BalloonImpl.getPointerLength(pos, false) + BalloonImpl.getNormalInset();
      if (pos == Balloon.Position.above || pos == Balloon.Position.below) {
        boolean heightFit =
            target.y - size.height - pointer > 0
                || target.y + size.height + pointer < paneSize.height;
        return heightFit && size.width + pointer < paneSize.width;
      } else {
        boolean widthFit =
            target.x - size.width - pointer > 0 || target.x + size.width + pointer < paneSize.width;
        return widthFit && size.height + pointer < paneSize.height;
      }
    } else {
      final Rectangle lpRect =
          new Rectangle(
              pane.getLocationOnScreen().x,
              pane.getLocationOnScreen().y,
              pane.getWidth(),
              pane.getHeight());
      Rectangle componentRect =
          new Rectangle(
              desiredLocation.getScreenPoint().x,
              desiredLocation.getScreenPoint().y,
              component.getPreferredSize().width,
              component.getPreferredSize().height);
      return lpRect.contains(componentRect);
    }
  }
コード例 #14
0
 public ParticleContainer(Editor editor) {
   parent = editor.getContentComponent();
   parent.add(this);
   this.setBounds(parent.getBounds());
   setVisible(true);
   parent.addComponentListener(this);
 }
コード例 #15
0
ファイル: XmlChooser.java プロジェクト: nbearson/IDV
  /**
   * Generate a user interface from the given xml document (derived from the given path). The xml
   * can be a thredds query capability, any verion of a thredds catalog or an IDV menus xml file.
   *
   * @param doc the xml document
   * @param xmlRoot The root of the xml document to create a display for.
   * @param path The url path we got the xml from.
   */
  protected void makeUi(Document doc, Element xmlRoot, String path) {
    this.document = doc;
    setHaveData(false);
    if (xmlRoot == null) {
      return;
    }
    setSelected(path);
    XmlHandler handler = null;
    String tagName = XmlUtil.getLocalName(xmlRoot);

    if (tagName.equals(WmsUtil.TAG_WMS1) || tagName.equals(WmsUtil.TAG_WMS2)) {
      handler = new WmsHandler(this, xmlRoot, path);
    } else if (tagName.equals(TAG_ERROR)) {
      final String error = XmlUtil.getAttribute(xmlRoot, "label", "Error");
      LogUtil.userErrorMessage("Error: " + error);
      return;
    } else if (tagName.equals(CatalogUtil.TAG_CATALOG)) {
      handler = new ThreddsHandler(this, xmlRoot, path);
    } else if (tagName.equals("menus")) {
      handler = new MenuHandler(this, xmlRoot, path);
    } else {
      throw new IllegalArgumentException(
          "Unknown xml:"
              + ((xmlContents.length() > 100) ? xmlContents.substring(0, 100) : xmlContents)
              + " ...");
    }

    JComponent contents = handler.getContents();
    contents.setPreferredSize(new Dimension(200, 250));
    addToContents(contents);
    addToHistory(handler);
    updateStatus();
  }
コード例 #16
0
 public Dimension getInnerSize() {
   boolean mustSort = this.mustSort;
   this.mustSort = false;
   Dimension d = scrollEnabled ? componentBox.getPreferredSize() : componentBox.getSize();
   this.mustSort = mustSort;
   return d;
 }
コード例 #17
0
  @Override
  public void paint(Graphics g, JComponent c) {
    Graphics2D g2 = (Graphics2D) g;
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();
    initShape(b);
    // ContentArea
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (model.isArmed()) {
      g2.setColor(ac);
      g2.fill(shape);
    } else if (b.isRolloverEnabled() && model.isRollover()) {
      paintFocusAndRollover(g2, c, rc);
    } else if (b.hasFocus()) {
      paintFocusAndRollover(g2, c, fc);
    } else {
      g2.setColor(c.getBackground());
      g2.fill(shape);
    }
    // Border
    g2.setPaint(c.getForeground());
    g2.draw(shape);

    g2.setColor(c.getBackground());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    super.paint(g2, c);
  }
コード例 #18
0
ファイル: ConfigDialog.java プロジェクト: npk/lcmc
  /**
   * Creates body of the dialog. You can redefine getDialogTitle(), getDescription(), getInputPane()
   * methods to customize this body.
   */
  protected final JPanel body() {
    final JPanel pane = new JPanel();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    final JEditorPane descPane =
        new JEditorPane(
            Tools.MIME_TYPE_TEXT_HTML,
            "<span style='font:bold italic;font-family:Dialog; font-size:"
                + Tools.getConfigData().scaled(14)
                + ";'>"
                + getDialogTitle()
                + "</span><br>"
                + "<span style='font-family:Dialog; font-size:"
                + Tools.getConfigData().scaled(12)
                + ";'>"
                + getDescription()
                + "</span>");
    descPane.setSize(300, Integer.MAX_VALUE);

    descPane.setBackground(Tools.getDefaultColor("ConfigDialog.Background"));
    descPane.setEditable(false);
    final JScrollPane descSP = new JScrollPane(descPane);
    descSP.setBorder(null);
    descSP.setAlignmentX(Component.LEFT_ALIGNMENT);
    descSP.setMinimumSize(new Dimension(0, 50));
    pane.add(descSP);
    final JComponent inputPane = getInputPane();
    if (inputPane != null) {
      inputPane.setMinimumSize(new Dimension(Short.MAX_VALUE, INPUT_PANE_HEIGHT));
      inputPane.setBackground(Tools.getDefaultColor("ConfigDialog.Background"));
      inputPane.setAlignmentX(Component.LEFT_ALIGNMENT);
      pane.add(inputPane);
    }
    pane.setBackground(Tools.getDefaultColor("ConfigDialog.Background.Light"));
    return pane;
  }
コード例 #19
0
  public void insertDraggableComponent(DraggableComponent component, int index) {
    component.setLayoutOrderList(layoutOrderList);

    component.addListener(draggableComponentListener);
    if (index < 0) {
      layoutOrderList.add(component.getComponent());
      componentBox.add(component.getComponent());
    } else {
      layoutOrderList.add(index, component.getComponent());
      componentBox.add(component.getComponent(), index);
    }

    sortComponentList(!descendingSortOrder);

    draggableComponentList.add(component);
    component.setOuterParentArea(outerParentArea);
    componentBox.revalidate();

    fireAddedEvent(component);
    if (autoSelect
        && layoutOrderList.size() == 1
        && selectedComponent == null
        && component.isEnabled()) doSelectComponent(component);

    updateScrollButtons();
  }
コード例 #20
0
  public static int getRoundedInteriorCorner(JComponent c) {
    if (!(c.getBorder() instanceof PBorder) && !(c.getBorder() instanceof PRoundBorder)) {
      return 0;
    }

    int h = c.getHeight() - (getBorderSize(c) * 2);
    int roundCorner = h;

    String ctype = (String) c.getClientProperty("JComponent.type");
    if (ctype != null) {
      if (ctype.equals("roundRect")) {
        return roundCorner;
      } else if (ctype.equals("square")) {
        return 0;
      } else if (ctype.equals("normal")) {
        return DEFAULT_ROUND_CORNER;
      }
    }

    Integer maxRoundCorner = (Integer) c.getClientProperty("maxRoundCorner");
    if (maxRoundCorner != null && maxRoundCorner >= 0) {
      roundCorner = Math.min(roundCorner, maxRoundCorner);
    }
    return roundCorner;
  }
コード例 #21
0
ファイル: BasicGripperUI.java プロジェクト: navy1103/jide-oss
 @Override
 public Dimension getMaximumSize(JComponent c) {
   Gripper gripper = (Gripper) c;
   if (gripper.getOrientation() == SwingConstants.HORIZONTAL)
     return new Dimension(_size, c.getParent().getHeight());
   else return new Dimension(c.getParent().getWidth(), _size);
 }
コード例 #22
0
  /**
   * Creates a plugin hosts given its class name. Use PluginHostManager.HOST_* constants.
   *
   * @param pluginHostClass Class name of plugin host to create.
   * @param props Properties map.
   * @throws PluginException on plugin error.
   */
  public void setPluginHost(String pluginHostClass, Map props) throws PluginException {
    boolean firstTime = (current_ == null);
    PluginHost previous = current_;

    try {
      current_ = (PluginHost) Class.forName(pluginHostClass).newInstance();
    } catch (InstantiationException e) {
      throw new PluginException(e);
    } catch (IllegalAccessException e) {
      throw new PluginException(e);
    } catch (ClassNotFoundException e) {
      throw new PluginException(e);
    }

    if (firstTime) {
      try {
        current_.initialize(props);
      } catch (ServiceException se) {
        throw new PluginException(se);
      }
    } else {
      try {
        transferAssets(previous, current_);
      } catch (ServiceException e1) {
        throw new PluginException(e1);
      }
      recepticle_.remove(previous.getView());
    }

    recepticle_.add(current_.getView());
  }
コード例 #23
0
ファイル: GTKStyle.java プロジェクト: susotajuraj/jdk8u-jdk
  private Insets getScrollBarInsets(SynthContext context, Insets insets) {
    int troughBorder = getClassSpecificIntValue(context, "trough-border", 1);
    insets.left = insets.right = insets.top = insets.bottom = troughBorder;

    JComponent c = context.getComponent();
    if (c.getParent() instanceof JScrollPane) {
      // This scrollbar is part of a scrollpane; use only the
      // "scrollbar-spacing" style property to determine the padding
      // between the scrollbar and its parent scrollpane.
      int spacing = getClassSpecificIntValue(WidgetType.SCROLL_PANE, "scrollbar-spacing", 3);
      if (((JScrollBar) c).getOrientation() == JScrollBar.HORIZONTAL) {
        insets.top += spacing;
      } else {
        if (c.getComponentOrientation().isLeftToRight()) {
          insets.left += spacing;
        } else {
          insets.right += spacing;
        }
      }
    } else {
      // This is a standalone scrollbar; leave enough room for the
      // focus line in addition to the trough border.
      if (c.isFocusable()) {
        int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
        int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
        int totalFocus = focusSize + focusPad;
        insets.left += totalFocus;
        insets.right += totalFocus;
        insets.top += totalFocus;
        insets.bottom += totalFocus;
      }
    }
    return insets;
  }
 public void doLayout() {
   JComponent compo;
   Dimension sz = getSize();
   compo = getPanelMenuBar();
   compo.setBounds(0, 0, sz.width, 25);
   dataScrollPane.setBounds(0, 25, sz.width, sz.height - 25);
 }
 public TestFrame() {
   super("Home Plan Component Test");
   this.home = new Home();
   this.home.getCompass().setVisible(false);
   UserPreferences preferences = new DefaultUserPreferences();
   ViewFactory viewFactory = new SwingViewFactory();
   this.homeController = new HomeController(home, preferences, viewFactory);
   JComponent homeView = (JComponent) this.homeController.getView();
   ActionMap actions = homeView.getActionMap();
   // Create buttons from HomePane actions map
   this.selectButton = new JToggleButton(actions.get(HomePane.ActionType.SELECT));
   this.createWallsButton = new JToggleButton(actions.get(HomePane.ActionType.CREATE_WALLS));
   this.createDimensionsButton =
       new JToggleButton(actions.get(HomePane.ActionType.CREATE_DIMENSION_LINES));
   ButtonGroup group = new ButtonGroup();
   group.add(this.selectButton);
   group.add(this.createWallsButton);
   group.add(this.createDimensionsButton);
   this.addButton = new JButton(actions.get(HomePane.ActionType.ADD_HOME_FURNITURE));
   this.undoButton = new JButton(actions.get(HomePane.ActionType.UNDO));
   this.redoButton = new JButton(actions.get(HomePane.ActionType.REDO));
   // Put them it a tool bar
   JToolBar toolBar = new JToolBar();
   toolBar.add(this.selectButton);
   toolBar.add(this.createWallsButton);
   toolBar.add(this.addButton);
   toolBar.add(this.undoButton);
   toolBar.add(this.redoButton);
   // Display the tool bar and main view in this pane
   add(toolBar, BorderLayout.NORTH);
   add(homeView, BorderLayout.CENTER);
   pack();
 }
コード例 #26
0
ファイル: ListOptionTest.java プロジェクト: e-ucm/eadventure
  public ListOptionTest() {
    model = new ExampleClass();
    init();

    DependencyNode node1 = new EngineNode<String>(1, "test1");

    OptionPanel p1 = new PanelImpl("Test", OptionPanel.LayoutPolicy.VerticalBlocks, 4);
    p1.add(
        new TextOption("name1", "toolTip1", model, "name", TextOption.ExpectedLength.SHORT, node1));
    p1.add(
        new TextOption("name2", "toolTip2", model, "name", TextOption.ExpectedLength.SHORT, node1));
    p1.add(new ListOption<String>("list1", "toolTip3", model, "list", String.class, node1));
    p1.add(
        new ListOption<String>("list2", "toolTip4", model, "list", String.class, node1) {
          int cosa = 1;

          @Override
          public String chooseElementToAdd() {
            return "Elemento " + (++cosa);
          }
        });

    controller.getModel().addModelListener(p1);
    JComponent internal = p1.getComponent(commandManager);
    System.err.println("Internal size demanded: " + internal.getPreferredSize());
    childPanel.add(internal, BorderLayout.CENTER);
    System.err.println("Total size demanded: " + childPanel.getPreferredSize());
  }
コード例 #27
0
ファイル: JRehaInternal.java プロジェクト: bomm/thera-pi
 public void destroyTitleBar() {
   int comp = nord.getComponentCount();
   Component icomp;
   for (int i = 0; i < comp; i++) {
     icomp = nord.getComponent(i);
     if (icomp != null) {
       ListenerTools.removeListeners(icomp);
       icomp = null;
     }
   }
   ListenerTools.removeListeners(thisContent);
   comp = thisContent.getComponentCount();
   for (int i = 0; i < comp; i++) {
     icomp = thisContent.getComponent(i);
     if (icomp != null) {
       ListenerTools.removeListeners(icomp);
       icomp = null;
     }
   }
   ListenerTools.removeListeners(inhalt);
   comp = inhalt.getComponentCount();
   for (int i = 0; i < comp; i++) {
     icomp = inhalt.getComponent(i);
     if (icomp != null) {
       ListenerTools.removeListeners(icomp);
       icomp = null;
     }
   }
 }
コード例 #28
0
  private HighlightersSet installHighlighterSet(Info info, Editor editor) {
    final JComponent internalComponent = editor.getContentComponent();
    internalComponent.addKeyListener(myEditorKeyListener);
    editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
    final Cursor cursor = internalComponent.getCursor();
    internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);

    List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
    TextAttributes attributes =
        myEditorColorsManager
            .getGlobalScheme()
            .getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
    for (TextRange range : info.getRanges()) {
      TextAttributes attr = patchAttributesColor(attributes, range, editor);
      final RangeHighlighter highlighter =
          editor
              .getMarkupModel()
              .addRangeHighlighter(
                  range.getStartOffset(),
                  range.getEndOffset(),
                  HighlighterLayer.SELECTION + 1,
                  attr,
                  HighlighterTargetArea.EXACT_RANGE);
      highlighters.add(highlighter);
    }

    return new HighlightersSet(highlighters, editor, cursor, info);
  }
コード例 #29
0
  @Override
  public void mousePressed(MouseEvent e) {
    //	The mouseMoved event continually updates this variable

    if (direction == 0) return;

    //  Setup for resizing. All future dragging calculations are done based
    //  on the original bounds of the component and mouse pressed location.

    resizing = true;

    Component source = e.getComponent();
    pressed = e.getPoint();
    SwingUtilities.convertPointToScreen(pressed, source);
    bounds = source.getBounds();

    //  Making sure autoscrolls is false will allow for smoother resizing
    //  of components

    if (source instanceof JComponent) {
      JComponent jc = (JComponent) source;
      autoscrolls = jc.getAutoscrolls();
      jc.setAutoscrolls(false);
    }
  }
コード例 #30
-1
  private void updateViewerForSelection() {
    if (myAllContents.isEmpty()) return;
    String fullString = getSelectedText();

    if (myViewer != null) {
      EditorFactory.getInstance().releaseEditor(myViewer);
    }

    if (myUseIdeaEditor) {
      myViewer = createIdeaEditor(fullString);
      JComponent component = myViewer.getComponent();
      component.setPreferredSize(JBUI.size(300, 500));
      mySplitter.setSecondComponent(component);
    } else {
      final JTextArea textArea = new JTextArea(fullString);
      textArea.setRows(3);
      textArea.setWrapStyleWord(true);
      textArea.setLineWrap(true);
      textArea.setSelectionStart(0);
      textArea.setSelectionEnd(textArea.getText().length());
      textArea.setEditable(false);
      mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea));
    }
    mySplitter.revalidate();
  }