javax.swing.JScrollPane.getSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中javax.swing.JScrollPane.getSize()方法的一些代码示例,展示了JScrollPane.getSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JScrollPane.getSize()方法的具体详情如下:
包路径:javax.swing.JScrollPane
类名称:JScrollPane
方法名:getSize

JScrollPane.getSize介绍

暂无

代码示例

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

private void repositionView() {
  int size = ((int)p.getSize().getWidth()-2*insets);
  paddedContainer.remove(view);
  paddedContainer.add(view,String.format("growy 1.0, width %d",size));
}

代码示例来源:origin: stackoverflow.com

JTable table = new JTable(rowData, headerData)
{
  private static final int DESIRED_WIDTH = 400;

  Dimension dim = new Dimension(DESIRED_WIDTH, Integer.MAX_VALUE);

  {
    JScrollPane dummy = new JScrollPane(this);
    dummy.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JFrame frame = new JFrame();
    frame.add(dummy);
    frame.pack();
    int actualWidth = dummy.getSize().width;
    frame.dispose();
    int excess = actualWidth - DESIRED_WIDTH;
    dim = new Dimension(DESIRED_WIDTH - excess, getRowHeight() * 3);
  }

  public Dimension getPreferredScrollableViewportSize()
  {
    return dim;
  }
};

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame();

final JTextPane text = new JTextPane();
text.setContentType("text/html");
text.setEditable(false);
text.setText("some random thing makes this pane bigger than its perferred size");

final JScrollPane scroll = new JScrollPane(text);
scroll.addComponentListener(new ComponentAdapter()  {
    @Override
    public void componentResized(ComponentEvent e) {
      System.out.println("Size of JScrollPane is: " + scroll.getSize());
      System.out.println("Size of JTextPane is: " + text.getSize());
    }
});

frame.setLayout(new BorderLayout());
frame.add(scroll,BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);

代码示例来源:origin: MegaMek/megamek

@Override
  public void treeExpanded(TreeExpansionEvent arg0) {
    if (forceTree.getPreferredSize().getWidth() > paneForceTree.getSize().getWidth()) {
      rightPanel.setMinimumSize(new Dimension(forceTree.getMinimumSize().width, rightPanel.getMinimumSize().height));
      rightPanel.setPreferredSize(new Dimension(forceTree.getPreferredSize().width, rightPanel.getPreferredSize().height));
    }
    rightPanel.revalidate();
  }
});

代码示例来源:origin: net.preibisch/multiview-reconstruction

public SimpleInfoBox( final String title, final String text )
  {
    frame = new JFrame( title );

    final JTextArea textarea = new JTextArea( text );

    final JPanel panel = new JPanel();
    panel.add( textarea, BorderLayout.CENTER );
    final JScrollPane pane = new JScrollPane( panel );
    frame.add( pane, BorderLayout.CENTER );

    frame.pack();

    final Dimension d = pane.getSize();
    d.setSize( d.width + 20, d.height + 10 );
    pane.setSize( d );
    pane.setPreferredSize( d );
    frame.setPreferredSize( d );

    frame.pack();
    frame.setVisible( true );
  }
}

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

public void cmdToBar(JScrollPane scrollPane, JInternalFrame cmdFrame) {
  desktop.remove(cmdFrame);
  cmdFrame.dispose();
  scrollPane.getViewport().setMaximumSize(new Dimension(frame.getSize().width, 35));
  scrollPane.getViewport().setPreferredSize(new Dimension(frame.getSize().width, 35));
  frame.add(scrollPane, BorderLayout.PAGE_END);
  desktop.updateUI();
}

代码示例来源:origin: com.eas.platypus/platypus-js-scalable-widget

public void fit() {
  Dimension lSize = eventsTarget.getPreferredSize();
  lSize.height = Math.round(lSize.height);
  lSize.width = Math.round(lSize.width);
  JScrollPane lsp = (JScrollPane) getParent().getParent();
  Dimension lSpSize = lsp.getSize();
  float XScale = (float) lSpSize.width / (float) lSize.width;
  float YScale = (float) lSpSize.height / (float) lSize.height;
  if (XScale < YScale) {
    scaleBy(XScale);
  } else {
    scaleBy(YScale);
  }
}

代码示例来源:origin: org.apache.uima/uimaj-tools

Dimension d = this.textScrollPane.getSize();
this.preferences.setProperty(textSizePref + widthSuffix, Double.toString(d.getWidth()));
this.preferences.setProperty(textSizePref + heightSuffix, Double.toString(d.getHeight()));
d = this.indexTreeScrollPane.getSize();
this.preferences.setProperty(indexTreeSizePref + widthSuffix, Double.toString(d.getWidth()));
this.preferences.setProperty(indexTreeSizePref + heightSuffix, Double.toString(d.getHeight()));
d = this.fsTreeScrollPane.getSize();
this.preferences.setProperty(fsTreeSizePref + widthSuffix, Double.toString(d.getWidth()));
this.preferences.setProperty(fsTreeSizePref + heightSuffix, Double.toString(d.getHeight()));

代码示例来源:origin: RPTools/maptool

@Override
  public void mouseDragged(MouseEvent e) {
    boolean lock = (scrollPane.getSize().height + scrollPane.getVerticalScrollBar().getValue()) < scrollPane.getVerticalScrollBar().getMaximum();
    // The user has manually scrolled the scrollbar, Scroll lock time baby !
    MapTool.getFrame().getCommandPanel().getScrollLockButton().setSelected(lock);
  }
});

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

public void cmdToFrame(JScrollPane scrollingArea) {
  frame.remove(scrollingArea);
  JInternalFrame cmdFrame = new RegisteredJInternalFrame("Scripting", "Console", "Command console", true, false, false, true);
  cmdFrame.add(scrollingArea);
  cmdFrame.setVisible(true);
  cmdFrame.pack();
  int height = frame.getSize().height / 4;
  int width = 1000;
  int yPosition = frame.getSize().height - height;
  if (height < 68) {
    height = 68;
    yPosition = 0;
  }
  if (width > frame.getSize().width) {
    width = frame.getSize().width;
  }
  scrollingArea.getViewport().setPreferredSize(new Dimension(width, height));
  cmdFrame.setSize(width, height);
  cmdFrame.setLocation(-4, yPosition - 87);
  desktop.add(cmdFrame);
}

代码示例来源:origin: org.activecomponents.jadex/jadex-commons-gui

public Dimension getPreferredSize()
  {
    // Try to use dimension from containing scroll panel to expand to full size.
    Dimension    pref    = super.getPreferredSize();
    
    Dimension    par    = null;
    if(getParent()!=null && getParent().getParent() instanceof JScrollPane)
    {
      JScrollPane    scroll    = (JScrollPane)getParent().getParent();
      par    = scroll.getSize();
      Border    border    = scroll.getBorder();
      if(border!=null)
      {
        Insets    insets    = scroll.getBorder().getBorderInsets(scroll);
        par.width    -= insets.left + insets.right;
        par.height    -= insets.top + insets.bottom;
      }
    }
//        System.out.println("par: "+par);
    int	prefwidth	= pref!=null ? pref.width : 0;
    int	prefheight	= pref!=null ? pref.height : 0;
    int	parwidth	= par!=null ? par.width : 0;
    int	parheight	= par!=null ? par.height : 0;
    Dimension    ret    = new Dimension(Math.max(prefwidth, parwidth), Math.max(prefheight, parheight));
    return ret;
  }

代码示例来源:origin: net.sf.cssbox/pdf2dom

contentCanvas = new PdfBrowserCanvas(doc, null, contentScroll.getSize(), url);
contentCanvas.addMouseListener(new MouseListener() {
  public void mouseClicked(MouseEvent e)

代码示例来源:origin: com.synaptix/SynaptixTattoo

} else if (direction == SCROLL_DOWN) {
  scrollDirection = SCROLL_DOWN;
  Dimension size = scroller.getSize();
  Point convertedPoint = SwingUtilities.convertPoint(scroller,
      new Point(1, (size.height - 1) - 2), list);

代码示例来源:origin: com.eas.platypus/platypus-js-scalable-widget

protected Point calcLeftBottomRes() {
  Point lpt = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
  if (getParent() != null && getParent().getParent() != null
      && getParent().getParent() instanceof JScrollPane) {
    JScrollPane lsp = (JScrollPane) getParent().getParent();
    Dimension lSpSize = lsp.getSize();
    JScrollBar lhsb = lsp.getHorizontalScrollBar();
    JScrollBar lvsb = lsp.getVerticalScrollBar();
    int lx = 0;
    int ly = 0;
    if (lhsb != null && lhsb.isVisible()) {
      lx = lhsb.getMaximum() - lhsb.getValue() - lSpSize.width;
    }
    if (lvsb != null && lvsb.isVisible()) {
      ly = lvsb.getMaximum() - lvsb.getValue() - lSpSize.height;
    }
    lpt.x = Math.max(0, lx);
    lpt.y = Math.max(0, ly);
  }
  return lpt;
}

代码示例来源:origin: JetBrains/jediterm

Dimension dimension = scrollpane.getSize();

代码示例来源:origin: net.sf.nimrod/nimrod-laf

Dimension dim = sp.getSize();

代码示例来源:origin: org.simplericity.jettyconsole/jetty-console-core

scroll.invalidate();
scroll.doLayout();
scroll.paintImmediately(new Rectangle(scroll.getSize()));

代码示例来源:origin: eu.mihosoft.vrl/vrl

= messageFieldScrollPane.getSize().width - 15;

代码示例来源:origin: info.aduna.clustermap/aduna-clustermap-core

public void stateChanged(ChangeEvent e) {
    // only proceed when we already know the containing scroll pane
    if (scrollPane == null) {
      return;
    }

    // determine the currently available size, subtracting the
    // insets occupied by borders
    Dimension newSize = scrollPane.getSize();
    Insets insets = scrollPane.getInsets();
    newSize.width -= (insets.left + insets.right);
    newSize.height -= (insets.top + insets.bottom);

    // fetch the currently set available size
    ClusterMap map = panel.getClusterMap();
    RenderingProperties properties = map.getRenderingProperties();
    Dimension currentSize = properties.getAvailableSize();

    // see if the current size is valid and different
    if (newSize.width > 0 && newSize.height > 0 && !newSize.equals(currentSize)) {
      // apply the new available size
      properties.setAvailableSize(newSize);
      map.updateRenderer();
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-designer

} else if (viewport.getParent() instanceof JScrollPane) {
  JScrollPane scrollPane = (JScrollPane)viewport.getParent();
  Dimension extentSize = scrollPane.getSize();

相关文章

JScrollPane类方法