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

📄 showinputdialog.java

📁 自己建立的项目
💻 JAVA
字号:
package com.swtSample.dialogs;

import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
 * This class demonstrates the custom InputDialog class
 */
public class ShowInputDialog {
  public void run() {
    Display display = new Display();
    Shell shell = new Shell(display);
    createContents(shell);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }

  private void createContents(final Shell parent) {
    parent.setLayout(new FillLayout(SWT.VERTICAL));

    final Label label = new Label(parent, SWT.NONE);

    Button button = new Button(parent, SWT.PUSH);
    button.setText("Push Me");
    button.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        // Create and display the InputDialog
        InputDialog dlg = new InputDialog(parent);
        String input = dlg.open();
        if (input != null) {
          // User clicked OK; set the text into the label
          label.setText(input);
          label.getParent().pack();
        }
      }
    });
  }

  public static void main(String[] args) {
    new ShowInputDialog().run();
  }
}

⌨️ 快捷键说明

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