TitleAreaDialog - setting the title image

So, I am creating an image for placement in the title bar. Does everything work except that only 1/4 of the image is displayed?

my image is actually text, and the image is combined into one image. EX: JKTeater [] <- icon so right now only JKT is displayed in the title bar

Here is the create () method

public void create() { super.create(); setTitle("JKTeater Application"); setMessage("Hello World"); if (image != null) setTitleImage(image); } 
  • Is there a specific size that allows the header area code?
  • Is there a way to put the end of the image at the end of the title bar?
  • Can you use the layout to move it?
  • How can I get a black horizontal line at the bottom of the title bar?

EDIT

enter image description here

I'm sure he would ask a lot to find out if you can really change the background color from base color to gradient

+4
source share
1 answer

Here is an example TitleAreaDialog . As you can see, Image fully displayed and aligned to the right:

 public static void main(String[] args) { final Shell shell = new Shell(); shell.setLayout(new FillLayout()); TitleAreaDialog dialog = new MyTitleAreaDialog(shell); dialog.setTitleAreaColor(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB()); dialog.open(); } private static class MyTitleAreaDialog extends TitleAreaDialog { private Image image; public MyTitleAreaDialog(Shell parentShell) { super(parentShell); image = new Image(Display.getDefault(), "/home/baz/Desktop/StackOverflow.png"); } @Override public boolean close() { if (image != null) image.dispose(); return super.close(); } @Override protected Control createContents(Composite parent) { Control contents = super.createContents(parent); setTitle("Title"); setMessage("Message"); if (image != null) setTitleImage(image); return contents; } @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); // YOUR LINE HERE! Label line = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); line.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true)); return composite; } } 

enter image description here

Is there a specific size that allows the header area code?

AFAIK there is no size limit. I tried using Image , which was more than my screen resolution, and it was fully displayed. Dialog was clearly unusable.

I'm sure he would ask a lot to find out if you can really change the background color from base color to gradient

The background color can be changed using dialog.setTitleAreaColor(RGB) (in this case, the background color of the widget), but you cannot use the gradient. There is an obsolete getTitleArea() method that returns a Composite header area, but I really do not recommend using this.

How can I get a black horizontal line at the bottom of the title bar?

The line below was reached with:

 Label line = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); line.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true)); 

Can you use the layout to move it?

There is a similar question here:

Moving TitleAreaDialog Image Left

The answers there explain how to change the details of the TitleAreaDialog . Perhaps read them.

+3
source

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