MenuItems: scale gap between icon and text

This commit is contained in:
Karl Tauber
2019-08-31 13:04:46 +02:00
parent c5940f607b
commit 611296037c
5 changed files with 176 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.util.UIScale.scale;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI;
/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JCheckBoxMenuItem}.
*
* @author Karl Tauber
*/
public class FlatCheckBoxMenuItemUI
extends BasicCheckBoxMenuItemUI
{
public static ComponentUI createUI( JComponent c ) {
return new FlatCheckBoxMenuItemUI();
}
@Override
protected void installDefaults() {
super.installDefaults();
// scale
defaultTextIconGap = scale( defaultTextIconGap );
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.util.UIScale.scale;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicMenuItemUI;
/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JMenuItem}.
*
* @author Karl Tauber
*/
public class FlatMenuItemUI
extends BasicMenuItemUI
{
public static ComponentUI createUI( JComponent c ) {
return new FlatMenuItemUI();
}
@Override
protected void installDefaults() {
super.installDefaults();
// scale
defaultTextIconGap = scale( defaultTextIconGap );
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.util.UIScale.scale;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicMenuUI;
/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JMenu}.
*
* @author Karl Tauber
*/
public class FlatMenuUI
extends BasicMenuUI
{
public static ComponentUI createUI( JComponent c ) {
return new FlatMenuUI();
}
@Override
protected void installDefaults() {
super.installDefaults();
// scale
defaultTextIconGap = scale( defaultTextIconGap );
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.util.UIScale.scale;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI;
/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JRadioButtonMenuItem}.
*
* @author Karl Tauber
*/
public class FlatRadioButtonMenuItemUI
extends BasicRadioButtonMenuItemUI
{
public static ComponentUI createUI( JComponent c ) {
return new FlatRadioButtonMenuItemUI();
}
@Override
protected void installDefaults() {
super.installDefaults();
// scale
defaultTextIconGap = scale( defaultTextIconGap );
}
}

View File

@@ -18,13 +18,17 @@
ButtonUI=com.formdev.flatlaf.ui.FlatButtonUI
CheckBoxUI=com.formdev.flatlaf.ui.FlatCheckBoxUI
CheckBoxMenuItemUI=com.formdev.flatlaf.ui.FlatCheckBoxMenuItemUI
ComboBoxUI=com.formdev.flatlaf.ui.FlatComboBoxUI
EditorPaneUI=com.formdev.flatlaf.ui.FlatEditorPaneUI
FormattedTextFieldUI=com.formdev.flatlaf.ui.FlatFormattedTextFieldUI
LabelUI=com.formdev.flatlaf.ui.FlatLabelUI
MenuUI=com.formdev.flatlaf.ui.FlatMenuUI
MenuItemUI=com.formdev.flatlaf.ui.FlatMenuItemUI
PasswordFieldUI=com.formdev.flatlaf.ui.FlatPasswordFieldUI
ProgressBarUI=com.formdev.flatlaf.ui.FlatProgressBarUI
RadioButtonUI=com.formdev.flatlaf.ui.FlatRadioButtonUI
RadioButtonMenuItemUI=com.formdev.flatlaf.ui.FlatRadioButtonMenuItemUI
ScrollBarUI=com.formdev.flatlaf.ui.FlatScrollBarUI
ScrollPaneUI=com.formdev.flatlaf.ui.FlatScrollPaneUI
SeparatorUI=com.formdev.flatlaf.ui.FlatSeparatorUI