mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
Extras: added extension interfaces and classes for JComboBox, JFormattedTextField, JPasswordField, JScrollBar, JScrollPane and JTextField (issue #117)
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components;
|
||||||
|
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import com.formdev.flatlaf.extras.components.extensions.FlatComboBoxExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of {@link JComboBox} that implements {@link FlatComboBoxExtension}
|
||||||
|
* to provide easy access to FlatLaf specific client properties.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatComboBox<E>
|
||||||
|
extends JComboBox<E>
|
||||||
|
implements FlatComboBoxExtension
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components;
|
||||||
|
|
||||||
|
import javax.swing.JFormattedTextField;
|
||||||
|
import com.formdev.flatlaf.extras.components.extensions.FlatTextFieldExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of {@link JFormattedTextField} that implements {@link FlatTextFieldExtension}
|
||||||
|
* to provide easy access to FlatLaf specific client properties.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatFormattedTextField
|
||||||
|
extends JFormattedTextField
|
||||||
|
implements FlatTextFieldExtension
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components;
|
||||||
|
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import com.formdev.flatlaf.extras.components.extensions.FlatTextFieldExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of {@link JPasswordField} that implements {@link FlatTextFieldExtension}
|
||||||
|
* to provide easy access to FlatLaf specific client properties.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatPasswordField
|
||||||
|
extends JPasswordField
|
||||||
|
implements FlatTextFieldExtension
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components;
|
||||||
|
|
||||||
|
import javax.swing.JScrollBar;
|
||||||
|
import com.formdev.flatlaf.extras.components.extensions.FlatScrollBarExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of {@link JScrollBar} that implements {@link FlatScrollBarExtension}
|
||||||
|
* to provide easy access to FlatLaf specific client properties.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatScrollBar
|
||||||
|
extends JScrollBar
|
||||||
|
implements FlatScrollBarExtension
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components;
|
||||||
|
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import com.formdev.flatlaf.extras.components.extensions.FlatScrollPaneExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of {@link JScrollPane} that implements {@link FlatScrollPaneExtension}
|
||||||
|
* to provide easy access to FlatLaf specific client properties.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatScrollPane
|
||||||
|
extends JScrollPane
|
||||||
|
implements FlatScrollPaneExtension
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components;
|
||||||
|
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import com.formdev.flatlaf.extras.components.extensions.FlatTextFieldExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of {@link JTextField} that implements {@link FlatTextFieldExtension}
|
||||||
|
* to provide easy access to FlatLaf specific client properties.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatTextField
|
||||||
|
extends JTextField
|
||||||
|
implements FlatTextFieldExtension
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components.extensions;
|
||||||
|
|
||||||
|
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension interface for {@link JComboBox} that provides
|
||||||
|
* easy access to FlatLaf specific client properties.
|
||||||
|
* <p>
|
||||||
|
* Use this interface if you already have a subclass of {@link JComboBox}
|
||||||
|
* in your project and want add access to FlatLaf features to your class.
|
||||||
|
* Otherwise use {@link FlatComboBox}.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public interface FlatComboBoxExtension
|
||||||
|
extends FlatComponentExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the placeholder text that is only painted if the editable combo box is empty.
|
||||||
|
*/
|
||||||
|
default String getPlaceholderText() {
|
||||||
|
return (String) getClientProperty( PLACEHOLDER_TEXT );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the placeholder text that is only painted if the editable combo box is empty.
|
||||||
|
*/
|
||||||
|
default void setPlaceholderText( String placeholderText ) {
|
||||||
|
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components.extensions;
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base interface for all FlatLaf component extensions.
|
||||||
|
* Extensions use client properties to store property values in components.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public interface FlatComponentExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Overrides {@link JComponent#getClientProperty(Object)}.
|
||||||
|
*/
|
||||||
|
Object getClientProperty( Object key );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides {@link JComponent#putClientProperty(Object, Object)}.
|
||||||
|
*/
|
||||||
|
void putClientProperty( Object key, Object value );
|
||||||
|
|
||||||
|
|
||||||
|
default boolean getClientPropertyBoolean( Object key, String defaultValueKey ) {
|
||||||
|
Object value = getClientProperty( key );
|
||||||
|
return (value instanceof Boolean) ? (boolean) value : UIManager.getBoolean( defaultValueKey );
|
||||||
|
}
|
||||||
|
|
||||||
|
default <T extends Enum<T>> T getClientPropertyEnumString( Object key, Class<T> enumType,
|
||||||
|
String defaultValueKey, T defaultValue )
|
||||||
|
{
|
||||||
|
Object value = getClientProperty( key );
|
||||||
|
if( !(value instanceof String) && defaultValueKey != null )
|
||||||
|
value = UIManager.getString( defaultValueKey );
|
||||||
|
if( value instanceof String ) {
|
||||||
|
try {
|
||||||
|
return Enum.valueOf( enumType, (String) value );
|
||||||
|
} catch( IllegalArgumentException ex ) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
default <T extends Enum<T>> void putClientPropertyEnumString( Object key, Enum<T> value ) {
|
||||||
|
putClientProperty( key, (value != null) ? value.toString() : null );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components.extensions;
|
||||||
|
|
||||||
|
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||||
|
import javax.swing.JScrollBar;
|
||||||
|
import com.formdev.flatlaf.extras.components.FlatScrollBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension interface for {@link JScrollBar} that provides
|
||||||
|
* easy access to FlatLaf specific client properties.
|
||||||
|
* <p>
|
||||||
|
* Use this interface if you already have a subclass of {@link JScrollBar}
|
||||||
|
* in your project and want add access to FlatLaf features to your class.
|
||||||
|
* Otherwise use {@link FlatScrollBar}.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public interface FlatScrollBarExtension
|
||||||
|
extends FlatComponentExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns whether the decrease/increase arrow buttons of a scrollbar are shown.
|
||||||
|
*/
|
||||||
|
default boolean isShowButtons() {
|
||||||
|
return getClientPropertyBoolean( SCROLL_BAR_SHOW_BUTTONS, "ScrollBar.showButtons" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether the decrease/increase arrow buttons of a scrollbar are shown.
|
||||||
|
*/
|
||||||
|
default void setShowButtons( boolean showButtons ) {
|
||||||
|
putClientProperty( SCROLL_BAR_SHOW_BUTTONS, showButtons );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components.extensions;
|
||||||
|
|
||||||
|
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import com.formdev.flatlaf.extras.components.FlatScrollPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension interface for {@link JScrollPane} that provides
|
||||||
|
* easy access to FlatLaf specific client properties.
|
||||||
|
* <p>
|
||||||
|
* Use this interface if you already have a subclass of {@link JScrollPane}
|
||||||
|
* in your project and want add access to FlatLaf features to your class.
|
||||||
|
* Otherwise use {@link FlatScrollPane}.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public interface FlatScrollPaneExtension
|
||||||
|
extends FlatComponentExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns whether the decrease/increase arrow buttons of a scrollbar are shown.
|
||||||
|
*/
|
||||||
|
default boolean isShowButtons() {
|
||||||
|
return getClientPropertyBoolean( SCROLL_BAR_SHOW_BUTTONS, "ScrollBar.showButtons" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether the decrease/increase arrow buttons of a scrollbar are shown.
|
||||||
|
*/
|
||||||
|
default void setShowButtons( boolean showButtons ) {
|
||||||
|
putClientProperty( SCROLL_BAR_SHOW_BUTTONS, showButtons );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the scroll pane uses smooth scrolling.
|
||||||
|
*/
|
||||||
|
default boolean isSmoothScrolling() {
|
||||||
|
return getClientPropertyBoolean( SCROLL_PANE_SMOOTH_SCROLLING, "ScrollPane.smoothScrolling" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether the scroll pane uses smooth scrolling.
|
||||||
|
*/
|
||||||
|
default void setSmoothScrolling( boolean smoothScrolling ) {
|
||||||
|
putClientProperty( SCROLL_PANE_SMOOTH_SCROLLING, smoothScrolling );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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
|
||||||
|
*
|
||||||
|
* https://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.extras.components.extensions;
|
||||||
|
|
||||||
|
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||||
|
import javax.swing.JFormattedTextField;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import com.formdev.flatlaf.extras.components.FlatFormattedTextField;
|
||||||
|
import com.formdev.flatlaf.extras.components.FlatPasswordField;
|
||||||
|
import com.formdev.flatlaf.extras.components.FlatTextField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension interface for {@link JTextField} (and subclasses) that provides
|
||||||
|
* easy access to FlatLaf specific client properties.
|
||||||
|
* <p>
|
||||||
|
* Use this interface if you already have a subclass of {@link JTextField},
|
||||||
|
* {@link JFormattedTextField} or {@link JPasswordField}
|
||||||
|
* in your project and want add access to FlatLaf features to your class.
|
||||||
|
* Otherwise use {@link FlatTextField}, {@link FlatFormattedTextField} or {@link FlatPasswordField}.
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public interface FlatTextFieldExtension
|
||||||
|
extends FlatComponentExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the placeholder text that is only painted if the text field is empty.
|
||||||
|
*/
|
||||||
|
default String getPlaceholderText() {
|
||||||
|
return (String) getClientProperty( PLACEHOLDER_TEXT );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the placeholder text that is only painted if the text field is empty.
|
||||||
|
*/
|
||||||
|
default void setPlaceholderText( String placeholderText ) {
|
||||||
|
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: enum names must be equal to allowed strings
|
||||||
|
enum SelectAllOnFocusPolicy { never, once, always };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether all text is selected when the text component gains focus.
|
||||||
|
*/
|
||||||
|
default SelectAllOnFocusPolicy getSelectAllOnFocusPolicy() {
|
||||||
|
return getClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, SelectAllOnFocusPolicy.class,
|
||||||
|
"TextComponent.selectAllOnFocusPolicy", SelectAllOnFocusPolicy.once );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether all text is selected when the text component gains focus.
|
||||||
|
*/
|
||||||
|
default void setSelectAllOnFocusPolicy( SelectAllOnFocusPolicy selectAllOnFocusPolicy ) {
|
||||||
|
putClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, selectAllOnFocusPolicy );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import java.awt.*;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.*;
|
import javax.swing.border.*;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
|
import com.formdev.flatlaf.extras.components.*;
|
||||||
import net.miginfocom.swing.*;
|
import net.miginfocom.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,28 +189,28 @@ public class FlatComponentsTest
|
|||||||
JSpinner spinner2 = new JSpinner();
|
JSpinner spinner2 = new JSpinner();
|
||||||
FlatComponentsTest.ButtonlessSpinner buttonlessSpinner1 = new FlatComponentsTest.ButtonlessSpinner();
|
FlatComponentsTest.ButtonlessSpinner buttonlessSpinner1 = new FlatComponentsTest.ButtonlessSpinner();
|
||||||
FlatComponentsTest.ButtonlessSpinner buttonlessSpinner2 = new FlatComponentsTest.ButtonlessSpinner();
|
FlatComponentsTest.ButtonlessSpinner buttonlessSpinner2 = new FlatComponentsTest.ButtonlessSpinner();
|
||||||
JComboBox<String> comboBox7 = new JComboBox<>();
|
FlatComboBox<String> comboBox7 = new FlatComboBox<>();
|
||||||
JSpinner spinner3 = new JSpinner();
|
JSpinner spinner3 = new JSpinner();
|
||||||
JLabel textFieldLabel = new JLabel();
|
JLabel textFieldLabel = new JLabel();
|
||||||
textField1 = new JTextField();
|
textField1 = new JTextField();
|
||||||
JTextField textField2 = new JTextField();
|
JTextField textField2 = new JTextField();
|
||||||
JTextField textField3 = new JTextField();
|
JTextField textField3 = new JTextField();
|
||||||
JTextField textField4 = new JTextField();
|
JTextField textField4 = new JTextField();
|
||||||
JTextField textField6 = new JTextField();
|
FlatTextField textField6 = new FlatTextField();
|
||||||
JTextField textField5 = new JTextField();
|
JTextField textField5 = new JTextField();
|
||||||
JLabel formattedTextFieldLabel = new JLabel();
|
JLabel formattedTextFieldLabel = new JLabel();
|
||||||
JFormattedTextField formattedTextField1 = new JFormattedTextField();
|
JFormattedTextField formattedTextField1 = new JFormattedTextField();
|
||||||
JFormattedTextField formattedTextField2 = new JFormattedTextField();
|
JFormattedTextField formattedTextField2 = new JFormattedTextField();
|
||||||
JFormattedTextField formattedTextField3 = new JFormattedTextField();
|
JFormattedTextField formattedTextField3 = new JFormattedTextField();
|
||||||
JFormattedTextField formattedTextField4 = new JFormattedTextField();
|
JFormattedTextField formattedTextField4 = new JFormattedTextField();
|
||||||
JFormattedTextField formattedTextField5 = new JFormattedTextField();
|
FlatFormattedTextField formattedTextField5 = new FlatFormattedTextField();
|
||||||
JFormattedTextField formattedTextField6 = new JFormattedTextField();
|
JFormattedTextField formattedTextField6 = new JFormattedTextField();
|
||||||
JLabel passwordFieldLabel = new JLabel();
|
JLabel passwordFieldLabel = new JLabel();
|
||||||
JPasswordField passwordField1 = new JPasswordField();
|
JPasswordField passwordField1 = new JPasswordField();
|
||||||
JPasswordField passwordField2 = new JPasswordField();
|
JPasswordField passwordField2 = new JPasswordField();
|
||||||
JPasswordField passwordField3 = new JPasswordField();
|
JPasswordField passwordField3 = new JPasswordField();
|
||||||
JPasswordField passwordField4 = new JPasswordField();
|
JPasswordField passwordField4 = new JPasswordField();
|
||||||
JPasswordField passwordField5 = new JPasswordField();
|
FlatPasswordField passwordField5 = new FlatPasswordField();
|
||||||
JPasswordField passwordField6 = new JPasswordField();
|
JPasswordField passwordField6 = new JPasswordField();
|
||||||
JLabel textAreaLabel = new JLabel();
|
JLabel textAreaLabel = new JLabel();
|
||||||
JScrollPane scrollPane1 = new JScrollPane();
|
JScrollPane scrollPane1 = new JScrollPane();
|
||||||
@@ -247,8 +248,8 @@ public class FlatComponentsTest
|
|||||||
JButton button19 = new JButton();
|
JButton button19 = new JButton();
|
||||||
JScrollBar scrollBar2 = new JScrollBar();
|
JScrollBar scrollBar2 = new JScrollBar();
|
||||||
JScrollBar scrollBar3 = new JScrollBar();
|
JScrollBar scrollBar3 = new JScrollBar();
|
||||||
JScrollBar scrollBar7 = new JScrollBar();
|
FlatScrollBar scrollBar7 = new FlatScrollBar();
|
||||||
JScrollBar scrollBar8 = new JScrollBar();
|
FlatScrollBar scrollBar8 = new FlatScrollBar();
|
||||||
JSeparator separator2 = new JSeparator();
|
JSeparator separator2 = new JSeparator();
|
||||||
JSlider slider2 = new JSlider();
|
JSlider slider2 = new JSlider();
|
||||||
JSlider slider4 = new JSlider();
|
JSlider slider4 = new JSlider();
|
||||||
@@ -278,8 +279,8 @@ public class FlatComponentsTest
|
|||||||
JLabel scrollBarLabel = new JLabel();
|
JLabel scrollBarLabel = new JLabel();
|
||||||
JScrollBar scrollBar1 = new JScrollBar();
|
JScrollBar scrollBar1 = new JScrollBar();
|
||||||
JScrollBar scrollBar4 = new JScrollBar();
|
JScrollBar scrollBar4 = new JScrollBar();
|
||||||
JScrollBar scrollBar5 = new JScrollBar();
|
FlatScrollBar scrollBar5 = new FlatScrollBar();
|
||||||
JScrollBar scrollBar6 = new JScrollBar();
|
FlatScrollBar scrollBar6 = new FlatScrollBar();
|
||||||
JLabel separatorLabel = new JLabel();
|
JLabel separatorLabel = new JLabel();
|
||||||
JSeparator separator1 = new JSeparator();
|
JSeparator separator1 = new JSeparator();
|
||||||
JPanel panel2 = new JPanel();
|
JPanel panel2 = new JPanel();
|
||||||
@@ -686,7 +687,7 @@ public class FlatComponentsTest
|
|||||||
|
|
||||||
//---- comboBox7 ----
|
//---- comboBox7 ----
|
||||||
comboBox7.setEditable(true);
|
comboBox7.setEditable(true);
|
||||||
comboBox7.putClientProperty("JTextField.placeholderText", "Placeholder");
|
comboBox7.setPlaceholderText("Placeholder");
|
||||||
add(comboBox7, "cell 5 6,growx");
|
add(comboBox7, "cell 5 6,growx");
|
||||||
|
|
||||||
//---- spinner3 ----
|
//---- spinner3 ----
|
||||||
@@ -719,7 +720,7 @@ public class FlatComponentsTest
|
|||||||
add(textField4, "cell 4 7,growx");
|
add(textField4, "cell 4 7,growx");
|
||||||
|
|
||||||
//---- textField6 ----
|
//---- textField6 ----
|
||||||
textField6.putClientProperty("JTextField.placeholderText", "Placeholder");
|
textField6.setPlaceholderText("Placeholder");
|
||||||
add(textField6, "cell 5 7,growx");
|
add(textField6, "cell 5 7,growx");
|
||||||
|
|
||||||
//---- textField5 ----
|
//---- textField5 ----
|
||||||
@@ -752,7 +753,7 @@ public class FlatComponentsTest
|
|||||||
add(formattedTextField4, "cell 4 8,growx");
|
add(formattedTextField4, "cell 4 8,growx");
|
||||||
|
|
||||||
//---- formattedTextField5 ----
|
//---- formattedTextField5 ----
|
||||||
formattedTextField5.putClientProperty("JTextField.placeholderText", "Placeholder");
|
formattedTextField5.setPlaceholderText("Placeholder");
|
||||||
add(formattedTextField5, "cell 5 8,growx");
|
add(formattedTextField5, "cell 5 8,growx");
|
||||||
|
|
||||||
//---- formattedTextField6 ----
|
//---- formattedTextField6 ----
|
||||||
@@ -785,7 +786,7 @@ public class FlatComponentsTest
|
|||||||
add(passwordField4, "cell 4 9,growx");
|
add(passwordField4, "cell 4 9,growx");
|
||||||
|
|
||||||
//---- passwordField5 ----
|
//---- passwordField5 ----
|
||||||
passwordField5.putClientProperty("JTextField.placeholderText", "Placeholder");
|
passwordField5.setPlaceholderText("Placeholder");
|
||||||
add(passwordField5, "cell 5 9,growx");
|
add(passwordField5, "cell 5 9,growx");
|
||||||
|
|
||||||
//---- passwordField6 ----
|
//---- passwordField6 ----
|
||||||
@@ -996,12 +997,12 @@ public class FlatComponentsTest
|
|||||||
add(scrollBar3, "cell 2 13 1 6,growy");
|
add(scrollBar3, "cell 2 13 1 6,growy");
|
||||||
|
|
||||||
//---- scrollBar7 ----
|
//---- scrollBar7 ----
|
||||||
scrollBar7.putClientProperty("JScrollBar.showButtons", true);
|
scrollBar7.setShowButtons(true);
|
||||||
add(scrollBar7, "cell 2 13 1 6,growy");
|
add(scrollBar7, "cell 2 13 1 6,growy");
|
||||||
|
|
||||||
//---- scrollBar8 ----
|
//---- scrollBar8 ----
|
||||||
scrollBar8.setEnabled(false);
|
scrollBar8.setEnabled(false);
|
||||||
scrollBar8.putClientProperty("JScrollBar.showButtons", true);
|
scrollBar8.setShowButtons(true);
|
||||||
add(scrollBar8, "cell 2 13 1 6,growy");
|
add(scrollBar8, "cell 2 13 1 6,growy");
|
||||||
|
|
||||||
//---- separator2 ----
|
//---- separator2 ----
|
||||||
@@ -1173,13 +1174,13 @@ public class FlatComponentsTest
|
|||||||
|
|
||||||
//---- scrollBar5 ----
|
//---- scrollBar5 ----
|
||||||
scrollBar5.setOrientation(Adjustable.HORIZONTAL);
|
scrollBar5.setOrientation(Adjustable.HORIZONTAL);
|
||||||
scrollBar5.putClientProperty("JScrollBar.showButtons", true);
|
scrollBar5.setShowButtons(true);
|
||||||
add(scrollBar5, "cell 1 16,growx");
|
add(scrollBar5, "cell 1 16,growx");
|
||||||
|
|
||||||
//---- scrollBar6 ----
|
//---- scrollBar6 ----
|
||||||
scrollBar6.setOrientation(Adjustable.HORIZONTAL);
|
scrollBar6.setOrientation(Adjustable.HORIZONTAL);
|
||||||
scrollBar6.setEnabled(false);
|
scrollBar6.setEnabled(false);
|
||||||
scrollBar6.putClientProperty("JScrollBar.showButtons", true);
|
scrollBar6.setShowButtons(true);
|
||||||
add(scrollBar6, "cell 1 17,growx");
|
add(scrollBar6, "cell 1 17,growx");
|
||||||
|
|
||||||
//---- separatorLabel ----
|
//---- separatorLabel ----
|
||||||
|
|||||||
@@ -466,10 +466,10 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 6,growx"
|
"value": "cell 4 6,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatComboBox" ) {
|
||||||
name: "comboBox7"
|
name: "comboBox7"
|
||||||
"editable": true
|
"editable": true
|
||||||
"$client.JTextField.placeholderText": "Placeholder"
|
"placeholderText": "Placeholder"
|
||||||
auxiliary() {
|
auxiliary() {
|
||||||
"JavaCodeGenerator.typeParameters": "String"
|
"JavaCodeGenerator.typeParameters": "String"
|
||||||
}
|
}
|
||||||
@@ -522,9 +522,9 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 7,growx"
|
"value": "cell 4 7,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTextField" ) {
|
||||||
name: "textField6"
|
name: "textField6"
|
||||||
"$client.JTextField.placeholderText": "Placeholder"
|
"placeholderText": "Placeholder"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 7,growx"
|
"value": "cell 5 7,growx"
|
||||||
} )
|
} )
|
||||||
@@ -569,9 +569,9 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 8,growx"
|
"value": "cell 4 8,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatFormattedTextField" ) {
|
||||||
name: "formattedTextField5"
|
name: "formattedTextField5"
|
||||||
"$client.JTextField.placeholderText": "Placeholder"
|
"placeholderText": "Placeholder"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 8,growx"
|
"value": "cell 5 8,growx"
|
||||||
} )
|
} )
|
||||||
@@ -616,9 +616,9 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 9,growx"
|
"value": "cell 4 9,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JPasswordField" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatPasswordField" ) {
|
||||||
name: "passwordField5"
|
name: "passwordField5"
|
||||||
"$client.JTextField.placeholderText": "Placeholder"
|
"placeholderText": "Placeholder"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 9,growx"
|
"value": "cell 5 9,growx"
|
||||||
} )
|
} )
|
||||||
@@ -850,16 +850,16 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 2 13 1 6,growy"
|
"value": "cell 2 13 1 6,growy"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) {
|
||||||
name: "scrollBar7"
|
name: "scrollBar7"
|
||||||
"$client.JScrollBar.showButtons": true
|
"showButtons": true
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 2 13 1 6,growy"
|
"value": "cell 2 13 1 6,growy"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) {
|
||||||
name: "scrollBar8"
|
name: "scrollBar8"
|
||||||
"enabled": false
|
"enabled": false
|
||||||
"$client.JScrollBar.showButtons": true
|
"showButtons": true
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 2 13 1 6,growy"
|
"value": "cell 2 13 1 6,growy"
|
||||||
} )
|
} )
|
||||||
@@ -1098,18 +1098,18 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 15,growx"
|
"value": "cell 1 15,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) {
|
||||||
name: "scrollBar5"
|
name: "scrollBar5"
|
||||||
"orientation": 0
|
"orientation": 0
|
||||||
"$client.JScrollBar.showButtons": true
|
"showButtons": true
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 16,growx"
|
"value": "cell 1 16,growx"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) {
|
||||||
name: "scrollBar6"
|
name: "scrollBar6"
|
||||||
"orientation": 0
|
"orientation": 0
|
||||||
"enabled": false
|
"enabled": false
|
||||||
"$client.JScrollBar.showButtons": true
|
"showButtons": true
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 17,growx"
|
"value": "cell 1 17,growx"
|
||||||
} )
|
} )
|
||||||
|
|||||||
Reference in New Issue
Block a user