本文整理汇总了Java中javax.swing.JScrollPane.setVerticalScrollBarPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java JScrollPane.setVerticalScrollBarPolicy方法的具体用法?Java JScrollPane.setVerticalScrollBarPolicy怎么用?Java JScrollPane.setVerticalScrollBarPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JScrollPane
的用法示例。
在下文中一共展示了JScrollPane.setVerticalScrollBarPolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Initialize the contents of the frame.
*/
public void initialize(){
JPanel panel_7 = new JPanel();
panel_7.setBounds(0, 0, 665, 415);
frmPiattaformaGaming.getContentPane().add(panel_7);
panel_7.setLayout(new MigLayout());
panel_7.setVisible(true);
JTextArea ta = new JTextArea();
ta.setEditable(false);
panel_7.add(ta);
ArrayList<Recensione> al = new GiocoController(gioco).allReviews();
for( Recensione r : al ){
ta.setText(ta.getText() + " - " + r.getTesto() + "\n\n");
}
JButton btnBack = new JButton("Indietro");
panel_7.add(btnBack, "pos 267px 345px, width 110, height 15");
JScrollPane scroll = new JScrollPane(ta);
scroll.setVerticalScrollBarPolicy ( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
scroll.getVerticalScrollBar().setUnitIncrement(20);
scroll.setSize(460,240);
panel_7.add(scroll, "pos 0px 0px, width 660, height 340");
btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
panel_7.setVisible(false);
new GiocoView(frmPiattaformaGaming, utente, gioco);
}});
}
示例2: buildAttrListPanel
import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void buildAttrListPanel() {
attrList.setVisibleRowCount(5);
JPanel buttonsPanel = new JPanel();
buttonsPanel.add(eraseAttrButton);
JScrollPane sp = new JScrollPane(attrList);
sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
sp.setPreferredSize(new Dimension(ATTRLIST_WIDTH, ATTRLIST_HEIGHT));
attrListPanel.setBorder(BorderFactory.createTitledBorder(ATTR_LIST_TITLE));
attrListPanel.setLayout(new BorderLayout());
attrListPanel.add(sp, BorderLayout.CENTER);
attrListPanel.add(buttonsPanel, BorderLayout.SOUTH);
eraseAttrButton.addActionListener(new RemoveAttrListener());
}
示例3: addCommitMessageTextArea
import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void addCommitMessageTextArea(GridBagConstraints gbc) {
gbc.insets = new Insets(UIConstants.COMPONENT_TOP_PADDING, UIConstants.COMPONENT_LEFT_PADDING,
UIConstants.COMPONENT_BOTTOM_PADDING, UIConstants.COMPONENT_RIGHT_PADDING);
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.gridwidth = 2;
commitMessage = new JTextArea();
commitMessage.setLineWrap(true);
// Around 3 lines of text.
int fontH = commitMessage.getFontMetrics(commitMessage.getFont()).getHeight();
commitMessage.setWrapStyleWord(true);
JScrollPane scrollPane = new JScrollPane(commitMessage);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setMinimumSize(new Dimension(10, 3 * fontH));
UndoSupportInstaller.installUndoManager(commitMessage);
this.add(scrollPane, gbc);
}
示例4: ShowModifiedFilesDialog
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Private constructor
*/
private ShowModifiedFilesDialog() {
setLayout(new GridBagLayout());
modifiedFiles = new JTextArea(10, 40);
modifiedFiles.setLineWrap(true);
modifiedFiles.setWrapStyleWord(true);
modifiedFiles.setEditable(false);
JScrollPane scroll = new JScrollPane(modifiedFiles);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.LINE_START;
add(scroll , gbc);
}
开发者ID:oxygenxml,项目名称:oxygen-dita-translation-package-builder,代码行数:25,代码来源:ShowModifiedFilesDialog.java
示例5: buildRightPanel
import javax.swing.JScrollPane; //导入方法依赖的package包/类
private void buildRightPanel() {
JPanel tableButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
// Buttons
tableButtonPanel.add(newRowButton);
tableButtonPanel.add(removeRowButton);
JPanel southButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
southButtonPanel.add(insertButton);
selectedTableViewer.add(tableButtonPanel, BorderLayout.NORTH);
selectedTableViewer.add(southButtonPanel, BorderLayout.SOUTH);
JScrollPane contentTablePanelSP = new JScrollPane(selectedTableViewer);
contentTablePanelSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
// Remove ugly borders
contentTablePanelSP.setViewportBorder(null);
JPanel bottomPanel = new JPanel(new BorderLayout());
JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonsPanel.add(doneButton);
bottomPanel.add(buttonsPanel, BorderLayout.SOUTH);
getRightPanel().add(selectedTableViewer, BorderLayout.CENTER);
getRightPanel().add(bottomPanel, BorderLayout.SOUTH);
}
示例6: initComponents
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Set up the panel contents and layout
*/
private void initComponents() {
stTable = new STTable();
/* and now some Box black magic */
Box hBox = Box.createHorizontalBox();
hBox.add(Box.createHorizontalStrut(20));
//Horizontal box containing Description label and buttons
Box descrBox = Box.createVerticalBox();
descrBox.add(new JLabel(DESCRIPTION_SERVICEDEMANDS));
descrBox.add(Box.createHorizontalStrut(10));
descrBox.add(new JButton(SWITCH_TO_ST_V));
descrBox.setPreferredSize(new Dimension(220, 1000));
descrBox.setMinimumSize(new Dimension(200, 200));
hBox.add(descrBox);
hBox.add(Box.createHorizontalStrut(10));
JScrollPane visitTablePane = new JScrollPane(stTable);
visitTablePane.setPreferredSize(new Dimension(1000, 1000));
visitTablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
visitTablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
hBox.add(visitTablePane);
hBox.add(Box.createHorizontalStrut(20));
Box totalBox = Box.createVerticalBox();
totalBox.add(Box.createVerticalStrut(20));
totalBox.add(hBox);
totalBox.add(Box.createVerticalStrut(20));
setLayout(new BorderLayout());
add(totalBox, BorderLayout.CENTER);
}
示例7: Window
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public Window(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
KeyboardListener keyboardListener = new KeyboardListener(this);
addKeyListener(keyboardListener);
addFocusListener(keyboardListener);
setFocusTraversalKeysEnabled(false); //Enables tab clicks to be sent o the keyboard listener
setPreferredSize(new Dimension(900,500));
textArea = new TextArea();
JPanel resizer = new JPanel();
resizer.setBackground(Color.WHITE);
resizer.setLayout(new FlowLayout(FlowLayout.LEFT));
resizer.add(textArea);
JScrollPane scroller = new JScrollPane(resizer);
scroller.setBackground(Color.WHITE);
scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
add(scroller);
pack();
setVisible(true);
textArea.defaultFocus();
updateFocusTracker();
}
示例8: initComponents
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Set up the panel contents and layout
*/
private void initComponents() {
stTable = new STTable();
Box hBox = Box.createHorizontalBox();
hBox.add(Box.createHorizontalStrut(20));
//Horizontal box containing Description label and buttons
Box descrBox = Box.createVerticalBox();
descrBox.add(new JLabel(DESCRIPTION_SERVICETIMES));
descrBox.add(Box.createHorizontalStrut(10));
descrBox.add(new JButton(SWITCH_TO_SD));
descrBox.setPreferredSize(new Dimension(220, 1000));
descrBox.setMinimumSize(new Dimension(200, 200));
hBox.add(descrBox);
hBox.add(Box.createHorizontalStrut(10));
JScrollPane visitTablePane = new JScrollPane(stTable);
visitTablePane.setPreferredSize(new Dimension(1000, 1000));
visitTablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
visitTablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
hBox.add(visitTablePane);
hBox.add(Box.createHorizontalStrut(20));
Box totalBox = Box.createVerticalBox();
totalBox.add(Box.createVerticalStrut(30));
totalBox.add(hBox);
totalBox.add(Box.createVerticalStrut(30));
setLayout(new BorderLayout());
add(totalBox, BorderLayout.CENTER);
}
示例9: initComponents
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Set up the panel contents and layout
*/
private void initComponents() {
visitTable = new VisitTable();
JPanel totalBox = new JPanel(new BorderLayout(10, 10));
//Horizontal box containing Description label and buttons
JLabel descrLabel = new JLabel(DESCRIPTION_VISITS);
JPanel descrBox = new JPanel(new BorderLayout());
descrBox.setPreferredSize(new Dimension(200, 1000));
descrBox.add(descrLabel, BorderLayout.NORTH);
JScrollPane visitTablePane = new JScrollPane(visitTable);
visitTablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
visitTablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
totalBox.add(visitTablePane, BorderLayout.CENTER);
totalBox.add(descrBox, BorderLayout.WEST);
setLayout(new BorderLayout());
add(totalBox, BorderLayout.CENTER);
add(Box.createVerticalStrut(30), BorderLayout.NORTH);
add(Box.createVerticalStrut(30), BorderLayout.SOUTH);
add(Box.createHorizontalStrut(20), BorderLayout.EAST);
add(Box.createHorizontalStrut(20), BorderLayout.WEST);
}
示例10: ErrorsDialog
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public ErrorsDialog(ArrayList<String> errors) {
okButton = new JButton("Ok");
errorsTextArea = new JTextArea();
setLayout(new BorderLayout());
okButton.addActionListener(new OkButtonListener());
errorsTextArea.setEditable(false);
// Showing errors
for (int i = 0; i < errors.size(); i++) {
errorsTextArea.append(" - " + errors.get(i) + "\n");
}
JPanel mainContainer = new JPanel(new BorderLayout());
JPanel messagePanel = new JPanel();
JPanel buttonsPanel = new JPanel();
messagePanel.add(new JLabel(MESSAGE));
JScrollPane errorsPanelSP = new JScrollPane(errorsTextArea);
errorsPanelSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
errorsPanelSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
mainContainer.setBorder(BorderFactory.createEmptyBorder(PADDING_TOP,
PADDING_LEFT, PADDING_BOTTOM, PADDING_RIGHT));
buttonsPanel.add(okButton);
mainContainer.add(messagePanel, BorderLayout.NORTH);
mainContainer.add(errorsPanelSP, BorderLayout.CENTER);
mainContainer.add(buttonsPanel, BorderLayout.SOUTH);
add(mainContainer);
buildWindow();
}
示例11: redraw
import javax.swing.JScrollPane; //导入方法依赖的package包/类
@Override
public void redraw() {
// Redraws only if data has changed - Bertoli Marco
if (!redrawNeeded)
return;
if (data.hasResults() && data.areResultsOK()
&& data.getResults().getSaturationSectors().size() > 0) {
if (data.getClasses() == 2) {
this.removeAll();
s2dp = new Sectors2DGraph(data);
this.setLayout(new BorderLayout());
this.add(new JabaCanvas(s2dp), BorderLayout.CENTER);
this.add(new JLabel(JabaConstants.DESCRIPITION_GRAPH),
BorderLayout.PAGE_END);
repaint();
} else if (data.getClasses() == 3) {
this.removeAll();
Sectors3DGraph s3dp = new Sectors3DGraph(data);
this.setLayout(new BorderLayout());
this.add(new JabaCanvas(s3dp), BorderLayout.CENTER);
this.add(new JLabel(JabaConstants.DESCRIPITION_GRAPH),
BorderLayout.PAGE_END);
repaint();
}
} else {
this.removeAll();
JEditorPane synView = new JTextPane();
synView.setContentType("text/html");
synView.setEditable(false);
JScrollPane synScroll = new JScrollPane(synView);
synScroll
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
synScroll
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
synView.setText("<html><body><center><font face=\"bold\" size=\"3\">Saturation Sectors will be here displayed once you solve the model.</font></center></body></html>");
this.add(synScroll, BorderLayout.CENTER);
}
redrawNeeded = false;
}
示例12: setupGUI
import javax.swing.JScrollPane; //导入方法依赖的package包/类
@SuppressWarnings("nls")
private void setupGUI(Node privNode)
{
JPanel options = createOptions(privNode);
listModel = new LimitedSetListModel();
list = new JList(listModel);
list.setCellRenderer(new ExpressionListCellRenderer(userService)
{
@Override
public String getExpression(Object value)
{
return ((PrivilegeListEntry) value).getWho();
}
});
listScroller = new JScrollPane(list);
listScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
select = new JButton(CurrentLocale.get("com.tle.admin.security.editors.basiceditorpanel.select"));
select.addActionListener(this);
final int height1 = options.getPreferredSize().height;
final int height2 = select.getPreferredSize().height;
final int width1 = select.getPreferredSize().width;
final int[] rows = {height1, TableLayout.FILL, height2,};
final int[] cols = {20, TableLayout.FILL, width1, TableLayout.FILL,};
setLayout(new TableLayout(rows, cols));
add(options, new Rectangle(0, 0, 4, 1));
add(listScroller, new Rectangle(1, 1, 2, 1));
add(select, new Rectangle(2, 2, 1, 1));
}
示例13: Timer
import javax.swing.JScrollPane; //导入方法依赖的package包/类
public Timer() throws IOException
{
super(new BorderLayout());
model = new TimerModel();
table = new TimerTable(model);
openPort = new JLabel("Serial Port Not Connected");
openPort.setHorizontalAlignment(JLabel.CENTER);
MyServerLabel slbl = new MyServerLabel();
openPort.setBorder(BorderFactory.createLoweredBevelBorder());
slbl.setBorder(BorderFactory.createLoweredBevelBorder());
JPanel bottom = new JPanel(new MigLayout("fill, ins 0", "[50%]0[50%]"));
bottom.add(openPort, "grow");
bottom.add(slbl, "grow");
JScrollPane scroll = new JScrollPane(table);
scroll.getViewport().setBackground(Color.WHITE);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
add(controls(), BorderLayout.NORTH);
add(scroll, BorderLayout.CENTER);
add(bottom, BorderLayout.SOUTH);
lights = new ButtonGroup();
serial = null;
try {
server = new TimerServer(Discovery.BWTIMER_TYPE);
model.addRunServerListener(server);
server.start();
} catch (IOException ioe) {
log.log(Level.SEVERE, "\bTimer Server Failed to start: {0}", ioe.getMessage());
}
}
示例14: createExtComponent
import javax.swing.JScrollPane; //导入方法依赖的package包/类
@Override
protected JComponent createExtComponent() {
JTextComponent component = getComponent();
JLayeredPane layers = new LayeredEditorPane(component);
layers.add(component, JLayeredPane.DEFAULT_LAYER, 0);
// MyInternalFrame window = new MyInternalFrame();
// layers.add(window, JLayeredPane.PALETTE_LAYER);
// window.show();
// Add the scroll-pane with the component to the center
JScrollPane scroller = new JScrollPane(layers);
scroller.getViewport().setMinimumSize(new Dimension(4,4));
// remove default scroll-pane border, winsys will handle borders itself
Border empty = BorderFactory.createEmptyBorder();
// Important: Do not delete or use null instead, will cause
//problems on GTK L&F. Must set both scroller border & viewport
//border! - Tim
scroller.setBorder(empty);
scroller.setViewportBorder(empty);
if (component.getClientProperty("nbeditorui.vScrollPolicy") != null) {
scroller.setVerticalScrollBarPolicy(
(Integer)component.getClientProperty("nbeditorui.vScrollPolicy"));
}
if (component.getClientProperty("nbeditorui.hScrollPolicy") != null) {
scroller.setHorizontalScrollBarPolicy(
(Integer)component.getClientProperty("nbeditorui.hScrollPolicy"));
}
// extComponent will be a panel
JComponent ec = new JPanel(new BorderLayout());
ec.putClientProperty(JTextComponent.class, component);
ec.add(scroller);
// Initialize sidebars
// Need to clear the cache - it's null at this point when opening file but the sidebars
// would be reused during L&F change (see BaseTextUI.UIWatcher) which would not work properly.
CustomizableSideBar.resetSideBars(component);
Map<SideBarPosition, JComponent> sideBars = CustomizableSideBar.getSideBars(component);
processSideBars(sideBars, ec, scroller);
if (listener == null){
listener = new SideBarsListener(component);
CustomizableSideBar.addChangeListener(NbEditorUtilities.getMimeType(component), listener);
}
// Initialize the corner component
initGlyphCorner(scroller);
return ec;
}
示例15: initComponents
import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
* Set up the panel contents and layout
*/
private void initComponents() {
stationSpinner.addChangeListener(spinnerListener);
stationTable = new StationTable();
/* and now some Box black magic */
Box stationSpinnerBox = Box.createHorizontalBox();
//OLD
//DEK (Federico Granata) 26-09-2003
//JLabel spinnerLabel = new JLabel("<html><font size=\"4\">Set the number of stations (1-" + MAX_STATIONS + "):</font></html>");
//NEW
//@author Stefano
JLabel spinnerLabel = new JLabel(DESCRIPTION_STATIONS);
//spinnerLabel.setMaximumSize(new Dimension(300, 18));
stationSpinnerBox.add(spinnerLabel);
stationSpinnerBox.add(Box.createHorizontalStrut(10));
Box numberBox = Box.createVerticalBox();
JPanel spinnerPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JLabel numberLabel = new JLabel("Number:");
stationSpinner.setMaximumSize(new Dimension(600, 18));
spinnerPanel.add(numberLabel);
spinnerPanel.add(stationSpinner);
numberBox.add(spinnerPanel);
numberBox.add(new JButton(addStation));
numberBox.setMaximumSize(new Dimension(150, 50));
stationSpinnerBox.add(numberBox);
//END
Box stationBox = Box.createVerticalBox();
stationBox.add(Box.createVerticalStrut(20));
stationBox.add(stationSpinnerBox);
stationBox.add(Box.createVerticalStrut(10));
JScrollPane stationTablePane = new JScrollPane(stationTable);
stationTablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
stationTablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
stationBox.add(stationTablePane);
stationBox.add(Box.createRigidArea(new Dimension(10, 20)));
Box totalBox = Box.createHorizontalBox();
totalBox.add(Box.createHorizontalStrut(20));
totalBox.add(stationBox);
totalBox.add(Box.createHorizontalStrut(20));
setLayout(new BorderLayout());
add(totalBox, BorderLayout.CENTER);
}