老师给布置个任务,点击放大缩小按纽的话,窗体会水平放大缩小,(就是说窗体内10cm长的横线点击放大按纽的话会按一定比例放大到20cm;再点放大到40cm)具体怎么实现啊,各位大侠帮帮忙,万分感谢!
解决方案 »
- Java编写增删改查,不使用数据库(用IO,或者集合框架)
- 在线急等===== 一个小知识。
- 请教:我在做新闻发布后台管理的时候,需要分层次管理(树型,分结点,子结点、叶),请给个思想或类似的代码。
- 入门级学员请教JAVA连接SQLServer
- 再过两个月毕业急将成为中软程序员
- 我写的两个类来查询12张表,但是总是又数据丢失,就是说有些符合条件的数据不能够查询出来
- J2SDK的类文件放在什么地方?
- 请各位高手来呀!
- 有谁能帮我解决JEditPane对中文页面的支持问题
- 请问面试题中,有很多算法题,都要ood么?
- org.apache.jasper.JasperException: Unable to compile class for JSP 高手帮忙谢谢!
- JSAPI(tts.jar,speech.jar)中文发声问题
我想问的是在SWT中怎么实现,而不是用awt,希望帮忙解答
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.SWT;public class Change extends SelectionAdapter {
static int width = 500; static int height = 400; static Button zoomIn; static Button zoomOut; static Shell shell; public static void main(String args[]) {
Change change = new Change();
Display display = new Display();
shell = new Shell(display);
shell.setLayout(new RowLayout());
zoomIn = new Button(shell, SWT.PUSH | SWT.CENTER);
zoomIn.addSelectionListener(change);
zoomIn.setText("缩小");
zoomOut = new Button(shell, SWT.PUSH | SWT.CENTER);
zoomOut.addSelectionListener(change);
zoomOut.setText("放大");
shell.setSize(width, height);
shell.setVisible(true);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
shell.dispose();
display.dispose();
} public void widgetSelected(SelectionEvent arg0) {
if (arg0.getSource() == zoomIn) {
width -= 50;
} else if (arg0.getSource() == zoomOut) {
width += 50;
}
shell.setSize(width, height);
}
}