scrollpanedemo_gui.java
来自「JAVA程序设计课程中各章节的程序实例。」· Java 代码 · 共 44 行
JAVA
44 行
/**
*A simple scroll panel program in GUI
*2004.11.27. xhcprince
*Pay attention,it's not ScrollPanel, but ScrollPane!Without 'l' at last!
*/
import java.awt.*;
import java.applet.*;
public class scrollpaneDemo_GUI extends Applet
{
private canvas A;
private ScrollPane B;
public void init()
{
A = new canvas(300,160);
B = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
B.add(A);
this.add(B);
}
}
class canvas extends Canvas
{
protected canvas(int width, int height)
{
super();
this.setSize(width,height);
}
public void paint(Graphics g)
{
int width = this.getBounds().width;
int height = this.getBounds().height;
g.drawString("I will be tall!\n",150,80);
g.drawLine(height,0,0,width);
}
}
/*
<applet code = "scrollpaneDemo_GUI.class" width = 600 height = 600>
</applet>
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?