• 0

SWT GridLayout in Java question


Question

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

11 answers to this question

Recommended Posts

  • 0

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

  • 0

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

  • 0

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

  • 0

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.