⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buttonproject.java

📁 Describes simple java code for developments. IT comtains 10 codes
💻 JAVA
字号:
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;

public class ButtonProject 
{
    Display display;
    Shell shell;
    Button button;
    Text text;

    public static void main(String [] args) 
    {
        new ButtonProject();
    }

    ButtonProject()
    {
       display = new Display();
       shell = new Shell(display);
       shell.setSize(240, 150);
       shell.setText("SWT Buttons");

       button = new Button(shell, SWT.PUSH);
       button.setText("Click here");
       button.setBounds(10, 35, 60, 30);

       text = new Text(shell, SWT.SHADOW_IN);
       text.setBounds(80, 40, 120, 20);
       
       button.addSelectionListener(new SelectionListener()
       {
          public void widgetSelected(SelectionEvent event)
          {
            text.setText("Thanks for clicking.");
          }

          public void widgetDefaultSelected(SelectionEvent event)
          {
            text.setText("Thanks for clicking.");
          }
       });

       shell.open();
       while(!shell.isDisposed()) {
          if(!display.readAndDispatch()) display.sleep();
       }
       display.dispose();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -