Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Coolbar repaint on application regaining focus (Win2K)
Coolbar repaint on application regaining focus (Win2K) [message #439830] Fri, 16 July 2004 13:52 Go to next message
Eclipse UserFriend
Originally posted by: michaelraath.yahoo.co.uk

Apologies if this has been answered elsewhere, but if it has I have been
unable to find it.

I have added a label and combo to a coolbar, but have noticed that if I
tab away to another application and then return, the CoolItem is not
repainted correctly.

Can someone point out to me what I'm doing wrong, please? Any help is
greatly appreciated.

This demonstrates the problem:

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);

CoolBar bar = new CoolBar(shell, SWT.NONE);
bar.setSize(200, 600);

CoolItem coolItem = new CoolItem(bar, SWT.NONE);
Composite quickSearch = new Composite(bar, SWT.NONE);
quickSearch.setLayout(new RowLayout());

Label qsLabel = new Label(quickSearch, SWT.CENTER);
qsLabel.setText("Search");
qsLabel.pack();

Combo dropDown = new Combo(quickSearch, SWT.DROP_DOWN);
dropDown.pack();
quickSearch.pack();
Point size = quickSearch.getSize();

coolItem.setControl(quickSearch);
coolItem.setPreferredSize(coolItem.computeSize(size.x, size.y));

shell.addFocusListener(new ACDMFocusListener(shell));
shell.pack();
shell.open();

while (!shell.isDisposed()) {
if (display.readAndDispatch())
display.sleep();
}
display.dispose();

}
Re: Coolbar repaint on application regaining focus (Win2K) [message #439831 is a reply to message #439830] Fri, 16 July 2004 14:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michaelraath.yahoo.co.uk

Sorry, please ignore the line
<snip>
shell.addFocusListener(new ACDMFocusListener(shell));
</snip>
this was an attempt to force a redraw on the application main window
regaining focus (which failed - the focusGained method is never called).
SOLVED Re: Coolbar repaint on application regaining focus (Win2K) [message #439860 is a reply to message #439830] Mon, 19 July 2004 09:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michaelraath.yahoo.co.uk

I have been able to solve this by adding a paintListener to the shell
which does a shell.update() on the paintControl event.

Anyone know why this doesn't happen automatically?
Re: Coolbar repaint on application regaining focus (Win2K) [message #440004 is a reply to message #439830] Tue, 20 July 2004 13:16 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
The problem is your event loop. You are missing a "!" in front of
"display.readAndDispatch()". This causes you to sleep after every event.

"Mike Raath" <michaelraath@yahoo.co.uk> wrote in message
news:cd8mi4$gb6$1@eclipse.org...
> Apologies if this has been answered elsewhere, but if it has I have been
> unable to find it.
>
> I have added a label and combo to a coolbar, but have noticed that if I
> tab away to another application and then return, the CoolItem is not
> repainted correctly.
>
> Can someone point out to me what I'm doing wrong, please? Any help is
> greatly appreciated.
>
> This demonstrates the problem:
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
>
> CoolBar bar = new CoolBar(shell, SWT.NONE);
> bar.setSize(200, 600);
>
> CoolItem coolItem = new CoolItem(bar, SWT.NONE);
> Composite quickSearch = new Composite(bar, SWT.NONE);
> quickSearch.setLayout(new RowLayout());
>
> Label qsLabel = new Label(quickSearch, SWT.CENTER);
> qsLabel.setText("Search");
> qsLabel.pack();
>
> Combo dropDown = new Combo(quickSearch, SWT.DROP_DOWN);
> dropDown.pack();
> quickSearch.pack();
> Point size = quickSearch.getSize();
>
> coolItem.setControl(quickSearch);
> coolItem.setPreferredSize(coolItem.computeSize(size.x, size.y));
>
> shell.addFocusListener(new ACDMFocusListener(shell));
> shell.pack();
> shell.open();
>
> while (!shell.isDisposed()) {
> if (display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
>
> }
>
>
Re: Coolbar repaint on application regaining focus (Win2K) [message #440036 is a reply to message #440004] Wed, 21 July 2004 15:51 Go to previous message
Eclipse UserFriend
Originally posted by: michaelraath.yahoo.co.uk

Thanks for your help there Steve.
Previous Topic:remove element from TreeViewer
Next Topic:swing/awt threading question
Goto Forum:
  


Current Time: Tue Apr 23 12:23:27 GMT 2024

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

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

Back to the top