mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.14k stars 235 forks source link

WebComponentPane disable borders #536

Open husker-dev opened 5 years ago

husker-dev commented 5 years ago

I need to disable paint borders when element of WebComponentPane is focused. I tried to use setFocusable(false) but it doesn't help. How can I do it?

image

mgarin commented 5 years ago

You can't easily change it because it's hardcoded in SelectablePanelPainter that is used in the current componentpane.xml style for the WebComponentPane:

    <!-- Container panel -->
    <style type="panel" id="componentpane">

        <!-- Single panel -->
        <style type="panel" id="panel">
            <painter class="SelectablePanelPainter" />
        </style>

    </style>

You can add a separate temporary painter implementation until it's fixed though - just need to make a custom painter similar to SelectablePanelPainter and register it's annotation in StyleManager to be useable in the skin XML files.

Either way, I've added this issue into the #535 list and I will be adjusting the component to be properly styleable in the v1.2.11 update.

husker-dev commented 5 years ago

I easily changed it :D

public class MovableComponentList extends WebComponentPane {
    public MovableComponentList(){
        setStyleId(StyleId.componentpane);
        setReorderingAllowed(true);
        setShowReorderGrippers(false);
    }

    // Remove focus tracker
    public WebSelectablePanel addElement(Component component){
        WebSelectablePanel selectablePanel = super.addElement(component);
        FocusManager.removeFocusTrackers(selectablePanel);
        return selectablePanel;
    }
}
husker-dev commented 5 years ago

Solution inside library for update.

This solution isn't perfect, because after components were added, changing showBordersWhenFocused(boolean) won't help.

WebConponentPane:

// Create variable showBordersWhenFocused 
protected boolean showBordersWhenFocused = true;

// Add setter to showBordersWhenFocused 
public void setShowBordersWhenFocused ( final boolean showBordersWhenFocused ){
    this.showBordersWhenFocused = showBordersWhenFocused;
}

// Add getter to showBordersWhenFocused 
public boolean isShowingBordersWhenFocused (){
    return showBordersWhenFocused;
}

WebSelectablePane:

// Add testing for showBordersWhenFocused in initialisation
if (componentPane.isShowingBordersWhenFocused())
    com.alee.managers.focus.FocusManager.addFocusTracker ( WebSelectablePanel.this, focusTracker );
mgarin commented 5 years ago

It is fine workaround solution, but FocusTracker won't even be needed once component is moved to proper styling as it will handle all states according to the style provided. It's a fairly simple component, so i'll be adjusting it quite soon, right after the v1.2.10 release (which is possibly happening today).

mgarin commented 4 years ago

There are some complications I've encountered with this component, so I'll be moving it to v1.2.12 update as it might take some time and I don't want to delay the current update release any further.

mgarin commented 4 years ago

Still working on this in background, but some important changes and fixes will be done to the library first (planned in upcoming v1.3.0 version). WebLaF versioning is also getting adjusted to appropriately reflect changes made in different updates and to allow me to push important fixes outside of larger updates.