I am learning how to use the Eclipse IDE and trying to run a composite built in Eclipse.
(我正在学习如何使用Eclipse IDE,并尝试运行在Eclipse中构建的组合。)
However, I can't get it to run the GUI can anyone help? (但是,我无法运行GUI,有人可以帮忙吗?)
I know I need public static void main(String[] args)
but what do I need to add to this method to get it to run correctly? (我知道我需要public static void main(String[] args)
但是我需要添加什么方法才能使其正常运行?)
Can anyone please help me. (谁能帮帮我吗。)
package gui;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Combo;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.plaf.metal.MetalIconFactory;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
public class GUI extends Composite {
// Strings to use as list items
private static final String[] items = { "Item 1", "Item 2", "Item 3", "Item 4" };
public Framework(Composite parent, int style) {
super(parent, style);
Combo comboBox= new Combo(this, SWT.DROP_DOWN);
comboBox.setBounds(174, 36, 534, 20);
comboBox.setItems(Algorithms);
Label lblOut = new Label(this, SWT.NONE);
lblOut.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
lblOut.setBounds(38, 145, 534, 327);
Button btnExit = new Button(this, SWT.NONE);
btnExit.setText("EXIT");
btnExit.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
btnExit.setBounds(591, 421, 166, 51);
btnExit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
System.exit(0);
}
});
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
public static void main(String[] args) {
Framework framework = new Framework();
Composite c = new Composite(framework, SWT.NONE);
}
}
I get an error on the line Framework framework = new Framework();
(我在Framework framework = new Framework();
上遇到错误Framework framework = new Framework();
)
as I need two arguments parent, font
. (因为我需要两个参数parent, font
。)
Please help and explain I'm only a beginner of Java. (请帮助并解释我只是Java的初学者。)
ask by Grace Devlin translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…