use of javax.swing.JScrollBar in project jdk8u_jdk by JetBrains.
the class LWTextAreaPeer method getMinimumSize.
@Override
public Dimension getMinimumSize(final int rows, final int columns) {
final Dimension size = super.getMinimumSize(rows, columns);
synchronized (getDelegateLock()) {
// JScrollPane insets
final Insets pi = getDelegate().getInsets();
size.width += pi.left + pi.right;
size.height += pi.top + pi.bottom;
// Take scrollbars into account.
final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
final JScrollBar vbar = getDelegate().getVerticalScrollBar();
size.width += vbar != null ? vbar.getMinimumSize().width : 0;
}
final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
size.height += hbar != null ? hbar.getMinimumSize().height : 0;
}
}
return size;
}
use of javax.swing.JScrollBar in project jdk8u_jdk by JetBrains.
the class LWScrollBarPeer method initializeImpl.
@Override
void initializeImpl() {
super.initializeImpl();
final Scrollbar target = getTarget();
setLineIncrement(target.getUnitIncrement());
setPageIncrement(target.getBlockIncrement());
setValues(target.getValue(), target.getVisibleAmount(), target.getMinimum(), target.getMaximum());
final int orientation = target.getOrientation();
final JScrollBar delegate = getDelegate();
synchronized (getDelegateLock()) {
delegate.setOrientation(orientation == Scrollbar.HORIZONTAL ? Adjustable.HORIZONTAL : Adjustable.VERTICAL);
delegate.addAdjustmentListener(this);
}
}
use of javax.swing.JScrollBar in project JMRI by JMRI.
the class FileHistoryAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
JFrame frame = new JmriJFrame() {
};
// JmriJFrame to ensure fits on screen
JTextArea pane = new JTextArea();
// add a little space at top
pane.append("\n");
pane.setEditable(false);
JScrollPane scroll = new JScrollPane(pane);
frame.getContentPane().add(scroll);
FileHistory r = InstanceManager.getNullableDefault(FileHistory.class);
if (r == null) {
pane.append("<No History Found>\n");
} else {
pane.append(r.toString());
}
// add a little space at bottom
pane.append("\n");
frame.pack();
// start scrolled to top
JScrollBar b = scroll.getVerticalScrollBar();
b.setValue(b.getMaximum());
// show
frame.setVisible(true);
}
use of javax.swing.JScrollBar in project JMRI by JMRI.
the class ReportContextAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent ev) {
// JmriJFrame to ensure fits on screen
final JFrame frame = new JmriJFrame(Bundle.getMessage("TitleContext"));
final Clipboard clipboard = frame.getToolkit().getSystemClipboard();
pane = new JTextArea();
// add a little space at top
pane.append("\n");
pane.setEditable(false);
pane.setLineWrap(true);
pane.setWrapStyleWord(true);
pane.setColumns(120);
JScrollPane scroll = new JScrollPane(pane);
frame.add(scroll, BorderLayout.CENTER);
ReportContext r = new ReportContext();
addString(r.getReport(true));
// add a little space at bottom
pane.append("\n");
// Add button to allow copy to clipboard
JPanel p = new JPanel();
JButton copy = new JButton(Bundle.getMessage("ButtonCopyClip"));
copy.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
StringSelection text = new StringSelection(pane.getText());
clipboard.setContents(text, text);
}
});
p.add(copy);
JButton close = new JButton(Bundle.getMessage("ButtonClose"));
close.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
frame.setVisible(false);
frame.dispose();
}
});
p.add(close);
frame.add(p, BorderLayout.SOUTH);
frame.pack();
// start scrolled to top
pane.setCaretPosition(0);
JScrollBar b = scroll.getVerticalScrollBar();
b.setValue(b.getMaximum());
// show
frame.setVisible(true);
}
use of javax.swing.JScrollBar in project jdk8u_jdk by JetBrains.
the class Test7163696 method run.
public void run() {
if (this.bar == null) {
this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
this.bar.setPreferredSize(new Dimension(400, 20));
JFrame frame = new JFrame();
frame.add(this.bar);
frame.pack();
frame.setVisible(true);
} else if (40 != this.bar.getValue()) {
System.out.println("name = " + UIManager.getLookAndFeel().getName());
System.out.println("value = " + this.bar.getValue());
} else {
SwingUtilities.getWindowAncestor(this.bar).dispose();
this.bar = null;
}
}
Aggregations