【问题标题】:No items are displayed in the Palette in Eclipse oxygenEclipse 氧气的调色板中没有显示任何项目
【发布时间】:2018-08-22 12:04:40
【问题描述】:

我正在为 RCP 和 RAP 开发人员(氧气)使用 Eclipse。打开调色板后,它是空的。即使我的代码在源选项卡中处于编辑模式。 在下面的图像调色板是空的

按照建议添加以下代码。

打开“设计”选项卡时,调色板是空的。

package com.jcg.rca.main;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;

import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
//import org.eclipse.wb.swt.SWTResourceManager;

public class MainWindow {

protected Shell shlLogin;
private Text userNameTxt;
private Text passwordTxt;

private String userName = null;
private String password = null;

/**
 * Launch the application.
 * 
 * @param args
 */
public static void main(String[] args) {
    try {
        MainWindow window = new MainWindow();
        window.open();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

/**
 * Open the window.
 */
public void open() {
    Display display = Display.getDefault();
    createContents();
    shlLogin.open();
    shlLogin.layout();
    while (!shlLogin.isDisposed()) {
        if (!display.readAndDispatch()) {

            display.sleep();

        }
    }
}

/**
 * Create contents of the window.
 */
protected void createContents() {
    shlLogin = new Shell(SWT.CLOSE | SWT.TITLE | SWT.MIN);
    shlLogin.setSize(450, 300);
    shlLogin.setText("Login");

    CLabel label = new CLabel(shlLogin, SWT.NONE);
    //label.setImage(SWTResourceManager.getImage(MainWindow.class, "/com/jcg/rca/main/eclipse_logo.png"));
    label.setBounds(176, 10, 106, 70);
    label.setText("");

    Label lblUsername = new Label(shlLogin, SWT.NONE);
    lblUsername.setBounds(125, 115, 55, 15);
    lblUsername.setText("Username");

    Label lblPassword = new Label(shlLogin, SWT.NONE);
    lblPassword.setBounds(125, 144, 55, 15);
    lblPassword.setText("Password");

    userNameTxt = new Text(shlLogin, SWT.BORDER);
    userNameTxt.setBounds(206, 109, 173, 21);

    passwordTxt = new Text(shlLogin, SWT.BORDER | SWT.PASSWORD);
    passwordTxt.setBounds(206, 144, 173, 21);

    Button btnLogin = new Button(shlLogin, SWT.NONE);
    btnLogin.setBounds(206, 185, 75, 25);
    btnLogin.setText("Login");

    btnLogin.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {

            userName = userNameTxt.getText();
            password = passwordTxt.getText();

            if (userName == null || userName.isEmpty() || password == null || password.isEmpty()) {
                String errorMsg = null;
                MessageBox messageBox = new MessageBox(shlLogin, SWT.OK | SWT.ICON_ERROR);

                messageBox.setText("Alert");
                if (userName == null || userName.isEmpty()) {
                    errorMsg = "Please enter username";
                } else if (password == null || password.isEmpty()) {
                    errorMsg = "Please enter password";
                }
                if (errorMsg != null) {
                    messageBox.setMessage(errorMsg);
                    messageBox.open();
                }
            } else {
                MessageBox messageBox = new MessageBox(shlLogin, SWT.OK | SWT.ICON_WORKING);
                messageBox.setText("Info");
                messageBox.setMessage("Valid");
                messageBox.open();
            }
        }
    });

}}

.................................................. ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ....

【问题讨论】:

  • 你能在编辑模式下发布你的代码吗?
  • 看起来您正在使用 Windows Builder 插件?看看这个链接stackoverflow.com/questions/15963082/…
  • @JohnJoe 在问题中添加了代码片段。
  • @Shashwat 我已经用 Windows Builder Editor 打开了类文件,但调色板仍然是空的。
  • 您的代码未完成,我无法运行。只需创建一个简单的应用程序,然后查看是否显示项目。

标签: java eclipse eclipse-rcp eclipse-oxygen


【解决方案1】:

只需创建一个简单的 JAVA 项目。 然后我使用 Swing > JFrame 作为类。

不要从 WindowsBuilder 下创建项目。

【讨论】:

    【解决方案2】:

    右键单击调色板框 然后选择恢复默认调色板

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-02
      • 2018-12-02
      相关资源
      最近更新 更多