Move image in TitleAreaDialog left

I am working on a Java SE SWT / Jface project, I want to move the TitleAreaDialog image to the left. Is it possible? if not, then anyway?

Thanks,

+4
source share
2 answers

You can change the image label layout data 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(); 
0
source

It is not possible to configure it using the API, the layout is hard-coded. One way is to hack the controls of the dialog box and change their layout data, but it is most likely easier to implement your own class (using TitleAreaDialog as an example).

If you are a subclass of TitleAreaDialog , you must override the createContents(Composite) method, otherwise TitleAreaDialog will create its own header area by calling createTitleArea() . I suggest first copying the code from TitleAreaDialog.createContents() and starting replacing the things you need to do differently. I donโ€™t know exactly what to do without doing anything.

+2
source

Source: https://habr.com/ru/post/1435475/


All Articles