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

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

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

JScrollPane.setSize介绍

暂无

代码示例

代码示例来源:origin: apache/geode

@Override
 public void componentResized(ComponentEvent e) {
  Component source = e.getComponent();
  scroller.setSize(source.getSize());
  scroller.revalidate();
 }
});

代码示例来源:origin: magefree/mage

@Override
  public void componentResized(ComponentEvent e) {
    int width = e.getComponent().getWidth();
    int height = e.getComponent().getHeight();
    BattlefieldPanel.this.jScrollPane.setSize(width, height);
    BattlefieldPanel.this.width = width;
    sortLayout();
  }
});

代码示例来源:origin: ron190/jsql-injection

@Override
  public void componentResized(ComponentEvent e) {
    // listen to changes of JLayeredPane size
    JScrollIndicator.this.scrollPane.setSize(JScrollIndicator.this.getSize());
    JScrollIndicator.this.scrollPane.getViewport().revalidate();
    JScrollIndicator.this.controlPanel.setSize(JScrollIndicator.this.getSize());
    JScrollIndicator.this.controlPanel.revalidate();
  }
}

代码示例来源:origin: nodebox/nodebox

JPanel tablePanel = new JPanel(new BorderLayout(5, 5));
JScrollPane tableScroll = new JScrollPane(menuItemsTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
tableScroll.setSize(200, 170);
tableScroll.setPreferredSize(new Dimension(200, 170));
tableScroll.setMaximumSize(new Dimension(200, 170));

代码示例来源:origin: com.github.yannrichet/JMathPlot

protected void initSize() {
  if (scrollPane != null) {
    scrollPane.setSize(this.getSize());
  }
  // scrollPane.setPreferredSize(this.getSize());
}

代码示例来源:origin: yannrichet/jmathplot

protected void initSize() {
  if (scrollPane != null) {
    scrollPane.setSize(this.getSize());
  }
  // scrollPane.setPreferredSize(this.getSize());
}

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

final JScrollPane scrollEditor = new JScrollPane(editor, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
final JSplitPane innerPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, scrollEditor, scrollPreview);

innerPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {

            editor.setSize(innerPane.getLeftComponent().getBounds().width, editor.getHeight() - 10); // If you want more edge space make 10 to 15 or 20
            scrollEditor.setSize(innerPane.getLeftComponent().getBounds().width, editor.getHeight());

          }
        });

代码示例来源:origin: io.snappydata/gemfire-hydra-tests

@Override
  public void componentResized(ComponentEvent e) {
    Component source =e.getComponent();
    scroller.setSize(source.getSize());
    scroller.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: stackoverflow.com

// the panel
 JPanel buttonPanel = new JPanel();
 buttonPanel.setLayout(new GridBagLayout());
 buttonPanel.setSize(new Dimension(400, 300)); // whatever
 // the scrollpane
 JScrollPane pane = new JScrollPane();
 pane.setSize(new Dimension(400, 300)); // whatever
 // GridBagConstraint for button
 GridBagConstraints constraint = new GridBagConstraints();
 constraint.anchor = GridBagConstraints.CENTER;
 constraint.fill = GridBagConstraints.NONE;
 constraint.gridx = 0;
 constraint.gridy = GridBagConstraints.RELATIVE;
 constraint.weightx = 1.0f;
 constraint.weighty = 1.0f;
 int sizeOfButtons = 50;
 for(int i = 0; i < sizeOfButtons; i++) {
   JButton button = new JButton();
   button.setText("Button #" + i);
   // other attributes you will set
   buttonPanel.add(button, constraint);
 }
 pane.setViewportView(buttonPanel);
 this.rootPane.add(pane); // or other panel etc.
 pane.updateUI();

代码示例来源:origin: org.owasp.jbrofuzz/jbrofuzz

private JComponent createCode() {
  final JLabel codeLabel = new JLabel(ImageCreator.IMG_OWASP);
  codeLabel.setLocation(20, 45);
  codeLabel.setSize(100, 100);
  final URL codeURL = ClassLoader.getSystemClassLoader()
  .getResource("LICENSE/CODE.txt");
  JEditorPane code; 
  try {
    code = new JEditorPane(codeURL);
    
  } catch (final IOException eAbout) {
    code = new JEditorPane();
    code.setText("Code information cannot be found!");
  }
  code.setEditable(false);
  code.addKeyListener(this);
  
  final JScrollPane codeScroll = new JScrollPane(code);
  codeScroll.setVerticalScrollBarPolicy(20);
  codeScroll.setHorizontalScrollBarPolicy(30);
  codeScroll.setLocation(140, 5);
  codeScroll.setSize(290, 185);
  
  final JPanel codePanel = new JPanel();
  codePanel.setLayout(null);
  codePanel.add(codeLabel);
  codePanel.add(codeScroll);
  return codePanel;
}

代码示例来源:origin: org.owasp.jbrofuzz/jbrofuzz

disclaimerScroll.setHorizontalScrollBarPolicy(30);
disclaimerScroll.setLocation(140, 5);
disclaimerScroll.setSize(290, 185);

代码示例来源:origin: com.github.yannrichet/JMathPlot

private void draw() {
  JPanel panel = new JPanel();
  GridBagLayout gbl = new GridBagLayout();
  GridBagConstraints c = new GridBagConstraints();
  panel.setLayout(gbl);
  for (int i = 0; i < paramLabels.length; i++) {
    fields[i].addActionListener(this);
    // Ajout du panel de la chaine
    buildConstraints(c, 0, i, 1, 1, 50, 20);
    c.anchor = GridBagConstraints.EAST;
    gbl.setConstraints(labels[i], c);
    panel.add(labels[i]);
    // Ajout du panel de la chaine
    buildConstraints(c, 1, i, 1, 1, 50, 20);
    c.fill = GridBagConstraints.HORIZONTAL;
    gbl.setConstraints(fields[i], c);
    panel.add(fields[i]);
  }
  JScrollPane scrollPane = new JScrollPane(panel);
  scrollPane.setPreferredSize(getSize());
  scrollPane.setSize(getSize());
  setLayout(new BorderLayout());
  add(scrollPane, BorderLayout.CENTER);
}

代码示例来源:origin: yannrichet/jmathplot

private void draw() {
  JPanel panel = new JPanel();
  GridBagLayout gbl = new GridBagLayout();
  GridBagConstraints c = new GridBagConstraints();
  panel.setLayout(gbl);
  for (int i = 0; i < paramLabels.length; i++) {
    fields[i].addActionListener(this);
    // Ajout du panel de la chaine
    buildConstraints(c, 0, i, 1, 1, 50, 20);
    c.anchor = GridBagConstraints.EAST;
    gbl.setConstraints(labels[i], c);
    panel.add(labels[i]);
    // Ajout du panel de la chaine
    buildConstraints(c, 1, i, 1, 1, 50, 20);
    c.fill = GridBagConstraints.HORIZONTAL;
    gbl.setConstraints(fields[i], c);
    panel.add(fields[i]);
  }
  JScrollPane scrollPane = new JScrollPane(panel);
  scrollPane.setPreferredSize(getSize());
  scrollPane.setSize(getSize());
  setLayout(new BorderLayout());
  add(scrollPane, BorderLayout.CENTER);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void setSize(int width, int height){
  int maxWidth = width;
  int maxHeight = height;
  minSize.width = minSizeDefault.width;
  minSize.height = minSizeDefault.height;
  setMinimumSize(minSize);
  
  Dimension ps = getPreferredSize();
  /* Add size of the vertical scrollbar by default. This could be improved
  * to be done only if the height exceeds the bounds. */
  ps.width += scrollBarSize.width;
  ps.width = Math.max(Math.max(ps.width, minSize.width),
            getTitleComponentPreferredSize().width);
  maxWidth = Math.min(maxWidth, maxSize.width);
  maxHeight = Math.min(maxHeight, maxSize.height);
  boolean displayHorizontalScrollbar = (ps.width-scrollBarSize.width)>maxWidth;
  if (ps.width > maxWidth) {
    ps.width = maxWidth;
    if (displayHorizontalScrollbar){
      ps.height += scrollBarSize.height; // will show horizontal scrollbar
      minSize.height += scrollBarSize.height;
      setMinimumSize(minSize);
    }
    
  }
  ps.height = Math.min(Math.max(ps.height, minSize.height), maxHeight);
  super.setSize(ps.width, ps.height);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-deprecated-pre61completion

public void setSize(int width, int height){
  int maxWidth = width;
  int maxHeight = height;
  minSize.width = minSizeDefault.width;
  minSize.height = minSizeDefault.height;
  setMinimumSize(minSize);
  
  Dimension ps = getPreferredSize();
  /* Add size of the vertical scrollbar by default. This could be improved
  * to be done only if the height exceeds the bounds. */
  ps.width += scrollBarSize.width;
  ps.width = Math.max(Math.max(ps.width, minSize.width),
            getTitleComponentPreferredSize().width);
  maxWidth = Math.min(maxWidth, maxSize.width);
  maxHeight = Math.min(maxHeight, maxSize.height);
  boolean displayHorizontalScrollbar = (ps.width-scrollBarSize.width)>maxWidth;
  if (ps.width > maxWidth) {
    ps.width = maxWidth;
    if (displayHorizontalScrollbar){
      ps.height += scrollBarSize.height; // will show horizontal scrollbar
      minSize.height += scrollBarSize.height;
      setMinimumSize(minSize);
    }
    
  }
  ps.height = Math.min(Math.max(ps.height, minSize.height), maxHeight);
  super.setSize(ps.width, ps.height);
}

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

JTree tree;
JScrollPane scrollPane;
DefaultMutableTreeNode root = new DefaultMutableTreeNode("RootNode");

public Tree()
{
  setVisible(true);
  setSize(100, 300);
  createChildNodes(root);
  tree = new JTree(root);
  tree.setVisible(true);
  tree.setSize(100, 300);
  scrollPane = new JScrollPane(tree);
  scrollPane.add(tree);
  scrollPane.setVisible(true);
  scrollPane.setSize(100, 300);
  scrollPane.setViewportView(this);
  scrollPane.setBackground(Color.red);
}

代码示例来源:origin: featurecat/lizzie

/**
 * Create comment cached image
 *
 * @param forceRefresh
 * @param w
 * @param h
 */
public void createCommentImage(boolean forceRefresh, int w, int h) {
 if (forceRefresh || scrollPane.getWidth() != w || scrollPane.getHeight() != h) {
  if (w > 0 && h > 0) {
   scrollPane.setSize(w, h);
   cachedCommentImage =
     new BufferedImage(scrollPane.getWidth(), scrollPane.getHeight(), TYPE_INT_ARGB);
   Graphics2D g2 = cachedCommentImage.createGraphics();
   scrollPane.doLayout();
   scrollPane.validate();
   scrollPane.printAll(g2);
   g2.dispose();
  }
 }
}

代码示例来源:origin: antlr/antlrworks

public void resize() {
  int height = tipsList.getFixedCellHeight();
  int size = tipsModel.size();
  if(size > 0) {
    int width = 0;
    for(int i=0; i<tipsModel.size(); i++) {
      String e = (String)tipsModel.getElementAt(i);
      TextLayout layout = new TextLayout(e, tipsList.getFont(), ((Graphics2D)tipsList.getGraphics()).getFontRenderContext());
      width = Math.max(width, (int)layout.getBounds().getWidth());
    }
    height = height*Math.min(VISIBLE_TIPS, size)+5;
    Dimension d = new Dimension(width+10, height);
    setSize(d);
    tipsList.setSize(d);
    tipsScrollPane.setSize(d);
  }
}

代码示例来源:origin: net.java.abeille/abeille

/** @param parent */
public void layoutContainer(Container parent) {
  Dimension margin_sz = m_colmargin.getPreferredSize();
  Insets insets = parent.getInsets();
  int colm_x = insets.left + margin_sz.width;
  int colm_y = insets.top;
  int colm_width = parent.getWidth() - insets.right - colm_x;
  int colm_height = margin_sz.height;
  int rowm_x = insets.left;
  int rowm_y = insets.top + margin_sz.height;
  int rowm_width = margin_sz.width;
  int rowm_height = parent.getHeight() - insets.bottom - rowm_y;
  m_scroll.setLocation(colm_x, rowm_y);
  m_scroll.setSize(colm_width, rowm_height);
  m_colmargin.setLocation(colm_x, colm_y);
  m_colmargin.setSize(colm_width, colm_height);
  m_rowmargin.setLocation(rowm_x, rowm_y);
  m_rowmargin.setSize(rowm_width, rowm_height);
}

相关文章

JScrollPane类方法