eccofresh Posted October 25, 2004 Share Posted October 25, 2004 I have a simple question about designing an Interface with SWT. what command(s) do I use to leave an grid empty? EDIT: 1 more question :) I know how to display an Image without using a layout, but how do I display the image with a Layout in a composite. My composite is called "composite" I tryed this command: Image img = new Image(composite, "C:\\logo.gif) but that doesnt work :( thx in advance Link to comment Share on other sites More sharing options...
0 davemania Posted October 25, 2004 Share Posted October 25, 2004 You have to use c.gridwidth to make a grid look empty, so for the cell above or below, set the gridwidth to 2. Link to comment Share on other sites More sharing options...
0 eccofresh Posted October 25, 2004 Author Share Posted October 25, 2004 what is c. ? Link to comment Share on other sites More sharing options...
0 davemania Posted October 25, 2004 Share Posted October 25, 2004 i mean GridBagLayout c = new GridBagLayout(); I got my above post wrong, for the empty cell, set the adjacent cell to grid width 2 Link to comment Share on other sites More sharing options...
0 eccofresh Posted October 25, 2004 Author Share Posted October 25, 2004 eclipse only allows me to import: import java.awt.GridBagLayout; but im using swt. does GridBagLayout also work for swt? Link to comment Share on other sites More sharing options...
0 davemania Posted October 25, 2004 Share Posted October 25, 2004 eclipse only allows me to import: import java.awt.GridBagLayout; but im using swt. does GridBagLayout also work for swt? 584801760[/snapback] yes Link to comment Share on other sites More sharing options...
0 eccofresh Posted October 25, 2004 Author Share Posted October 25, 2004 where would I write this into my code? be4 I create the new object which is supposed to skip one cell? like this for ex.: data = new GridData(GridData.FILL_BOTH); Button button1 = new Button(shell, SWT.PUSH); button1.setText("Browse Harddrive"); data.widthHint = 150; data.heightHint = 25; button1.setLayoutData(data); c.gridwidth = 2; data = new GridData(GridData.FILL_BOTH); Button button2 = new Button(shell, SWT.PUSH); button2.setText("Convert!"); data.widthHint = 150; data.heightHint = 25; button2.setLayoutData(data); also eclipse doesnt seam to like the line c.gridwidth = 2; cause it underlines it read and says no correction available :( Link to comment Share on other sites More sharing options...
0 davemania Posted October 25, 2004 Share Posted October 25, 2004 You have two buttons, what cell are you trying to leave empty ? Link to comment Share on other sites More sharing options...
0 eccofresh Posted October 25, 2004 Author Share Posted October 25, 2004 better example: data = new GridData(GridData.FILL_BOTH); Button button2 = new Button(shell, SWT.PUSH); button2.setText("Convert!"); data.widthHint = 150; data.heightHint = 25; button2.setLayoutData(data); c.gridwidth = 2; data = new GridData(GridData.FILL_BOTH); final Text csvFileOutput = new Text(shell, SWT.V_SCROLL | SWT.BORDER); csvFileOutput.setSize(590,200); csvFileOutput.setLocation(10,130); csvFileOutput.setEditable(false); I have two cells per row, and I one to leave the one next to button2 empty so that the text box is in the next row Link to comment Share on other sites More sharing options...
0 davemania Posted October 25, 2004 Share Posted October 25, 2004 I am still not really clear what you're trying to do but try this JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()) GridBaglayout c = new GridBagLayout(); c.gridx = 0 // first cell c.gridy = 0 // first row panel.add(button,c) c.gridx = 1 c.gridy = 0 panel.add(whaterver, c) etc etc Link to comment Share on other sites More sharing options...
0 eccofresh Posted October 25, 2004 Author Share Posted October 25, 2004 Im not allowed to use Swing, I got to use SWT with a GridLayout. All I want to do is leave one cell of the grid empty so that the csvFileOutput from my example is in the next row instead of on the right side of the button2 Link to comment Share on other sites More sharing options...
0 eccofresh Posted October 25, 2004 Author Share Posted October 25, 2004 w00t, i found the solution. I just had to insert an empty label with the visibility set to false. thx for the help though! Link to comment Share on other sites More sharing options...
Question
eccofresh
I have a simple question about designing an Interface with SWT.
what command(s) do I use to leave an grid empty?
EDIT: 1 more question :)
I know how to display an Image without using a layout, but how do I display the image with a Layout in a composite. My composite is called "composite"
I tryed this command:
but that doesnt work :(
thx in advance
Link to comment
Share on other sites
11 answers to this question
Recommended Posts