[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: Draw custom text on Table

Thank you, works fine (except the weight of the label - it it very short, I'll have probably to hardcore the weight of the label)
Agata


Grant Gayed wrote:

Putting a Label on the Table should work, snippet:

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setBounds(10,10,200,200);
    shell.setLayout(new FillLayout());
    Table table = new Table(shell, SWT.NONE);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    shell.open();
    Label label = new Label(table, SWT.CENTER);
    label.setBackground(table.getBackground());
    label.setBounds (5, table.getHeaderHeight(), table.getSize().x - 2 * 5,
table.getItemHeight());
    label.setText("no items here");
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
}

Grant


"Tom Schindl" <tom.schindl@xxxxxxxxxxxxxxx> wrote in message
news:gannqe$qk9$1@xxxxxxxxxxxxxxxxxxxx
Hi Agata,

Ok. Looks like SWT-Table doesn't support SWT-Paint :-( The only trick I
now see is that you are setting a background image which has the draw
back that it is rendered behind the Grid-Lines (you could turn them of
of course).

I've CC'ed the swt-newsgroup maybe some of the others has a better idea.

Tom

Agata Vackova schrieb:
> I tried to use paint listener (
>  table.addPaintListener(new PaintListener(){
>    public void paintControl(PaintEvent e) {
>     e.gc.drawText("No data", 100, 100);
>    }
>   });
> ), but it doesn't work: method paintControl is not called at all.
>
> Agata
>
> Tom Schindl wrote:
>
>> Owner Draw doesn't help here I guess because if there are no rows
>> there's no owner draw because it is bound to Table/TreeItem but a
simple
>> SWT.Paint-Listener should do the trick.
>
>> Tom
>
>> Eric Rizzo schrieb:
>>> Agata Vackova wrote:
>>>> Hello,
>>>>  is it possible to draw custom text on the table?
>>>>  I have Table and TableViewer and if there is not data to show, I
>>>> would like to display text with such message. I'd like the message to
>>>> be in first row, but go throw the more columns or to be in a special
>>>> place (eg. in the middle of control).
>>>
>>> You can probably use the Owner Draw feature to do this. See some
>>> examples on the Snippets page:
>>> http://wiki.eclipse.org/index.php/JFaceSnippets
>>>
>>> Hope this helps,
>>> Eric
>
>
>
>


-- B e s t S o l u t i o n . at -------------------------------------------------------------------- Tom Schindl JFace-Committer --------------------------------------------------------------------