下面列出了javax.swing.JScrollPane#createHorizontalScrollBar ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Constructor GridTableFrame
* @param griddata
*/
public GridTableFrame(GridData griddata) {
setTitle("Grid-Data Table"); //$NON-NLS-1$
setSize(400, 300);
this.griddata = griddata;
int n = griddata.getComponentCount();
tables = new GridDataTable[n];
for(int i = 0; i<n; i++) {
tables[i] = new GridDataTable(griddata, i);
JScrollPane scrollpane = new JScrollPane(tables[i]);
scrollpane.createHorizontalScrollBar();
if(n==1) {
getContentPane().add(scrollpane, BorderLayout.CENTER);
return;
}
tabbedPane.addTab(griddata.getComponentName(i), scrollpane);
}
getContentPane().add(tabbedPane, BorderLayout.CENTER);
}
private void createGUI() {
setSize(400, 300);
setContentPane(new JPanel(new BorderLayout()));
JScrollPane scrollpane = new JScrollPane(table);
scrollpane.createHorizontalScrollBar();
getContentPane().add(scrollpane, BorderLayout.CENTER);
if(!JDialog.isDefaultLookAndFeelDecorated()) {
return;
}
JPanel panel = new JPanel(new FlowLayout());
JButton closeButton = new JButton(ControlsRes.getString("OSPTableInspector.OK")); //$NON-NLS-1$
panel.add(closeButton);
getContentPane().add(panel, BorderLayout.SOUTH);
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
}
});
}
/**
* Sets the XMLTable.
*
* @return the table
*/
public void setTable(XMLTable xmlTable) {
if(table!=null) {
table.removePropertyChangeListener("cell", this); //$NON-NLS-1$
table.removePropertyChangeListener("tableData", this); //$NON-NLS-1$
xmlTable.setEditable(table.isEditable());
}
table = xmlTable;
// listen for "cell" changes in arrays
table.addPropertyChangeListener("cell", this); //$NON-NLS-1$
// listen for "tableData" changes in the table
table.addPropertyChangeListener("tableData", this); //$NON-NLS-1$
JScrollPane scrollpane = new JScrollPane(table);
scrollpane.createHorizontalScrollBar();
getContentPane().add(scrollpane, BorderLayout.CENTER);
}
/**
* Creates the GUI.
*/
protected void createGUI() {
this.removeAll(); // remove old elements Paco: be careful with this. If you use the ArrayPanel as a normal JPanel
// and have added another component, it will be lost!
this.setPreferredSize(new Dimension(400, 300));
this.setLayout(new BorderLayout());
scrollpane = new JScrollPane(tables[0]);
if(tables.length>1) {
// create spinner
SpinnerModel model = new SpinnerNumberModel(0, 0, tables.length-1, 1);
spinner = new JSpinner(model);
JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner);
editor.getTextField().setFont(tables[0].indexRenderer.getFont());
spinner.setEditor(editor);
spinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int i = ((Integer) spinner.getValue()).intValue();
scrollpane.setViewportView(tables[i]);
}
});
Dimension dim = spinner.getMinimumSize();
spinner.setMaximumSize(dim);
add(scrollpane, BorderLayout.CENTER);
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
toolbar.add(new JLabel(" index ")); //$NON-NLS-1$
toolbar.add(spinner);
toolbar.add(Box.createHorizontalGlue());
add(toolbar, BorderLayout.NORTH);
} else {
scrollpane.createHorizontalScrollBar();
add(scrollpane, BorderLayout.CENTER);
}
this.validate(); // refresh the display
}
/**
* Creates the GUI.
*/
protected void createGUI() {
setSize(400, 300);
setContentPane(new JPanel(new BorderLayout()));
scrollpane = new JScrollPane(tables[0]);
if(tables.length>1) {
// create spinner
SpinnerModel model = new SpinnerNumberModel(0, 0, tables.length-1, 1);
spinner = new JSpinner(model);
JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner);
editor.getTextField().setFont(tables[0].getFont());
spinner.setEditor(editor);
spinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int i = ((Integer) spinner.getValue()).intValue();
scrollpane.setViewportView(tables[i]);
}
});
Dimension dim = spinner.getMinimumSize();
spinner.setMaximumSize(dim);
getContentPane().add(scrollpane, BorderLayout.CENTER);
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
toolbar.add(new JLabel(" index ")); //$NON-NLS-1$
toolbar.add(spinner);
toolbar.add(Box.createHorizontalGlue());
getContentPane().add(toolbar, BorderLayout.NORTH);
} else {
scrollpane.createHorizontalScrollBar();
getContentPane().add(scrollpane, BorderLayout.CENTER);
}
}