Skip to main content

Border: get Color - Dialog: get Type - Textarea: center

8 replies [Last post]
makibo
Offline
Joined: 2008-10-16

Hi,

i've got 3 questions:

1) Is there a way to get the Bordercolors set by the ressource editor? sth like myComponent.getBorder().getColor()?

2) How am i able to check the type of a dialog? I'm using a customLookAndFeel and i'd like to add an icon to the dialogTitle depending on what type it is (Error, Warning...)

3) Is it possible to center the text in a textarea?

thanks in advance!

regards,
maik

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
makibo
Offline
Joined: 2008-10-16

Hey again,

for centering content in the textarea, i just had to override the paint method (like you said - from dLAF). I only had to change one line to center my content - i dont think its hard to implement this generically - please correct me if i'm wrong..

Removed:
int x = ta.getX() + ta.getStyle().getPadding(Component.LEFT);

Added:
int x = ( ta.getWidth()-f.stringWidth(rowText) ) / 2;

regards,
maik

Shai Almog

Hi,
this will work generically for read only text areas but fail for text
field etc.
If anything we would have worked on right alignment which is very
important for bidi and is on our todo list for some future point.

> Hey again,
>
> for centering content in the textarea, i just had to override the
> paint method (like you said - from dLAF). I only had to change one
> line to center my content - i dont think its hard to implement this
> generically - please correct me if i'm wrong..
>
> Removed:
> int x = ta.getX() + ta.getStyle().getPadding(Component.LEFT);
>
> Added:
> int x = ( ta.getWidth()-f.stringWidth(rowText) ) / 2;
>
> regards,
> maik
> [Message sent by forum member 'makibo' (makibo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=310986
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

makibo
Offline
Joined: 2008-10-16

Thank you very much for your fast answers.

1) That's right what i want to do :)
Protected is just fine, because IMO its the most common use case to derive a border from border...

2) Thanks

3) I'll look into this - thanks for the hint

Shai Almog

> 1) That's right what i want to do :)
> Protected is just fine, because IMO its the most common use case to
> derive a border from border...

Hi,
I just started working on this and seems like I missed something
basic. Since the resource editor doesn't support arbitrary borders
you won't be able to instanciate your own border from the resource
editor. Only hardcoded borders, so extracting the color by a subclass
can be done but it won't help you much since your border won't be
created by the resource editor.

>
> [Message sent by forum member 'makibo' (makibo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=310907
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

makibo
Offline
Joined: 2008-10-16

hey again,

in my use case i wanted to manipulate a given border a bit, so that only the left, top and right borders were displayed. therefore i wanted to load the style from the border.

use-case: Dialog

instead of:

+--------+
+DTitle+
+--------+
+--------+
+Body+
+--------+

i wanted it like

+--------+
+DTitle+
+--------+
+Body+
+--------+

Shai Almog

Hi,
you will need to create your own border.
However, you won't be able to use the settings from the resource
editor since border types are hardcoded.
This can't be modified without reflection within the VM.

> hey again,
>
> in my use case i wanted to manipulate a given border a bit, so that
> only the left, top and right borders were displayed. therefore i
> wanted to load the style from the border.
>
> use-case: Dialog
>
> instead of:
>
> +--------+
> +DTitle+
> +--------+
> +--------+
> +Body+
> +--------+
>
> i wanted it like
>
> +--------+
> +DTitle+
> +--------+
> +Body+
> +--------+
> [Message sent by forum member 'makibo' (makibo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=313323
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

makibo
Offline
Joined: 2008-10-16

Hey again,

i have created my own border but would like to set the color via ressource editor...
maybe i'll go for adding a custom property "myDialogBorder" and set the "fgcolor", which i'm able to get in the code ^^

Thanks anyway for the fast and helpful replies :)

Shai Almog

Hi,
> Hi,
>
> i've got 3 questions:
>
> 1) Is there a way to get the Bordercolors set by the ressource
> editor? sth like myComponent.getBorder().getColor()?

Not at the moment.
I can see how this could be useful for implementing your own border.
Would protected methods for getters be enough or would you need a
public method exposed?
If public please elaborate the use case.

>
> 2) How am i able to check the type of a dialog? I'm using a
> customLookAndFeel and i'd like to add an icon to the dialogTitle
> depending on what type it is (Error, Warning...)

The type is mostly designed to convey the audio but I will add a s/
getDialogType() method in my next commit.

>
> 3) Is it possible to center the text in a textarea?

Not at the moment and this seems to be a relatively complex task to
do generically.
However, if you want to do something like this you can subclass text
area and use the code from DefaultLookAndFeel.drawTextArea to
implement paint. Just fix the line that draws a String to center the
string.

>
> thanks in advance!
>
> regards,
> maik
> [Message sent by forum member 'makibo' (makibo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=310417
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]