我SWT标签不改变文本的新项目,在组合框中选择?

问题描述 投票:0回答:1

我目前使用绝对布局,我有这应该作为一个新的项目在组合框中我把它与网格布局工作,选择来更改标签,但该食堂与其他功能,按钮和标签我有我怎么会做这个工作对我来说...什么将不胜感激..这是我讲的代码的一部分:

    Combo comboLevels = new Combo(shellAfterCasual, SWT.NONE);
    comboLevels.setBounds(10, 40, 91, 23);
    String[] item = new String[] { "Swedish 1", "Swedish 2", "Swedish 3" };
    comboLevels.setItems(new String[] {"Swedish 1", "Swedish 2", "Swedish 3"});
    comboLevels.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
             levelStr1 = comboLevels.getItem(comboLevels.getSelectionIndex());
            System.out.println("Selection: " + comboLevels.getItem(comboLevels.getSelectionIndex()));


            Label lblvarLvlLabel = new Label(shellAfterCasual, SWT.NONE);
            lblvarLvlLabel.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.BOLD | SWT.ITALIC));
            lblvarLvlLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));
            lblvarLvlLabel.setBounds(145, 5, 107, 27);
            lblvarLvlLabel.setText(comboLevels.getText());
            lblvarLvlLabel.getParent().layout();
            /*'''''''''''''.............'''''''''''''''''''''''''''''''''''''''''''*/
            System.out.println("XDDD;"+levelStr1);
        }
    });
java label swt refresh
1个回答
0
投票

我终于找到了如何做到这一点,我开始动作监听外的标签,使标签是永远存在的,但它.setText和.updates项目时作如此选择:

Label lblvarLvlLabel = new Label(shellAfterCasual, SWT.NONE);
    lblvarLvlLabel.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.BOLD | SWT.ITALIC));
    lblvarLvlLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));
    lblvarLvlLabel.setBounds(145, 5, 107, 27);


    Combo comboLevels = new Combo(shellAfterCasual, SWT.NONE);
    comboLevels.setBounds(10, 40, 91, 23);
    String[] item = new String[] { "Swedish 1", "Swedish 2", "Swedish 3" };
    comboLevels.setItems(new String[] {"Swedish 1", "Swedish 2", "Swedish 3"});
    comboLevels.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
             levelStr1 = comboLevels.getItem(comboLevels.getSelectionIndex());
            System.out.println("Selection: " + comboLevels.getItem(comboLevels.getSelectionIndex()));
            lblvarLvlLabel.setText(comboLevels.getText());
            lblvarLvlLabel.getParent().layout();
            lblvarLvlLabel.redraw();
            lblvarLvlLabel.update();
        }
    });
© www.soinside.com 2019 - 2024. All rights reserved.