Find the answer to your Linux question:
Results 1 to 3 of 3
Hey all. I'm currently working on learning SWT, so that I can write Linux apps that look nice (as opposed to the horrors of GTK1-skinned Swing apps). I am having ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252

    Java SWT: Help With Some Widgets [SOLVED]


    Hey all. I'm currently working on learning SWT, so that I can write Linux apps that look nice (as opposed to the horrors of GTK1-skinned Swing apps).

    I am having a problem. The window that I'm currently working on is in the following format:

    Code:
    ------------------
    |                      |
    |                      |
    ------------------
    |              |       |
    |              |       |
    ------------------
    Basically, I need two layouts in one screen. The top is a FillLayout (only one child), while the bottom is a Horizontal RowLayout.

    I have tried tackling this a number of ways:

    - A Shell with an Embedded Composite for the bottom
    - One Shell for the top, one Shell for the bottom
    - One Shell with an Embedded Composite for the Top, an Embedded Composite for the Bottom

    The third one is, I think, my best bet, but that gives me simply a grey pop-up.

    Can anyone think of another strategy? I have no prior knowledge of SWT: I am basing it entirely off of an open-source SWT app that I have lying around and the SWT website. But I'm picking it up pretty well, I think.


    Thanks in advance! If you want a code sample, let me know.

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    I got that problem fixed, but I've a new one now.

    When I add a Text to my app, it appears as a tiny little thing. I am able to make it larger by using setBounds, but I really don't want to do this if possible.

    The setSize() method is not functioning. How can I make my Text a readable size?


    Screenshot (the Text is the white rectangle):




    Code:
    Code:
    import org.eclipse.swt.*;
    import org.eclipse.swt.widgets.*;
    import org.eclipse.swt.layout.*;
    
    public class SWTTest
    {
        public static void main(String[] args)
        {
            Display display = new Display();
            Shell shell = new Shell(display);
            shell.setLayout(new RowLayout(SWT.VERTICAL));
            
            Label label = new Label(shell, SWT.WRAP);
            label.setText("===== The Text Is Below Here =====");
            
            Text text = new Text(shell, SWT.SINGLE);
            text.setTextLimit(50);
            
            shell.pack();
            shell.open();
                    
            while(!shell.isDisposed())
                if(!display.readAndDispatch())
                    display.sleep();
                display.dispose();
        }
    }

    Thanks in advance!

  3. #3
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Okay...

    If anyone ends up being curious, the way to solve this is to use a GridLayout, and create a GridData object, set the widthHint to a value, and assign the GridData to your widget. So, for example:

    Code:
    Text test = new Text(shell, SWT.SINGLE);
    GridData gData = new GridData();
    gData.widthHint = 200;
    test.setLayoutData(gData);

    It's hard to get SWT support . But I did find an SWT newgroup!


    So yeah, just here for future reference.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •