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

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

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

JScrollPane.setHorizontalScrollBarPolicy介绍

暂无

代码示例

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

private JPanel createXPathQueryPanel() {
  JPanel p = new JPanel();
  p.setLayout(new BorderLayout());
  xpathQueryArea.setBorder(BorderFactory.createLineBorder(Color.black));
  makeTextComponentUndoable(xpathQueryArea);
  JScrollPane scrollPane = new JScrollPane(xpathQueryArea);
  scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
  final JButton b = createGoButton();
  JPanel topPanel = new JPanel();
  topPanel.setLayout(new BorderLayout());
  topPanel.add(new JLabel("XPath Query (if any):"), BorderLayout.WEST);
  topPanel.add(createXPathVersionPanel(), BorderLayout.EAST);
  p.add(topPanel, BorderLayout.NORTH);
  p.add(scrollPane, BorderLayout.CENTER);
  p.add(b, BorderLayout.SOUTH);
  return p;
}

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

protected PluginPanel(boolean wrap)
{
  super();
  if (wrap)
  {
    setBorder(BORDER_PADDING);
    setLayout(new DynamicGridLayout(0, 1, 0, 3));
    setBackground(ColorScheme.DARK_GRAY_COLOR);
    final JPanel northPanel = new JPanel();
    northPanel.setLayout(new BorderLayout());
    northPanel.add(this, BorderLayout.NORTH);
    northPanel.setBackground(ColorScheme.DARK_GRAY_COLOR);
    scrollPane = new JScrollPane(northPanel);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    wrappedPanel = new JPanel();
    // Adjust the preferred size to expand to width of scrollbar to
    // to preven scrollbar overlapping over contents
    wrappedPanel.setPreferredSize(OUTER_PREFERRED_SIZE);
    wrappedPanel.setLayout(new BorderLayout());
    wrappedPanel.add(scrollPane, BorderLayout.CENTER);
  }
  else
  {
    scrollPane = null;
    wrappedPanel = this;
  }
}

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

final JScrollPane scroller = new JScrollPane(drawingPane);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
final TimeAxis timeAxis =
  new TimeAxis(TimeAxis.VERTICAL, sequenceDiagram.getMinTime(), sequenceDiagram.getMaxTime());

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

editorPane
    .setText("<html>Some long text that cannot hold on a single line if the screen is too small</html>");
JScrollPane scrollPane = new JScrollPane(editorPane);
scrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
frame.add(scrollPane);
frame.setSize(200, 400);
frame.setVisible(true);

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

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
  jScrollPane1 = new javax.swing.JScrollPane();
  text = new javax.swing.JTextPane();
  setMinimumSize(getPreferredSize());
  setOpaque(false);
  setPreferredSize(new Dimension(dimension.frameWidth, dimension.frameHeight));
  setLayout(null);
  jScrollPane1.setBorder(null);
  jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  jScrollPane1.setFocusable(false);
  jScrollPane1.setOpaque(false);
  text.setBorder(null);
  text.setEditable(false);
  text.setFont(new java.awt.Font("Arial", 0, 9));
  text.setFocusable(false);
  text.setOpaque(false);
  jScrollPane1.setViewportView(text);
  add(jScrollPane1);
  jScrollPane1.setBounds(20, 110, 130, 100);
  jScrollPane1.setBounds(new Rectangle(dimension.contentXOffset, dimension.textYOffset, dimension.textWidth, dimension.textHeight));
}// </editor-fold>//GEN-END:initComponents

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

public void init() {
  //JFrame frame = new JFrame(); 

  JPanel panel = new JPanel(); 
  JScrollPane scrPane = new JScrollPane(panel); 
  scrPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  scrPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  //  scrPane.setLayout(new ScrollPaneLayout()); 
  //  frame.getContentPane().add(scrPane); 

  getContentPane().add(scrPane);

  // this.setVisible(true); 
}

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

JPanel internalPanel = new JPanel();
internalPanel.setBorder(...);
internalPanel.add(...);
JScrollPane scrollPane = new JScrollPane( internalPanel );
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

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

public class ScrollListExample {
  static List<String> stringList = new ArrayList<String>();
  static {
    for (int i = 0; i < 500; i++) {
      stringList.add("test" + i);
    }
  }

  public static void main(final String[] args) {
    final JFrame frame = new JFrame();
    final Container contentPane = frame.getContentPane();
    final JList list = new JList(stringList.toArray());
    final JScrollPane scrollPane = new JScrollPane(list);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    contentPane.add(scrollPane);
    frame.setPreferredSize(new Dimension(200,200));
    frame.pack();
    frame.setVisible(true);
  }
}

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

layeredPane.setLayer(this.horizontalScrollBar, JLayeredPane.PALETTE_LAYER);
this.scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
this.scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
this.scrollPane.setLayout(new ScrollPaneLayout() {
  @Override

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

JPanel fontPanel = new JPanel();
  leftSidePanel.add(fontPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
    GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    JScrollPane fontScroll = new JScrollPane();
    fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
      GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    unicodePanel = new JPanel(new GridBagLayout());
    fontPanel.add(unicodePanel, new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0, GridBagConstraints.EAST,
      GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
  samplePanel.setBorder(BorderFactory.createTitledBorder("Sample Text"));
    JScrollPane textScroll = new JScrollPane();
    samplePanel.add(textScroll, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
      GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,
  GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
  effectsPanel.setMinimumSize(new Dimension(210, 1));
      GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
    appliedEffectsScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
    appliedEffectsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

代码示例来源:origin: opentripplanner/OpenTripPlanner

private Container makeDiffTab() {
  JPanel pane = new JPanel();
  pane.setLayout(new GridLayout(0, 2));
  JScrollPane stScrollPane = new JScrollPane(firstComparePathStates);
  stScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  pane.add(stScrollPane);
  firstComparePathStates.addListSelectionListener(new ComparePathStatesClickListener(firstStateData));
  stScrollPane = new JScrollPane(secondComparePathStates);
  stScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  pane.add(stScrollPane);
  secondComparePathStates.addListSelectionListener(new ComparePathStatesClickListener(secondStateData));
  stScrollPane = new JScrollPane(firstStateData);
  stScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  pane.add(stScrollPane);
  stScrollPane = new JScrollPane(secondStateData);
  stScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  pane.add(stScrollPane);

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

jScrollPane2 = new JScrollPane();
jScrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

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

private void initComponents() {
  scrollView = new JScrollPane();
  choiceRanks = new javax.swing.JComboBox<String>();
  ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.NewRecruitDialog", new EncodeControl());
  setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  setTitle(resourceMap.getString("Form.title")); // NOI18N
  if (newHire) {
    setTitle(resourceMap.getString("Form.title.new")); // NOI18N
  }
  setName("Form"); // NOI18N
  getContentPane().setLayout(new java.awt.BorderLayout());
  JPanel panSidebar = createSidebar(resourceMap);
  JPanel panBottomButtons = createButtonPanel(resourceMap);
  scrollView.setMinimumSize(new java.awt.Dimension(450, 180));
  scrollView.setPreferredSize(new java.awt.Dimension(450, 180));
  scrollView.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  scrollView.setViewportView(null);
  refreshView();
  getContentPane().add(panSidebar, BorderLayout.LINE_START);
  getContentPane().add(scrollView, BorderLayout.CENTER);
  getContentPane().add(panBottomButtons, BorderLayout.PAGE_END);
  pack();
}

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

/**
 * This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
  scrollPane = new javax.swing.JScrollPane();
  text = new javax.swing.JTextPane();
  setFocusable(false);
  setMinimumSize(new Dimension(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT));
  setName("bigCardPanel"); // NOI18N
  setOpaque(false);
  setPreferredSize(getMinimumSize());
  setLayout(null);
  scrollPane.setBorder(null);
  scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  scrollPane.setOpaque(false);
  text.setEditable(false);
  text.setFocusable(false);
  text.setOpaque(false);
  scrollPane.setViewportView(text);
  add(scrollPane);
  scrollPane.setBounds(20, 230, 210, 120);
  scrollPane.setBounds(new Rectangle(CONTENT_MAX_XOFFSET, TEXT_MAX_YOFFSET, TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT));
}// </editor-fold>//GEN-END:initComponents

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

JFrame frame = new JFrame();
JPanel panel = new JPanel();

// add something to you panel...
// panel.add(...);

// add the panel to a JScrollPane
JScrollPane jScrollPane = new JScrollPane(panel);
// only a configuration to the jScrollPane...
jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

// Then, add the jScrollPane to your frame
frame.getContentPane().add(jScrollPane);

代码示例来源:origin: net.sf.ingenias/editor

private void jbInit() throws Exception {
 box1 = Box.createVerticalBox();
 this.getContentPane().setLayout(borderLayout1);
 close.setText("Close");
 close.addActionListener(new CellHelpWindow_close_actionAdapter(this));
 jLabel1.setText("Recommendation");
 jLabel2.setText("Description");
 jPanel1.setLayout(borderLayout2);
 jPanel2.setLayout(borderLayout3);
 description.setText("jTextPane1");
 description.setContentType("text/html");
 scp1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 scp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
 scp1.setToolTipText("");
 recom.setText("");
 recom.setContentType("text/html");
 this.getContentPane().add(box1, BorderLayout.CENTER);
 box1.add(jPanel1, null);
 box1.add(jPanel2, null);
 this.getContentPane().add(jPanel3,  BorderLayout.SOUTH);
 jPanel3.add(close, null);
 jPanel2.add(jLabel1,  BorderLayout.NORTH);
 jPanel2.add(scp2, BorderLayout.CENTER);
 scp2.getViewport().add(recom, null);
 jPanel2.add(scp2,  BorderLayout.CENTER);
 jPanel1.add(jLabel2, BorderLayout.NORTH);
 jPanel1.add(scp1,  BorderLayout.CENTER);
 scp1.getViewport().add(description, null);
}

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

container.setSize(1800, 1500);
 container.setVisible(true);
 container.setPreferredSize(new Dimension(900, 900));
 JScrollPane scrollPane = new JScrollPane(container);  
 scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);  
 scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);  
 add(scrollPane);

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

JPanel fontPanel = new JPanel();
  leftSidePanel.add(fontPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
    GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    JScrollPane fontScroll = new JScrollPane();
    fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
      GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    unicodePanel = new JPanel(new GridBagLayout());
    fontPanel.add(unicodePanel, new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0, GridBagConstraints.EAST,
      GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
  samplePanel.setBorder(BorderFactory.createTitledBorder("Sample Text"));
    JScrollPane textScroll = new JScrollPane();
    samplePanel.add(textScroll, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
      GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,
  GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
  effectsPanel.setMinimumSize(new Dimension(210, 1));
      GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
    appliedEffectsScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
    appliedEffectsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

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

setBackground(ColorScheme.DARK_GRAY_COLOR);
topPanel = new JPanel();
topPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
topPanel.setLayout(new BorderLayout(0, OFFSET));
northPanel.add(mainPanel, BorderLayout.NORTH);
scrollPane = new JScrollPane(northPanel);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
add(scrollPane, BorderLayout.CENTER);

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

import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class Main {
 public static void main(String[] argv) throws Exception {
  JTextArea textArea = new JTextArea();
  JScrollPane pane = new JScrollPane(textArea);
  pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

 }
}

相关文章

JScrollPane类方法