本文整理汇总了Java中java.awt.Scrollbar.addAdjustmentListener方法的典型用法代码示例。如果您正苦于以下问题:Java Scrollbar.addAdjustmentListener方法的具体用法?Java Scrollbar.addAdjustmentListener怎么用?Java Scrollbar.addAdjustmentListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Scrollbar
的用法示例。
在下文中一共展示了Scrollbar.addAdjustmentListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSliderPanel
import java.awt.Scrollbar; //导入方法依赖的package包/类
private void createSliderPanel(final Scrollbar sliderField, String label, final Label sliderLabel,
final double scale)
{
Label listLabel = new Label(label, 0);
add(listLabel, 0, 1);
sliderField.setSize(100, 10);
c.ipadx = 75;
add(sliderField, 1, 1);
c.ipadx = 0;
sliderField.addAdjustmentListener(new AdjustmentListener()
{
public void adjustmentValueChanged(AdjustmentEvent e)
{
setSliderLabel(sliderField, sliderLabel, scale);
}
});
add(sliderLabel, 2, 1);
setSliderLabel(sliderField, sliderLabel, scale);
row++;
}
示例2: addListenerToSegDisplay
import java.awt.Scrollbar; //导入方法依赖的package包/类
private void addListenerToSegDisplay(){
// ready to use component listener on the slider of impSegmentationDisplay
Component[] components = impSegmentationDisplay.getWindow().getComponents();
for(Component comp : components){
if( comp instanceof ScrollbarWithLabel){
ScrollbarWithLabel scrollBar = (ScrollbarWithLabel) comp;
Component[] components2 = scrollBar.getComponents();
for(Component comp2 : components2){
if( comp2 instanceof Scrollbar){
Scrollbar scrollBar2 = (Scrollbar) comp2;
scrollBar2.addAdjustmentListener( new AdjustmentListener(){
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
pos[displayOrient] = impSegmentationDisplay.getSlice();
preview();
}
});
}
}
}
}
impListener = new ImageListener(){
@Override
public void imageClosed(ImagePlus imp) {
//ImagePlus.removeImageListener(this);
//if( imp.equals(impSegmentationDisplay)){
// impSegmentationDisplay.flush();
// impSegmentationDisplay = null;
// updateSegmentationDisplay();
// render();
//}
}
@Override
public void imageOpened(ImagePlus arg0) { }
@Override
public void imageUpdated(ImagePlus arg0) {
ImagePlus.removeImageListener(this);
pos[displayOrient] = impSegmentationDisplay.getSlice();
if ( pos[displayOrient] != previous.get("pos") )
preview();
ImagePlus.addImageListener(this);
}
};
ImagePlus.addImageListener(impListener); // not always satisfying does not always register the action
impSegmentationDisplay.getCanvas().addMouseMotionListener( this );
/*
KeyListener keyListener = new KeyListener(){
@Override
public void keyPressed(KeyEvent e) {
pos[displayOrient] = impSegmentationDisplay.getSlice();
preview();
System.out.println("hello key pressed");
e.consume();
}
@Override
public void keyTyped(KeyEvent e) { System.out.println("hello key typed");}
@Override
public void keyReleased(KeyEvent e) { System.out.println("hello key released");}
};
*/
//impSegmentationDisplay.getCanvas().addKeyListener( keyListener );
//impSegmentationDisplay.getWindow().addKeyListener( keyListener );
}
示例3: PDFViewerBuffer
import java.awt.Scrollbar; //导入方法依赖的package包/类
/**
* It render the section of the manual specified by @marker.
*
* @param title
* @param marker
* @throws IOException
*/
public PDFViewerBuffer(String title, ManualBookmarkers marker)
throws IOException {
super(title);
/** To avoid out of
* memory issue, it uses a buffer to load the pages.
*/
buffer = new Image[BUFFER_SIZE];
bufferIndex = new int[BUFFER_SIZE];
JPanel omni = new JPanel(new BorderLayout());
canvas = new JPanel();
loadManual(marker);
loadPage(0);
updateCanvas();
/**
* creation and management scrollbars
*/
bar = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, (pageEnd - pageStart)
* SCROLLBAR_ACCURACY);
bar.addAdjustmentListener(this);
JScrollPane scroller = new JScrollPane(canvas);
scroller.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));
scroller.getHorizontalScrollBar().setPreferredSize(new Dimension(0, 0));
omni.add(scroller, BorderLayout.CENTER);
omni.add(bar, BorderLayout.WEST);
omni.add(bar, BorderLayout.EAST);
setContentPane(omni);
this.addWindowListener(new CloseHelpFileAdapter());
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Toolkit tk = Toolkit.getDefaultToolkit();
setPreferredSize(new Dimension((int) Math.min(imageWidth, tk.getScreenSize().getWidth()),
(int) Math.min(imageHeight * 1.9, tk.getScreenSize().getHeight())));
pack();
setVisible(true);
}
示例4: sliderHorizontal
import java.awt.Scrollbar; //导入方法依赖的package包/类
public static Scrollbar sliderHorizontal(int value, int minScrollWidth, int maxScrollWidth, AdjustmentListener listener) {
Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, minScrollWidth, maxScrollWidth);
slider.addAdjustmentListener(listener);
return slider;
}
示例5: sliderVertical
import java.awt.Scrollbar; //导入方法依赖的package包/类
public static Scrollbar sliderVertical(int value, int minScrollWidth, int maxScrollWidth, AdjustmentListener listener) {
Scrollbar slider = new Scrollbar(Scrollbar.VERTICAL, value, 1, minScrollWidth, maxScrollWidth);
slider.addAdjustmentListener(listener);
return slider;
}
示例6: makeAdjustPropertiesDialog
import java.awt.Scrollbar; //导入方法依赖的package包/类
protected GenericDialog makeAdjustPropertiesDialog() {
Rectangle box = getBoundingBox(null);
GenericDialog gd = new GD("Properties of #" + id, this);
gd.addStringField("title: ", title);
gd.addNumericField("x: ", box.x, 2);
gd.addNumericField("y: ", box.y, 2);
gd.addNumericField("scale_x: ", 1, 2);
gd.addNumericField("scale_y: ", 1, 2);
gd.addNumericField("rot (degrees): ", 0, 2);
gd.addSlider("alpha: ", 0, 100, (int)(alpha*100));
gd.addCheckbox("visible", visible);
gd.addSlider("Red: ", 0, 255, color.getRed());
gd.addSlider("Green: ", 0, 255, color.getGreen());
gd.addSlider("Blue: ", 0, 255, color.getBlue());
gd.addCheckbox("locked", locked);
// add slider listener
final Scrollbar alp = (Scrollbar)gd.getSliders().get(0);
final Scrollbar red = (Scrollbar)gd.getSliders().get(1);
final Scrollbar green = (Scrollbar)gd.getSliders().get(2);
final Scrollbar blue = (Scrollbar)gd.getSliders().get(3);
final TextField talp = (TextField)gd.getNumericFields().get(5);
final TextField tred = (TextField)gd.getNumericFields().get(6);
final TextField tgreen = (TextField)gd.getNumericFields().get(7);
final TextField tblue = (TextField)gd.getNumericFields().get(8);
SliderListener sla = new SliderListener() {
public void update() {
setAlpha((float)alp.getValue()/100);
}
};
SliderListener slc = new SliderListener() {
public void update() {
setColor(new Color(red.getValue(), green.getValue(), blue.getValue()));
}
};
alp.addAdjustmentListener(sla);
red.addAdjustmentListener(slc);
green.addAdjustmentListener(slc);
blue.addAdjustmentListener(slc);
talp.addTextListener(sla);
tred.addTextListener(slc);
tgreen.addTextListener(slc);
tblue.addTextListener(slc);
gd.addChoice( "composite mode: ", compositeModes, compositeModes[ compositeMode ] );
return gd;
}