Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » getSize() always returns Point{0,0} on Button in GridLayout
getSize() always returns Point{0,0} on Button in GridLayout [message #452256] Wed, 16 March 2005 04:27 Go to next message
Eclipse UserFriend
Originally posted by: Blum_Thomas.nospam.web.de

Hi,
from the main-method I call the method "initButtons" with constants
colCount and rowCount:

private static void initButtons(){
buttons = new Button[colCount][rowCount];
for (int i=0; i<=colCount-1; i++)
for (int j=0; j<=rowCount-1; j++){
final int col = i;
final int row = j;
buttons[i][j] = new Button(shell, SWT.PUSH);
buttons[i][j].setLayoutData(new
GridData(GridData.HORIZONTAL_ALIGN_FILL |
GridData.VERTICAL_ALIGN_FILL |
GridData.GRAB_HORIZONTAL |
GridData.GRAB_VERTICAL));
buttons[i][j].setText(buttons[i][j].getSize().toString());
buttons[i][j].addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
handleButtonClick(col, row);
};
});
}

The buttons are always showing "Point{0,0}" but they are in fact much
bigger (about 250x130).
Can anybody tell me how to get the real size of the buttons?
Regards
Thomas Blum

--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/m2/
Re: getSize() always returns Point{0,0} on Button in GridLayout [message #452267 is a reply to message #452256] Wed, 16 March 2005 13:58 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
You are calling buttons[i][j].getSize() before the GridLayout has ever laid
out its components. GridLayout will not position and size your buttons
until either 1) the parent (shell in this case) changes size or 2) you call
layout() on the parent.

"Thomas Blum" <Blum_Thomas@nospam.web.de> wrote in message
news:opsnpqnwhq72jlis@thomas...
> Hi,
> from the main-method I call the method "initButtons" with constants
> colCount and rowCount:
>
> private static void initButtons(){
> buttons = new Button[colCount][rowCount];
> for (int i=0; i<=colCount-1; i++)
> for (int j=0; j<=rowCount-1; j++){
> final int col = i;
> final int row = j;
> buttons[i][j] = new Button(shell, SWT.PUSH);
> buttons[i][j].setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL |
> GridData.VERTICAL_ALIGN_FILL |
> GridData.GRAB_HORIZONTAL |
> GridData.GRAB_VERTICAL));
> buttons[i][j].setText(buttons[i][j].getSize().toString());
> buttons[i][j].addSelectionListener(new SelectionAdapter(){
> public void widgetSelected(SelectionEvent e){
> handleButtonClick(col, row);
> };
> });
> }
>
> The buttons are always showing "Point{0,0}" but they are in fact much
> bigger (about 250x130).
> Can anybody tell me how to get the real size of the buttons?
> Regards
> Thomas Blum
>
> --
> Erstellt mit Operas revolution
Thank you (was: getSize() always returns Point{0,0} on Button in GridLayout) [message #452286 is a reply to message #452267] Wed, 16 March 2005 22:19 Go to previous message
Eclipse UserFriend
Originally posted by: Blum_Thomas.nospam.web.de

Thank you very much, this solves my problem completly.
Regards
Thomas Blum



--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/m2/
Previous Topic:Launching a URL with multibyte characters problem
Next Topic:Field editors in org.eclipse.jface.preference
Goto Forum:
  


Current Time: Thu Apr 25 10:24:35 GMT 2024

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

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

Back to the top