This discussion is archived
9 Replies Latest reply: Apr 15, 2010 1:57 AM by 843851 RSS

Disable on Focus rectangle in HGraphicButton

843851 Newbie
Currently Being Moderated
I want disable the rectangle outside the component when is focused, i try "setBordersEnabled(false)" with any result, i post a photo to ilstrate us.
[http://img85.imageshack.us/img85/3747/capturadepantalla201003.png]

Thanks.

PD: Sorry for my bad english.
  • 1. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    Hi! I had the same problem. Try to change the color of the foreground of the container. I mean, if you set the Color with transparency 0. I write the code to explain better...

    cont1.setForeground(new DVBColor(122, 14, 125, 0));

    and then add the HGraphicButton..

    PD: I think you are Spanish. I am too. my mail is maitetxu009@msn.com. We can help its other.

    Byee!!
  • 2. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    Now the problem, is that text inside the button disappears too, i'm trying ...

    Thanks.
  • 3. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    The most elegant way I found to do it, was to override HGraphicLook (maybe HGraphicButtonLook) as a class, and then implement your own foreground handler that basically does nothing when it's focused.

    Then use HGraphicLook.setdefaultlook or whatever_your_hgraphic_button_instance_is.setlook to an instance of that class.
  • 4. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    it's 'renderborders' in the look and feel override that you want to override. Basically make it return nothing, and voila, no box.
  • 5. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    Hi.

    It's really easy to disable that borders. Just try this:
    import java.awt.Graphics;
    import java.awt.Image;
    import org.havi.ui.*;
    
    public class MyHGraphicLook extends HGraphicLook
    {     
         public void showLook(Graphics g, HVisible visible, int state)
         {
                   Image image = visible.getGraphicContent(state);
                   if(image != null)
                   {
                         g.drawImage(image, 0, 0, visible);
                   }
         }
    }
    And when creating the HGraphicButton write:
    HGraphicButton b = new HGraphicButton(myImage, 10, 10, 200, 30);
    MyHGraphicLook m = new MyHGraphicLook();
    try
    {
          b.setLook(m);
    }
    catch(Exception e){}
    And that's it.
  • 6. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    The same thing happened, the border disappears but the text inside them too.

    Thanks.
  • 7. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    bippi wrote:
    it's 'renderborders' in the look and feel override that you want to override. Basically make it return nothing, and voila, no box.
    Now i try this.
    public void renderBorders(java.awt.Graphics g, HVisible visible, int state) {
         
    }
    but no changes, the rectangle stills here. I think this time i don't do well i dont return nothing, because the function returns void.

    Thanks.
  • 8. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    I didn't realize what happened with text. I'm really sorry.

    So this is the final one:
    public void showLook(Graphics g, HVisible visible, int state)
    {
            Image image = visible.getGraphicContent(state);
            if(image != null)
            {
                 g.drawImage(image, 0, 0, visible);
            }
            String string = visible.getTextContent(state);
            if(string != null)
            {
                visible.getTextLayoutManager().render(string, g, visible, new Insets(2, 2, 2, 2));
            }
    }
    I hope it's what you need.
  • 9. Re: Disable on Focus rectangle in HGraphicButton
    843851 Newbie
    Currently Being Moderated
    Thanks this it is, works very well, thanks another time.