안녕하세요. 첫 번째 게시물입니다. 프로그래밍을 배우기 위해 최선을 다하고 있습니다. Eclipse에서 SWT를 사용하여 프로그램을 만들려고합니다. 사용자로부터 입력을 받아야하는 기본 프로그램이며 사용자가 입력 한 날짜에 따라 (if
문) 특정 출력이 표시됩니다.입력을 처리하는 방법은 무엇입니까?
문제 : 먼저 텍스트 필드 아래에 if
문을 넣으려고했지만이 실행을위한 일종의 단추가 필요하다는 것을 알았습니다. 그렇지 않으면 작동하지 않았습니다.
입력을 만드는 오류는 어디입니까? Dilluns
출력되지 않음 : MATESSS!
?
public void open() {
Display display = Display.getDefault();
createContents();
elsllibres.open();
elsllibres.layout();
while (!elsllibres.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
protected void createContents() {
elsllibres = new Shell();
elsllibres.setSize(450, 300);
elsllibres.setText("OSKARITOOO Industries");
Label lblQuinsLlibresCal = new Label(elsllibres, SWT.NONE);
lblQuinsLlibresCal.setBounds(10, 10, 360, 15);
lblQuinsLlibresCal.setText("QUINS LLIBRES CAL PORTAR AVUI?");
Label lblIndicaElDia = new Label(elsllibres, SWT.NONE);
lblIndicaElDia.setBounds(10, 31, 96, 15);
lblIndicaElDia.setText("INDICA EL DIA:");
text_1 = new Text(elsllibres, SWT.BORDER);
text_1.setText("EX: Dilluns, Dimarts...");
text_1.setBounds(10, 52, 123, 21);
Label info = new Label(elsllibres, SWT.NONE);
info.setBounds(10, 79, 174, 15);
info.setText("Cal portar els llibres de...");
resultat = new Label(elsllibres, SWT.NONE);
resultat.setBounds(10, 100, 207, 15);
Button ok = new Button(elsllibres, SWT.NONE);
ok.addTouchListener(new TouchListener() {
public void touch(TouchEvent arg0) {
String quediaes;
quediaes = text_1.toString();
if(quediaes.equals("Dilluns")){
resultat.setText("MATESSSS!");
}
}
});
ok.setBounds(142, 48, 75, 25);
ok.setText("OK");
text_1.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseEnter(org.eclipse.swt.events.MouseEvent e) {
text_1.setText("");
}
});
}
이것은 스윙이 아닙니다. 그것의 SWT. – camickr
upsitubsy! 나는 혼란 스러웠다. – oscar6662
그럴 경우 swt 태그를 스윙으로 대체 한 편집을 승인 한 것이 유감 스럽다. 대신 제목과 텍스트가 SWT를 읽도록 변경되어야합니다. 너무 빨랐어. –