Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Progress Bar with Cancel Button using SWT implementation issue
Progress Bar with Cancel Button using SWT implementation issue [message #1619413] Mon, 16 February 2015 15:10 Go to next message
Anoop Singh is currently offline Anoop SinghFriend
Messages: 3
Registered: February 2015
Junior Member
Dear Members,

I am new to java. I have to create progress bar and cancel button on UI. I am using SWT to create the progress bar and button both.
The functionality is that when one process is going on progress bar status will keep changing and if Cancel button is clicked, the process will stop and control will take to different screen.
Here is the piece of code written by me:

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;

private Button cancel = null;
private ProgressBar progressBar = null;
progressBar = new ProgressBar(toplayer, SWT.NONE);
cancelProgress = new Button(layer, SWT.NONE);

progressBar.setBackground(new Color(null, 255, 255, 255)); // White
progressBar.setLayoutData(getFormdata(57, 05, 95, 65));
progressBar.setBounds(0, 0, 100, 100);

cancelProgress.setText("Cancel");
cancelProgress.setBackground(new Color(null, 240, 200, 120));

cancelProgress.setFont(getFont(12, SWT.BOLD));
cancelProgress.setLayoutData(getFormdata(83, 15, 89, 96));

cancelProgress.addMouseListener(new MouseListener() {

@Override
public void mouseUp(MouseEvent arg0) {

}

@Override
public void mouseDown(MouseEvent arg0) {
cancelProgressClicked = true;

}

@Override
public void mouseDoubleClick(MouseEvent arg0) {

}
});

But I am facing one problem. On the screen "Cancel" button doesn't recognize any event. While Progress Bar is working fine. Even when i take cursor on "Cancel" button no action is seen and also no action on click.

Could anybody please solve this issue? Looks something silly i am doing but this is very critical. Thanks in advance.

With regards,
Anoop.
Re: Progress Bar with Cancel Button using SWT implementation issue [message #1621352 is a reply to message #1619413] Tue, 17 February 2015 21:13 Go to previous message
Eclipse UserFriend
Sounds like you're running your job on the SWT thread, so events aren't being dispatched.

But don't re-invent the wheel and use the JFace ProgressMonitorDialog. JFace provides a bunch of helpers that build on top of SWT.

Brian.
Previous Topic:Only 1 column of TreeViewer in SashForm should grab new space
Next Topic:SWT Tree hides first item when header gets visible
Goto Forum:
  


Current Time: Tue Apr 23 10:52:57 GMT 2024

Powered by FUDForum. Page generated in 0.02597 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top