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

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

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

JScrollPane.setViewportView介绍

暂无

代码示例

代码示例来源:origin: alibaba/druid

@Override
  protected void tableDataProcess(ArrayList<LinkedHashMap<String, Object>> data) {
    ColumnData columnData = TableDataProcessor.multiRow2Col(data, KEY_WORD_IDENTITY);
    contentPanel = new JPanel(new GridLayout(0, 1));
    addTable(columnData);

    scrollPane.setViewportView(contentPanel);
  }
}

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

JScrollPane scrollPane = new JScrollPane();
...

JTable table = new JTable();
scrollPane.setViewportView(table);

代码示例来源:origin: alibaba/druid

/**
 * 将各个界面添加到JFrame中
 * 
 * @param pane JFrame内部的Container对象
 */
private void addComponentsToPane(Container pane) {
  JScrollPane scrollPane = new JScrollPane();
  JPanel contentPanel = new JPanel();
  contentPanel.setLayout(new GridLayout(0, 1));
  final JTextArea sqlField = new JTextArea(formatSql, 8, 20);
  final JScrollPane content1 = new JScrollPane(sqlField);
  content1.setBorder((TitledBorder) BorderFactory.createTitledBorder("SQL语句"));
  contentPanel.add(content1);
  addTable(contentPanel, "解析信息", parseData);
  addTable(contentPanel, "上次慢查询信息", lastSlowData);
  addTable(contentPanel, "上次错误查询信息", lastErrorData);
  addTable(contentPanel, "其他信息", otherData);
  scrollPane.setViewportView(contentPanel);
  pane.add(scrollPane, BorderLayout.CENTER);
}

代码示例来源:origin: SonarSource/sonarqube

componentDetailsTab.setViewportView(componentEditor);
sourceTab.setViewportView(sourceEditor);
highlightingTab.setViewportView(highlightingEditor);
symbolTab.setViewportView(symbolEditor);
coverageTab.setViewportView(coverageEditor);
duplicationTab.setViewportView(duplicationEditor);
testsTab.setViewportView(testsEditor);
issuesTab.setViewportView(issuesEditor);
externalIssuesTab.setViewportView(externalIssuesEditor);
measuresTab.setViewportView(measuresEditor);
scmTab.setViewportView(scmEditor);
activeRuleTab.setViewportView(activeRuleEditor);
adHocRuleTab.setViewportView(adHocRuleEditor);
qualityProfileTab.setViewportView(qualityProfileEditor);
pluginTab.setViewportView(pluginEditor);

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

topPanel = new JPanel();         // our top component
bottomPanel = new JPanel();      // our bottom component
scrollPane = new JScrollPane();  // this scrollPane is used to make the text area scrollable
textArea = new JTextArea();      // this text area will be put inside the scrollPane
inputPanel = new JPanel();
textField = new JTextField();    // first the input field where the user can type his text
button = new JButton("send");    // and a button at the right, to send the text
getContentPane().add(splitPane);               // due to the GridLayout, our splitPane will now fill the whole window
scrollPane.setViewportView(textArea);       // the scrollPane should make the textArea scrollable, so we define the viewport
pack();   // calling pack() at the end, will ensure that every layout and size we just defined gets applied before the stuff becomes visible
  @Override
  public void run(){
    new MyFrame().setVisible(true);

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

regionSelectDialog = new JDialog(editor, "Pick regions", true);
regionPickerPanel = new RegionPickerPanel(this);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(regionPickerPanel);
regionSelectDialog.setContentPane(scrollPane);
regionSelectDialog.setDefaultCloseOperation( JDialog.HIDE_ON_CLOSE);
addContent(0, 0, pickButton = new JButton("Pick Regions"), false, GridBagConstraints.WEST, GridBagConstraints.NONE);

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

list.setCellRenderer(renderer);
jScrollPane1 = new JScrollPane();
jScrollPane1.setViewportView(list);
jScrollPane1.setBounds(10, 150, 635, 330);
add(jScrollPane1);

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

jPanel_SpeakerWindow = new javax.swing.JPanel();
jTextPane_PromptDisplay = new javax.swing.JTextPane();
jLabel_SessionStatus = new javax.swing.JLabel();
jLabel_PromptCount = new javax.swing.JLabel();
jLabel_PromptTotal = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane_nextSentence = new javax.swing.JTextPane();
jTextPane_nextSentence
    .setText("This is a long and boring test sentence, the only purpose of which is to see how to break between lines without making any difference across the windows.");
jScrollPane1.setViewportView(jTextPane_nextSentence);

代码示例来源:origin: CallForSanity/Gaalop

@Override
  public void actionPerformed(ActionEvent e) {
    JFrame frame = new JFrame("Gaalop - Rendering equations");
    frame.setLayout(new BorderLayout(5,5));
    frame.setSize(500, 500);
    JScrollPane pane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    frame.add(pane, BorderLayout.CENTER);
    JTextArea area = new JTextArea(getDisplayEquationsAsString());
    area.setLineWrap(true);
    area.setEditable(false);
    pane.setViewportView(area);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    JButton buttonCopy = new JButton("Copy content to clipboard");
    frame.add(buttonCopy, BorderLayout.SOUTH);
    buttonCopy.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents( new StringSelection(getDisplayEquationsAsString()), null );
      }
    });
  }
});

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

public static void main(String[] args) {
  StringBuilder sb = new StringBuilder();
  Locale[] locales = Locale.getAvailableLocales();
  for (int i = 0; i < locales.length; i++) {
    sb.append(locales[i].getDisplayCountry()).append(' ');
  }

  JTextArea textArea = new JTextArea(sb.toString());
  textArea.setLineWrap(true);
  textArea.setWrapStyleWord(true);

  JScrollPane scrollPane = new JScrollPane();
  scrollPane.setViewportView(textArea);

  JFrame frame = new JFrame("All installed locales");
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.add(scrollPane);
  frame.pack();
  frame.setVisible(true);
}

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

public void addChild (Component parent, Component child) {
  if (parent instanceof JScrollPane)
    ((JScrollPane)parent).setViewportView(child);
  else
    ((Container)parent).add(child);
}

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

jTable1.setFont(new Font("Arial", Font.BOLD, 12));
jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JScrollPane sp1 = new JScrollPane();
sp1.setPreferredSize(new Dimension(600, 200));
sp1.setViewportView(jTable1);
final JTable jTable2 = new JTable(model1);
jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JScrollPane sp2 = new JScrollPane();
sp2.setPreferredSize(new Dimension(600, 200));
sp2.setViewportView(jTable2);
final JTable jTable3 = new TableBackroundPaint0(data1, headers);
jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable3.setModel(model1);
final JScrollPane sp3 = new JScrollPane();
sp3.setPreferredSize(new Dimension(600, 200));
sp3.setViewportView(jTable3);
JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayout(3, 0, 10, 10));
panel1.add(sp1);
panel1.add(sp2);
panel1.add(sp3);
JFrame frame = new JFrame("tableSelection");
frame.add(panel1);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

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

private void initializeComponents () {
  setLayout(new GridBagLayout());
    JPanel sideButtons = new JPanel(new GridBagLayout());
    add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 0, 0, 0), 0, 0));
      JButton newButton = new JButton("New");
      sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER,
        GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
      JButton newButton = new JButton("Duplicate");
      sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER,
        GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
      JButton deleteButton = new JButton("Delete");
      sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER,
        GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
    JScrollPane scroll = new JScrollPane();
    add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,
      0, 0, 6), 0, 0));
      emitterTable.getTableHeader().setReorderingAllowed(false);
      emitterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      scroll.setViewportView(emitterTable);
      emitterTableModel = new DefaultTableModel(new String[0][0], new String[] {"Emitter", ""});
      emitterTable.setModel(emitterTableModel);

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

final JScrollPane scrollPane = new JScrollPane();
JButton cornerButton = new JButton("#");
scrollPane.setCorner(JScrollPane.UPPER_TRAILING_CORNER, cornerButton);
JPanel column = new JPanel();
column.setPreferredSize( new Dimension(100, cornerButton.getPreferredSize().height) );
scrollPane.setColumnHeaderView( column );
JPanel view = new JPanel();
view.setPreferredSize( new Dimension(100, 100) );
scrollPane.setViewportView( view );
    frame.add(scrollPane);
    frame.pack();
    frame.setVisible(true);

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

regionSelectDialog = new JDialog(editor, "Pick regions", true);
regionPickerPanel = new RegionPickerPanel(this);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(regionPickerPanel);
regionSelectDialog.setContentPane(scrollPane);
regionSelectDialog.setDefaultCloseOperation( JDialog.HIDE_ON_CLOSE);
addContent(0, 0, pickButton = new JButton("Pick Regions"), false, GridBagConstraints.WEST, GridBagConstraints.NONE);

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

jScrollPane1 = new JScrollPane();
tree = new Tree(this);
jScrollPane2 = new JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane1.setViewportView(tree);
jScrollPane2.setViewportView(jTextPane1);
JScrollPane documentScroller = new JScrollPane();
documentScroller.setViewportView(documentPanel);
getContentPane().add(statusPane.getPanel(), BorderLayout.PAGE_START);
getContentPane().add(jSplitPane1, BorderLayout.CENTER);
getContentPane().add(statusBar, BorderLayout.SOUTH);

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

private void initUI(DeviceNColorant[] colorants)
{
  panel = new JPanel();
  panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
  panel.setPreferredSize(new Dimension(300, 500));
  JLabel colorSpaceLabel = new JLabel("DeviceN colorspace");
  colorSpaceLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
  colorSpaceLabel.setFont(new Font(Font.MONOSPACED, Font.BOLD, 30));
  DeviceNTableModel tableModel = new DeviceNTableModel(colorants);
  JTable table = new JTable(tableModel);
  table.setDefaultRenderer(Color.class, new ColorBarCellRenderer());
  table.setRowHeight(60);
  JScrollPane scrollPane = new JScrollPane();
  scrollPane.setViewportView(table);
  panel.add(colorSpaceLabel);
  panel.add(scrollPane);
}

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

JScrollPane scrollPane = new JScrollPane();
JList list = new JList();
scrollPane.setViewportView(list);

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

String [][] data = new String[][]{{"Test11", "Test12", "Test13", "Test14"},
      {"Test21", "Test22", "Test23", "Test24"},
      {"Test31", "Test32", "Test33", "Test34"}};
String[] columnName = new String[] {"Column1", "Column2", "Column3", "Column3"};

private void createDataTable(String[][] data, String[] columnName){
  JFrame frame = new JFrame();
  JScrollPane scrollPane = new JScrollPane();

  JTable table = new JTable(data, columnName);
  scrollPane.setViewportView(table);
  frame.add(scrollPane);

  frame.setSize(800, 800);
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.setVisible(true);

}

public String[][] getTableData (JTable table) {
  TableModel dtm = table.getModel();
  int nRow = dtm.getRowCount(), nCol = dtm.getColumnCount();
  String[][] tableData = new String[nRow][nCol];
  for (int i = 0 ; i < nRow ; i++)
    for (int j = 0 ; j < nCol ; j++)
      tableData[i][j] = dtm.getValueAt(i,j).toString();
  return tableData;
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Remove all trees from the display
 */
public void clearMatches() {
 JPanel spaceholder = new JPanel();
 spaceholder.setBackground(Color.white);
 scroller.setViewportView(spaceholder);
 scroller.validate();
 scroller.repaint();
 matchedPartCoordinates = null;
 matchedPartCoordinateIdx = -1;
}

相关文章

JScrollPane类方法