📄 scrollborder.java
字号:
//scrollborder.java
import java.awt.*;
import java.awt.event.*;
public class scrollborder extends Frame implements AdjustmentListener{
Scrollbar hScroll1, hScroll2, vScroll1, vScroll2;
textPanel Panel1;
public scrollborder(){
setLayout(new BorderLayout());
hScroll1 = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 200);
add("North", hScroll1);
hScroll1.addAdjustmentListener(this);
vScroll1 = new Scrollbar(Scrollbar.VERTICAL, 1, 1, 1, 200);
add("West", vScroll1);
vScroll1.addAdjustmentListener(this);
hScroll2 = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 200);
add("South", hScroll2);
hScroll2.addAdjustmentListener(this);
vScroll2 = new Scrollbar(Scrollbar.VERTICAL, 1, 1, 1, 200);
add("East", vScroll2);
vScroll2.addAdjustmentListener(this);
Panel1 = new textPanel();
add("Center", Panel1);
Panel1.Text1.setLocation(0, 0);
setSize(200, 200);
setVisible(true);
}
public void adjustmentValueChanged(AdjustmentEvent e){
if(e.getAdjustable() == hScroll1){
hScroll1.setValue(hScroll1.getValue());
hScroll2.setValue(hScroll1.getValue());
Panel1.Text1.setText("Horizontal location: " +
hScroll1.getValue());
}
if(e.getAdjustable() == vScroll1){
vScroll1.setValue(vScroll1.getValue());
vScroll2.setValue(vScroll1.getValue());
Panel1.Text1.setText("Vertical location: " +
vScroll1.getValue());
}
if(e.getAdjustable() == hScroll2){
hScroll2.setValue(hScroll2.getValue());
hScroll1.setValue(hScroll2.getValue());
Panel1.Text1.setText("Horizontal location: " +
hScroll2.getValue());
}
if(e.getAdjustable() == vScroll2){
vScroll2.setValue(vScroll2.getValue());
vScroll1.setValue(vScroll2.getValue());
Panel1.Text1.setText("Vertical location: " + vScroll2.getValue());
}
}
public static void main(String args[]){
scrollborder scroll=new scrollborder();
}
}
class textPanel extends Panel{
TextField Text1;
textPanel(){
Text1 = new TextField(20);
add(Text1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -