GoodSpeed
GoodSpeed

Reputation: 323

Moving an image of a TitleAreaDialog to the left

I'm working on a SWT/Jface project based on Java SE, i want to move the image of a TitleAreaDialog to the left. is it possible ? if not is there anyway ?

Thanks,

Upvotes: 4

Views: 628

Answers (2)

Martti Käärik
Martti Käärik

Reputation: 3621

There is no way to configure it using API, the layout is hard-coded. One way is to hack into the dialog controls and change their layout data, but it is likely easier to implement your own class (using TitleAreaDialog as an example).

If you subclass TitleAreaDialog you have to override createContents(Composite) method, otherwise the TitleAreaDialog will create its own title area by calling createTitleArea(). I suggest that at first you just copy the code from TitleAreaDialog.createContents() and start replacing stuff that you need to be done differently. I don't know exactly what needs to be done without actually doing everything.

Upvotes: 2

Nick Wilson
Nick Wilson

Reputation: 4989

You can modify the layout data of the image label as follows:

    TitleAreaDialog tad = new TitleAreaDialog(getShell()) {

        @Override
        protected Control createContents(Composite parent) {
            Control control = super.createContents(parent);
            Label label = getTitleImageLabel();
            FormData data = (FormData) label.getLayoutData();
            data.left = new FormAttachment(0, 0);
            data.right = null;
            return control;
        }

    };
    tad.setTitle("title");
    tad.setTitleImage(Activator.imageDescriptorFromPlugin(
            Activator.PLUGIN_ID, "image.gif").createImage());
    tad.open();

Upvotes: 0

Related Questions