HTML: Fixed font sizes for HTML tags <h1>...<h6>, <code>, <kbd>, <big>, <small> and <samp> in HTML text for components Button, CheckBox, RadioButton, MenuItem (and subclasses), JideLabel, JideButton, JXBusyLabel and JXHyperlink. Also fixed for Label and ToolTip if using Java 11+.

This commit is contained in:
Karl Tauber
2024-05-29 18:57:45 +02:00
parent a54aeb3838
commit 261d2b1fe8
16 changed files with 557 additions and 198 deletions

View File

@@ -14,6 +14,10 @@ FlatLaf Change Log
- FlatLaf window decorations: Window top border on Windows 10 in "full window - FlatLaf window decorations: Window top border on Windows 10 in "full window
content" mode was not fully repainted when activating or deactivating window. content" mode was not fully repainted when activating or deactivating window.
(issue #809) (issue #809)
- HTML: Fixed font sizes for HTML tags `<h1>`...`<h6>`, `<code>`, `<kbd>`,
`<big>`, `<small>` and `<samp>` in HTML text for components Button, CheckBox,
RadioButton, MenuItem (and subclasses), JideLabel, JideButton, JXBusyLabel and
JXHyperlink. Also fixed for Label and ToolTip if using Java 11+.
#### Incompatibilities #### Incompatibilities

View File

@@ -300,6 +300,10 @@ public class FlatButtonUI
protected void propertyChange( AbstractButton b, PropertyChangeEvent e ) { protected void propertyChange( AbstractButton b, PropertyChangeEvent e ) {
switch( e.getPropertyName() ) { switch( e.getPropertyName() ) {
case BasicHTML.propertyKey:
FlatHTML.updateRendererCSSFontBaseSize( b );
break;
case SQUARE_SIZE: case SQUARE_SIZE:
case MINIMUM_WIDTH: case MINIMUM_WIDTH:
case MINIMUM_HEIGHT: case MINIMUM_HEIGHT:

View File

@@ -23,6 +23,7 @@ import java.lang.invoke.MethodHandles;
import java.util.Map; import java.util.Map;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.LookAndFeel; import javax.swing.LookAndFeel;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI; import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI;
@@ -102,13 +103,23 @@ public class FlatCheckBoxMenuItemUI
oldStyleValues = null; oldStyleValues = null;
} }
@Override
protected void installComponents( JMenuItem menuItem ) {
super.installComponents( menuItem );
// update HTML renderer if necessary
FlatHTML.updateRendererCSSFontBaseSize( menuItem );
}
protected FlatMenuItemRenderer createRenderer() { protected FlatMenuItemRenderer createRenderer() {
return new FlatMenuItemRenderer( menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter ); return new FlatMenuItemRenderer( menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter );
} }
@Override @Override
protected PropertyChangeListener createPropertyChangeListener( JComponent c ) { protected PropertyChangeListener createPropertyChangeListener( JComponent c ) {
return FlatStylingSupport.createPropertyChangeListener( c, this::installStyle, super.createPropertyChangeListener( c ) ); return FlatHTML.createPropertyChangeListener(
FlatStylingSupport.createPropertyChangeListener( c, this::installStyle,
super.createPropertyChangeListener( c ) ) );
} }
/** @since 2 */ /** @since 2 */

View File

@@ -0,0 +1,133 @@
/*
* Copyright 2024 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.ui;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.Document;
import javax.swing.text.LabelView;
import javax.swing.text.View;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;
/**
* @author Karl Tauber
* @since 3.5
*/
public class FlatHTML
{
private FlatHTML() {}
/**
* Adds CSS rule BASE_SIZE to the style sheet of the HTML view,
* which re-calculates font sizes based on current component font size.
* This is necessary for "absolute-size" keywords (e.g. "x-large")
* for "font-size" attributes in default style sheet (see javax/swing/text/html/default.css).
* See also <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size?retiredLocale=de#values">CSS font-size</a>.
* <p>
* This method should be invoked after {@link BasicHTML#updateRenderer(JComponent, String)}.
*/
public static void updateRendererCSSFontBaseSize( JComponent c ) {
View view = (View) c.getClientProperty( BasicHTML.propertyKey );
if( view == null )
return;
// dumpViews( view, 0 );
Document doc = view.getDocument();
if( !(doc instanceof HTMLDocument) )
return;
// add BASE_SIZE rule if necessary
// - if point size at index 7 is not 36, then probably HTML text contains BASE_SIZE rule
// - if point size at index 4 is equal to given font size, then it is not necessary to add BASE_SIZE rule
StyleSheet styleSheet = ((HTMLDocument)doc).getStyleSheet();
int fontBaseSize = c.getFont().getSize();
if( styleSheet.getPointSize( 7 ) != 36f ||
styleSheet.getPointSize( 4 ) == fontBaseSize )
return;
// BASE_SIZE rule is parsed in javax.swing.text.html.StyleSheet.addRule()
styleSheet.addRule( "BASE_SIZE " + fontBaseSize );
clearViewCaches( view );
// dumpViews( view, 0 );
}
/**
* Clears cached values in view so that CSS changes take effect.
*/
private static void clearViewCaches( View view ) {
if( view instanceof LabelView )
((LabelView)view).changedUpdate( null, null, null );
int viewCount = view.getViewCount();
for( int i = 0; i < viewCount; i++ )
clearViewCaches( view.getView( i ) );
}
public static PropertyChangeListener createPropertyChangeListener( PropertyChangeListener superListener ) {
return e -> {
if( superListener != null )
superListener.propertyChange( e );
propertyChange( e );
};
}
/**
* Invokes {@link #updateRendererCSSFontBaseSize(JComponent)}
* for {@link BasicHTML#propertyKey} property change events,
* which are fired when {@link BasicHTML#updateRenderer(JComponent, String)}
* updates the HTML view.
*/
public static void propertyChange( PropertyChangeEvent e ) {
if( BasicHTML.propertyKey.equals( e.getPropertyName() ) )
FlatHTML.updateRendererCSSFontBaseSize( (JComponent) e.getSource() );
}
/*debug
public static void dumpView( JComponent c ) {
View view = (View) c.getClientProperty( BasicHTML.propertyKey );
if( view != null )
dumpViews( view, 0 );
}
public static void dumpViews( View view, int indent ) {
for( int i = 0; i < indent; i++ )
System.out.print( " " );
System.out.print( view.getClass().isAnonymousClass() ? view.getClass().getName() : view.getClass().getSimpleName() );
if( view instanceof LabelView ) {
LabelView lview = ((LabelView)view);
Font font = lview.getFont();
Color foreground = lview.getForeground();
System.out.printf( " %2d-%-2d %-14s %d #%06x",
lview.getStartOffset(), lview.getEndOffset() - 1,
font.getName(), font.getSize(),
foreground.getRGB() & 0xffffff );
}
System.out.println();
int viewCount = view.getViewCount();
for( int i = 0; i < viewCount; i++ ) {
View child = view.getView( i );
dumpViews( child, indent + 1 );
}
}
debug*/
}

View File

@@ -22,11 +22,7 @@ import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
@@ -113,16 +109,13 @@ public class FlatLabelUI
super.installComponents( c ); super.installComponents( c );
// update HTML renderer if necessary // update HTML renderer if necessary
updateHTMLRenderer( c, c.getText(), false ); FlatHTML.updateRendererCSSFontBaseSize( c );
} }
@Override @Override
public void propertyChange( PropertyChangeEvent e ) { public void propertyChange( PropertyChangeEvent e ) {
String name = e.getPropertyName(); String name = e.getPropertyName();
if( name == "text" || name == "font" || name == "foreground" ) { if( name.equals( FlatClientProperties.STYLE ) || name.equals( FlatClientProperties.STYLE_CLASS ) ) {
JLabel label = (JLabel) e.getSource();
updateHTMLRenderer( label, label.getText(), true );
} else if( name.equals( FlatClientProperties.STYLE ) || name.equals( FlatClientProperties.STYLE_CLASS ) ) {
JLabel label = (JLabel) e.getSource(); JLabel label = (JLabel) e.getSource();
if( shared && FlatStylingSupport.hasStyleProperty( label ) ) { if( shared && FlatStylingSupport.hasStyleProperty( label ) ) {
// unshare component UI if necessary // unshare component UI if necessary
@@ -132,8 +125,10 @@ public class FlatLabelUI
installStyle( label ); installStyle( label );
label.revalidate(); label.revalidate();
label.repaint(); label.repaint();
} else }
super.propertyChange( e );
super.propertyChange( e );
FlatHTML.propertyChange( e );
} }
/** @since 2 */ /** @since 2 */
@@ -168,85 +163,6 @@ public class FlatLabelUI
return FlatStylingSupport.getAnnotatedStyleableValue( this, key ); return FlatStylingSupport.getAnnotatedStyleableValue( this, key );
} }
/**
* Checks whether text contains HTML tags that use "absolute-size" keywords
* (e.g. "x-large") for font-size in default style sheet
* (see javax/swing/text/html/default.css).
* If yes, adds a special CSS rule (BASE_SIZE) to the HTML text, which
* re-calculates font sizes based on current component font size.
*/
static void updateHTMLRenderer( JComponent c, String text, boolean always ) {
if( BasicHTML.isHTMLString( text ) &&
c.getClientProperty( "html.disable" ) != Boolean.TRUE &&
needsFontBaseSize( text ) )
{
// BASE_SIZE rule is parsed in javax.swing.text.html.StyleSheet.addRule()
String style = "<style>BASE_SIZE " + c.getFont().getSize() + "</style>";
String lowerText = text.toLowerCase( Locale.ENGLISH );
int headIndex;
int styleIndex;
int insertIndex;
if( (headIndex = lowerText.indexOf( "<head>" )) >= 0 ) {
// there is a <head> tag --> insert after <head> tag
insertIndex = headIndex + "<head>".length();
} else if( (styleIndex = lowerText.indexOf( "<style>" )) >= 0 ) {
// there is a <style> tag --> insert before <style> tag
insertIndex = styleIndex;
} else {
// no <head> or <style> tag --> insert <head> tag after <html> tag
style = "<head>" + style + "</head>";
insertIndex = "<html>".length();
}
text = text.substring( 0, insertIndex )
+ style
+ text.substring( insertIndex );
} else if( !always )
return; // not necessary to invoke BasicHTML.updateRenderer()
BasicHTML.updateRenderer( c, text );
}
private static Set<String> tagsUseFontSizeSet;
private static boolean needsFontBaseSize( String text ) {
if( tagsUseFontSizeSet == null ) {
// tags that use font-size in javax/swing/text/html/default.css
tagsUseFontSizeSet = new HashSet<>( Arrays.asList(
"h1", "h2", "h3", "h4", "h5", "h6", "code", "kbd", "big", "small", "samp" ) );
}
// search for tags in HTML text
int textLength = text.length();
for( int i = 6; i < textLength - 1; i++ ) {
if( text.charAt( i ) == '<' ) {
switch( text.charAt( i + 1 ) ) {
// first letters of tags in tagsUseFontSizeSet
case 'b': case 'B':
case 'c': case 'C':
case 'h': case 'H':
case 'k': case 'K':
case 's': case 'S':
int tagBegin = i + 1;
for( i += 2; i < textLength; i++ ) {
if( !Character.isLetterOrDigit( text.charAt( i ) ) ) {
String tag = text.substring( tagBegin, i ).toLowerCase( Locale.ENGLISH );
if( tagsUseFontSizeSet.contains( tag ) )
return true;
break;
}
}
break;
}
}
}
return false;
}
@Override @Override
public void update( Graphics g, JComponent c ) { public void update( Graphics g, JComponent c ) {
FlatPanelUI.fillRoundedBackground( g, c, arc ); FlatPanelUI.fillRoundedBackground( g, c, arc );

View File

@@ -103,13 +103,23 @@ public class FlatMenuItemUI
oldStyleValues = null; oldStyleValues = null;
} }
@Override
protected void installComponents( JMenuItem menuItem ) {
super.installComponents( menuItem );
// update HTML renderer if necessary
FlatHTML.updateRendererCSSFontBaseSize( menuItem );
}
protected FlatMenuItemRenderer createRenderer() { protected FlatMenuItemRenderer createRenderer() {
return new FlatMenuItemRenderer( menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter ); return new FlatMenuItemRenderer( menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter );
} }
@Override @Override
protected PropertyChangeListener createPropertyChangeListener( JComponent c ) { protected PropertyChangeListener createPropertyChangeListener( JComponent c ) {
return FlatStylingSupport.createPropertyChangeListener( c, this::installStyle, super.createPropertyChangeListener( c ) ); return FlatHTML.createPropertyChangeListener(
FlatStylingSupport.createPropertyChangeListener( c, this::installStyle,
super.createPropertyChangeListener( c ) ) );
} }
/** @since 2 */ /** @since 2 */

View File

@@ -136,6 +136,14 @@ public class FlatMenuUI
oldStyleValues = null; oldStyleValues = null;
} }
@Override
protected void installComponents( JMenuItem menuItem ) {
super.installComponents( menuItem );
// update HTML renderer if necessary
FlatHTML.updateRendererCSSFontBaseSize( menuItem );
}
protected FlatMenuItemRenderer createRenderer() { protected FlatMenuItemRenderer createRenderer() {
return new FlatMenuRenderer( menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter ); return new FlatMenuRenderer( menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter );
} }
@@ -167,7 +175,9 @@ public class FlatMenuUI
@Override @Override
protected PropertyChangeListener createPropertyChangeListener( JComponent c ) { protected PropertyChangeListener createPropertyChangeListener( JComponent c ) {
return FlatStylingSupport.createPropertyChangeListener( c, this::installStyle, super.createPropertyChangeListener( c ) ); return FlatHTML.createPropertyChangeListener(
FlatStylingSupport.createPropertyChangeListener( c, this::installStyle,
super.createPropertyChangeListener( c ) ) );
} }
/** @since 2 */ /** @since 2 */

View File

@@ -23,6 +23,7 @@ import java.lang.invoke.MethodHandles;
import java.util.Map; import java.util.Map;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.LookAndFeel; import javax.swing.LookAndFeel;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicMenuItemUI; import javax.swing.plaf.basic.BasicMenuItemUI;
@@ -102,13 +103,23 @@ public class FlatRadioButtonMenuItemUI
oldStyleValues = null; oldStyleValues = null;
} }
@Override
protected void installComponents( JMenuItem menuItem ) {
super.installComponents( menuItem );
// update HTML renderer if necessary
FlatHTML.updateRendererCSSFontBaseSize( menuItem );
}
protected FlatMenuItemRenderer createRenderer() { protected FlatMenuItemRenderer createRenderer() {
return new FlatMenuItemRenderer( menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter ); return new FlatMenuItemRenderer( menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter );
} }
@Override @Override
protected PropertyChangeListener createPropertyChangeListener( JComponent c ) { protected PropertyChangeListener createPropertyChangeListener( JComponent c ) {
return FlatStylingSupport.createPropertyChangeListener( c, this::installStyle, super.createPropertyChangeListener( c ) ); return FlatHTML.createPropertyChangeListener(
FlatStylingSupport.createPropertyChangeListener( c, this::installStyle,
super.createPropertyChangeListener( c ) ) );
} }
/** @since 2 */ /** @since 2 */

View File

@@ -40,6 +40,7 @@ import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicButtonListener; import javax.swing.plaf.basic.BasicButtonListener;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.plaf.basic.BasicRadioButtonUI; import javax.swing.plaf.basic.BasicRadioButtonUI;
import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.icons.FlatCheckBoxIcon; import com.formdev.flatlaf.icons.FlatCheckBoxIcon;
@@ -159,6 +160,10 @@ public class FlatRadioButtonUI
/** @since 2 */ /** @since 2 */
protected void propertyChange( AbstractButton b, PropertyChangeEvent e ) { protected void propertyChange( AbstractButton b, PropertyChangeEvent e ) {
switch( e.getPropertyName() ) { switch( e.getPropertyName() ) {
case BasicHTML.propertyKey:
FlatHTML.updateRendererCSSFontBaseSize( b );
break;
case FlatClientProperties.STYLE: case FlatClientProperties.STYLE:
case FlatClientProperties.STYLE_CLASS: case FlatClientProperties.STYLE_CLASS:
if( shared && FlatStylingSupport.hasStyleProperty( b ) ) { if( shared && FlatStylingSupport.hasStyleProperty( b ) ) {

View File

@@ -61,7 +61,7 @@ public class FlatToolTipUI
super.installUI( c ); super.installUI( c );
// update HTML renderer if necessary // update HTML renderer if necessary
FlatLabelUI.updateHTMLRenderer( c, ((JToolTip)c).getTipText(), false ); FlatHTML.updateRendererCSSFontBaseSize( c );
} }
@Override @Override
@@ -81,11 +81,7 @@ public class FlatToolTipUI
/** @since 2.0.1 */ /** @since 2.0.1 */
@Override @Override
public void propertyChange( PropertyChangeEvent e ) { public void propertyChange( PropertyChangeEvent e ) {
String name = e.getPropertyName(); FlatHTML.propertyChange( e );
if( name == "tiptext" || name == "font" || name == "foreground" ) {
JToolTip toolTip = (JToolTip) e.getSource();
FlatLabelUI.updateHTMLRenderer( toolTip, toolTip.getTipText(), false );
}
} }
@Override @Override

View File

@@ -16,9 +16,14 @@
package com.formdev.flatlaf.jideoss.ui; package com.formdev.flatlaf.jideoss.ui;
import java.beans.PropertyChangeEvent;
import javax.swing.AbstractButton;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicButtonListener;
import com.formdev.flatlaf.ui.FlatHTML;
import com.jidesoft.plaf.LookAndFeelFactory; import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.plaf.basic.BasicJideButtonListener;
import com.jidesoft.plaf.basic.BasicJideButtonUI; import com.jidesoft.plaf.basic.BasicJideButtonUI;
/** /**
@@ -37,4 +42,26 @@ public class FlatJideButtonUI
return new FlatJideButtonUI(); return new FlatJideButtonUI();
} }
@Override
protected BasicButtonListener createButtonListener( AbstractButton b ) {
return new FlatJideButtonListener( b );
}
//---- class FlatJideButtonListener ---------------------------------------
/** @since 3.5 */
protected class FlatJideButtonListener
extends BasicJideButtonListener
{
protected FlatJideButtonListener( AbstractButton b ) {
super( b );
}
@Override
public void propertyChange( PropertyChangeEvent e ) {
super.propertyChange( e );
FlatHTML.propertyChange( e );
}
}
} }

View File

@@ -18,11 +18,13 @@ package com.formdev.flatlaf.jideoss.ui;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.beans.PropertyChangeEvent;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.ui.FlatHTML;
import com.formdev.flatlaf.ui.FlatUIUtils; import com.formdev.flatlaf.ui.FlatUIUtils;
import com.jidesoft.plaf.LookAndFeelFactory; import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.plaf.basic.BasicJideLabelUI; import com.jidesoft.plaf.basic.BasicJideLabelUI;
@@ -65,6 +67,20 @@ public class FlatJideLabelUI
defaults_initialized = false; defaults_initialized = false;
} }
@Override
protected void installComponents( JLabel c ) {
super.installComponents( c );
// update HTML renderer if necessary
FlatHTML.updateRendererCSSFontBaseSize( c );
}
@Override
public void propertyChange( PropertyChangeEvent e ) {
super.propertyChange( e );
FlatHTML.propertyChange( e );
}
@Override @Override
protected void paintEnabledText( JLabel l, Graphics g, String s, int textX, int textY ) { protected void paintEnabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1; int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1;

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.swingx.ui;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.beans.PropertyChangeEvent;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.UIManager; import javax.swing.UIManager;
@@ -25,6 +26,7 @@ import javax.swing.plaf.ComponentUI;
import org.jdesktop.swingx.JXBusyLabel; import org.jdesktop.swingx.JXBusyLabel;
import org.jdesktop.swingx.plaf.basic.BasicBusyLabelUI; import org.jdesktop.swingx.plaf.basic.BasicBusyLabelUI;
import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.ui.FlatHTML;
import com.formdev.flatlaf.ui.FlatUIUtils; import com.formdev.flatlaf.ui.FlatUIUtils;
//TODO scale busy spinner //TODO scale busy spinner
@@ -70,6 +72,20 @@ public class FlatBusyLabelUI
disabledForeground = null; disabledForeground = null;
} }
@Override
protected void installComponents( JLabel c ) {
super.installComponents( c );
// update HTML renderer if necessary
FlatHTML.updateRendererCSSFontBaseSize( c );
}
@Override
public void propertyChange( PropertyChangeEvent e ) {
super.propertyChange( e );
FlatHTML.propertyChange( e );
}
@Override @Override
protected void paintDisabledText( JLabel l, Graphics g, String s, int textX, int textY ) { protected void paintDisabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1; int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1;

View File

@@ -21,12 +21,15 @@ import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.beans.PropertyChangeEvent;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicButtonListener;
import org.jdesktop.swingx.plaf.basic.BasicHyperlinkUI; import org.jdesktop.swingx.plaf.basic.BasicHyperlinkUI;
import com.formdev.flatlaf.ui.FlatButtonUI; import com.formdev.flatlaf.ui.FlatButtonUI;
import com.formdev.flatlaf.ui.FlatHTML;
import com.formdev.flatlaf.ui.FlatUIUtils; import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.util.UIScale; import com.formdev.flatlaf.util.UIScale;
@@ -60,6 +63,11 @@ public class FlatHyperlinkUI
disabledText = null; disabledText = null;
} }
@Override
protected BasicButtonListener createButtonListener( AbstractButton b ) {
return new FlatHyperlinkListener( b );
}
@Override @Override
protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text ) { protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text ) {
FlatButtonUI.paintText( g, b, textRect, text, b.isEnabled() ? b.getForeground() : disabledText ); FlatButtonUI.paintText( g, b, textRect, text, b.isEnabled() ? b.getForeground() : disabledText );
@@ -79,4 +87,21 @@ public class FlatHyperlinkUI
FlatUIUtils.resetRenderingHints( g, oldRenderingHints ); FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
//---- class FlatHyperlinkListener ----------------------------------------
/** @since 3.5 */
protected class FlatHyperlinkListener
extends BasicHyperlinkListener
{
protected FlatHyperlinkListener( AbstractButton b ) {
super( b );
}
@Override
public void propertyChange( PropertyChangeEvent e ) {
super.propertyChange( e );
FlatHTML.propertyChange( e );
}
}
} }

View File

@@ -18,8 +18,10 @@ package com.formdev.flatlaf.testing;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.JTextComponent;
import com.formdev.flatlaf.util.StringUtils; import com.formdev.flatlaf.util.StringUtils;
import com.formdev.flatlaf.util.UIScale; import com.formdev.flatlaf.util.UIScale;
import com.jidesoft.swing.*;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
import org.jdesktop.swingx.*; import org.jdesktop.swingx.*;
@@ -53,6 +55,58 @@ public class FlatHtmlTest
increaseFontSize(); increaseFontSize();
} }
private void changeHtmlText() {
changeHtmlText( this );
}
private void changeHtmlText( Component c ) {
if( c instanceof AbstractButton )
((AbstractButton)c).setText( changeHtmlText( ((AbstractButton)c).getText() ) );
else if( c instanceof JLabel )
((JLabel)c).setText( changeHtmlText( ((JLabel)c).getText() ) );
else if( c instanceof JTextComponent )
((JTextComponent)c).setText( changeHtmlText( ((JTextComponent)c).getText() ) );
else if( c instanceof JToolTip )
((JToolTip)c).setTipText( changeHtmlText( ((JToolTip)c).getTipText() ) );
else if( c instanceof JComboBox ) {
@SuppressWarnings( "unchecked" )
JComboBox<String> cb = (JComboBox<String>) c;
DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) cb.getModel();
String text = model.getElementAt( 0 );
String newText = changeHtmlText( text );
if( newText != text ) {
model.insertElementAt( newText, 1 );
model.removeElementAt( 0 );
}
}
if( c instanceof Container ) {
for( Component child : ((Container)c).getComponents() )
changeHtmlText( child );
}
}
private String changeHtmlText( String text ) {
String htmlTag = "<html>";
if( !text.startsWith( htmlTag ) )
return text;
String bodyTag = "<body>";
int bodyIndex = text.indexOf( bodyTag );
if( bodyIndex < 0 )
bodyIndex = htmlTag.length();
else
bodyIndex += bodyTag.length();
int insertIndex = text.indexOf( '>', bodyIndex );
if( insertIndex < 0 )
insertIndex = bodyIndex;
else
insertIndex++;
return text.substring( 0, insertIndex ) + "X" + text.substring( insertIndex );
}
private void initComponents() { private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel labelLabel = new JLabel(); JLabel labelLabel = new JLabel();
@@ -88,14 +142,28 @@ public class FlatHtmlTest
JRadioButtonMenuItem radioButtonMenuItem1 = new JRadioButtonMenuItem(); JRadioButtonMenuItem radioButtonMenuItem1 = new JRadioButtonMenuItem();
JRadioButtonMenuItem radioButtonMenuItem2 = new JRadioButtonMenuItem(); JRadioButtonMenuItem radioButtonMenuItem2 = new JRadioButtonMenuItem();
JLabel label14 = new JLabel(); JLabel label14 = new JLabel();
JLabel label15 = new JLabel(); JToolTip toolTip3 = new JToolTip();
JLabel label16 = new JLabel(); JToolTip toolTip4 = new JToolTip();
JLabel label17 = new JLabel(); JLabel label17 = new JLabel();
JComboBox<String> comboBox1 = new JComboBox<>(); JComboBox<String> comboBox1 = new JComboBox<>();
JComboBox<String> comboBox2 = new JComboBox<>(); JComboBox<String> comboBox2 = new JComboBox<>();
JLabel label56 = new JLabel();
JXBusyLabel xBusyLabel1 = new JXBusyLabel();
JXBusyLabel xBusyLabel2 = new JXBusyLabel();
JLabel label18 = new JLabel(); JLabel label18 = new JLabel();
JXHyperlink xHyperlink1 = new JXHyperlink(); JXHyperlink xHyperlink1 = new JXHyperlink();
JXHyperlink xHyperlink2 = new JXHyperlink(); JXHyperlink xHyperlink2 = new JXHyperlink();
JLabel label33 = new JLabel();
JideLabel jideLabel1 = new JideLabel();
JideLabel jideLabel2 = new JideLabel();
JLabel label16 = new JLabel();
JideButton jideButton1 = new JideButton();
JideButton jideButton2 = new JideButton();
JLabel label54 = new JLabel();
JideToggleButton jideToggleButton1 = new JideToggleButton();
JideToggleButton jideToggleButton2 = new JideToggleButton();
JButton changeHtmlTextButton = new JButton();
JLabel label15 = new JLabel();
label1 = new JLabel(); label1 = new JLabel();
JScrollPane scrollPane15 = new JScrollPane(); JScrollPane scrollPane15 = new JScrollPane();
editorPane1 = new JEditorPane(); editorPane1 = new JEditorPane();
@@ -143,13 +211,10 @@ public class FlatHtmlTest
JLabel label47 = new JLabel(); JLabel label47 = new JLabel();
JLabel label53 = new JLabel(); JLabel label53 = new JLabel();
JLabel label48 = new JLabel(); JLabel label48 = new JLabel();
JLabel label54 = new JLabel();
JLabel label56 = new JLabel();
JLabel label57 = new JLabel();
//======== this ======== //======== this ========
setLayout(new MigLayout( setLayout(new MigLayout(
"ltr,insets dialog,hidemode 3", "flowy,ltr,insets dialog,hidemode 3",
// columns // columns
"[grow,sizegroup 1,fill]" + "[grow,sizegroup 1,fill]" +
"[grow,sizegroup 1,fill]" + "[grow,sizegroup 1,fill]" +
@@ -196,6 +261,12 @@ public class FlatHtmlTest
"[]" + "[]" +
"[]" + "[]" +
"[]" + "[]" +
"[]unrel" +
"[]" +
"[]unrel" +
"[]" +
"[]" +
"[]para" +
"[]" + "[]" +
"[]")); "[]"));
@@ -204,7 +275,7 @@ public class FlatHtmlTest
panel1.add(label5, "cell 0 0"); panel1.add(label5, "cell 0 0");
//---- label6 ---- //---- label6 ----
label6.setText("<html>Some <b>Bold</b> Text"); label6.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(label6, "cell 1 0"); panel1.add(label6, "cell 1 0");
//---- label7 ---- //---- label7 ----
@@ -212,11 +283,11 @@ public class FlatHtmlTest
panel1.add(label7, "cell 2 0"); panel1.add(label7, "cell 2 0");
//---- label3 ---- //---- label3 ----
label3.setText("JButon:"); label3.setText("JButton:");
panel1.add(label3, "cell 0 1"); panel1.add(label3, "cell 0 1");
//---- button1 ---- //---- button1 ----
button1.setText("<html>Some <b>Bold</b> Text"); button1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(button1, "cell 1 1"); panel1.add(button1, "cell 1 1");
//---- button2 ---- //---- button2 ----
@@ -228,7 +299,7 @@ public class FlatHtmlTest
panel1.add(label11, "cell 0 2"); panel1.add(label11, "cell 0 2");
//---- toggleButton1 ---- //---- toggleButton1 ----
toggleButton1.setText("<html>Some <b>Bold</b> Text"); toggleButton1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
toggleButton1.setSelected(true); toggleButton1.setSelected(true);
panel1.add(toggleButton1, "cell 1 2"); panel1.add(toggleButton1, "cell 1 2");
@@ -242,7 +313,7 @@ public class FlatHtmlTest
panel1.add(label12, "cell 0 3"); panel1.add(label12, "cell 0 3");
//---- checkBox1 ---- //---- checkBox1 ----
checkBox1.setText("<html>Some <b>Bold</b> Text"); checkBox1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(checkBox1, "cell 1 3"); panel1.add(checkBox1, "cell 1 3");
//---- checkBox2 ---- //---- checkBox2 ----
@@ -254,7 +325,7 @@ public class FlatHtmlTest
panel1.add(label13, "cell 0 4"); panel1.add(label13, "cell 0 4");
//---- radioButton1 ---- //---- radioButton1 ----
radioButton1.setText("<html>Some <b>Bold</b> Text"); radioButton1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(radioButton1, "cell 1 4"); panel1.add(radioButton1, "cell 1 4");
//---- radioButton2 ---- //---- radioButton2 ----
@@ -267,7 +338,7 @@ public class FlatHtmlTest
//======== menu1 ======== //======== menu1 ========
{ {
menu1.setText("<html>Some <b>Bold</b> Text"); menu1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
} }
panel1.add(menu1, "cell 1 5"); panel1.add(menu1, "cell 1 5");
@@ -282,7 +353,7 @@ public class FlatHtmlTest
panel1.add(label4, "cell 0 6"); panel1.add(label4, "cell 0 6");
//---- menuItem1 ---- //---- menuItem1 ----
menuItem1.setText("<html>Some <b>Bold</b> Text"); menuItem1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(menuItem1, "cell 1 6"); panel1.add(menuItem1, "cell 1 6");
//---- menuItem2 ---- //---- menuItem2 ----
@@ -294,7 +365,7 @@ public class FlatHtmlTest
panel1.add(label9, "cell 0 7"); panel1.add(label9, "cell 0 7");
//---- checkBoxMenuItem1 ---- //---- checkBoxMenuItem1 ----
checkBoxMenuItem1.setText("<html>Some <b>Bold</b> Text"); checkBoxMenuItem1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
checkBoxMenuItem1.setSelected(true); checkBoxMenuItem1.setSelected(true);
panel1.add(checkBoxMenuItem1, "cell 1 7"); panel1.add(checkBoxMenuItem1, "cell 1 7");
@@ -308,7 +379,7 @@ public class FlatHtmlTest
panel1.add(label10, "cell 0 8"); panel1.add(label10, "cell 0 8");
//---- radioButtonMenuItem1 ---- //---- radioButtonMenuItem1 ----
radioButtonMenuItem1.setText("<html>Some <b>Bold</b> Text"); radioButtonMenuItem1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
radioButtonMenuItem1.setSelected(true); radioButtonMenuItem1.setSelected(true);
panel1.add(radioButtonMenuItem1, "cell 1 8"); panel1.add(radioButtonMenuItem1, "cell 1 8");
@@ -321,15 +392,13 @@ public class FlatHtmlTest
label14.setText("JToolTip:"); label14.setText("JToolTip:");
panel1.add(label14, "cell 0 9"); panel1.add(label14, "cell 0 9");
//---- label15 ---- //---- toolTip3 ----
label15.setText("(move mouse here)"); toolTip3.setTipText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
label15.setToolTipText("<html>Some <b>Bold</b> Text"); panel1.add(toolTip3, "cell 1 9");
panel1.add(label15, "cell 1 9");
//---- label16 ---- //---- toolTip4 ----
label16.setText("(move mouse here)"); toolTip4.setTipText("Some text");
label16.setToolTipText("Some text"); panel1.add(toolTip4, "cell 2 9");
panel1.add(label16, "cell 2 9");
//---- label17 ---- //---- label17 ----
label17.setText("JComboBox:"); label17.setText("JComboBox:");
@@ -337,7 +406,7 @@ public class FlatHtmlTest
//---- comboBox1 ---- //---- comboBox1 ----
comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { comboBox1.setModel(new DefaultComboBoxModel<>(new String[] {
"<html>Some <b>Bold</b> Text", "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>",
"abc", "abc",
"def" "def"
})); }));
@@ -351,19 +420,76 @@ public class FlatHtmlTest
})); }));
panel1.add(comboBox2, "cell 2 10"); panel1.add(comboBox2, "cell 2 10");
//---- label56 ----
label56.setText("JXBusyLabel:");
panel1.add(label56, "cell 0 11");
//---- xBusyLabel1 ----
xBusyLabel1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(xBusyLabel1, "cell 1 11");
//---- xBusyLabel2 ----
xBusyLabel2.setText("Some text");
panel1.add(xBusyLabel2, "cell 2 11");
//---- label18 ---- //---- label18 ----
label18.setText("JXHyperlink:"); label18.setText("JXHyperlink:");
panel1.add(label18, "cell 0 11"); panel1.add(label18, "cell 0 12");
//---- xHyperlink1 ---- //---- xHyperlink1 ----
xHyperlink1.setText("<html>Some <b>Bold</b> Text"); xHyperlink1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(xHyperlink1, "cell 1 11"); panel1.add(xHyperlink1, "cell 1 12");
//---- xHyperlink2 ---- //---- xHyperlink2 ----
xHyperlink2.setText("Some text"); xHyperlink2.setText("Some text");
panel1.add(xHyperlink2, "cell 2 11"); panel1.add(xHyperlink2, "cell 2 12");
//---- label33 ----
label33.setText("JideLabel:");
panel1.add(label33, "cell 0 13");
//---- jideLabel1 ----
jideLabel1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(jideLabel1, "cell 1 13");
//---- jideLabel2 ----
jideLabel2.setText("Some text");
panel1.add(jideLabel2, "cell 2 13");
//---- label16 ----
label16.setText("JideButton:");
panel1.add(label16, "cell 0 14");
//---- jideButton1 ----
jideButton1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(jideButton1, "cell 1 14");
//---- jideButton2 ----
jideButton2.setText("Some text");
panel1.add(jideButton2, "cell 2 14");
//---- label54 ----
label54.setText("JideToggleButton:");
panel1.add(label54, "cell 0 15");
//---- jideToggleButton1 ----
jideToggleButton1.setText("<html>Some <b>Bold</b> Text <kbd>kbd</kbd>");
panel1.add(jideToggleButton1, "cell 1 15");
//---- jideToggleButton2 ----
jideToggleButton2.setText("Some text");
panel1.add(jideToggleButton2, "cell 2 15");
//---- changeHtmlTextButton ----
changeHtmlTextButton.setText("Change HTML Text");
changeHtmlTextButton.addActionListener(e -> changeHtmlText());
panel1.add(changeHtmlTextButton, "cell 0 16");
//---- label15 ----
label15.setText("(use to check whether CSS is updated on text changes)");
panel1.add(label15, "cell 0 17 3 1");
} }
add(panel1, "cell 4 0 1 2,aligny top,growy 0"); add(panel1, "cell 4 0 1 3,aligny top,growy 0");
//---- label1 ---- //---- label1 ----
label1.setText("<html>HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a><h1>Header 1</h1><h2>Header 2</h2><h3>Header 3</h3><h4>Header 4</h4><h5>Header 5</h5><h6>Header 6</h6><p>Paragraph</p><address>Address</address><hr><table border=\"1\"><tr><th>Col 1</th><th>Col 2</th></tr><tr><td>abc</td><td>def</td></tr></table><ul><li>item 1</li><li>item 2</li></ul></html>"); label1.setText("<html>HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a><h1>Header 1</h1><h2>Header 2</h2><h3>Header 3</h3><h4>Header 4</h4><h5>Header 5</h5><h6>Header 6</h6><p>Paragraph</p><address>Address</address><hr><table border=\"1\"><tr><th>Col 1</th><th>Col 2</th></tr><tr><td>abc</td><td>def</td></tr></table><ul><li>item 1</li><li>item 2</li></ul></html>");
@@ -441,10 +567,6 @@ public class FlatHtmlTest
"[]" + "[]" +
"[]" + "[]" +
"[]" + "[]" +
"[]para" +
"[]para" +
"[]" +
"[]" +
"[]")); "[]"));
//---- label22 ---- //---- label22 ----
@@ -582,20 +704,8 @@ public class FlatHtmlTest
//---- label48 ---- //---- label48 ----
label48.setText("<html><address>address</address></html>"); label48.setText("<html><address>address</address></html>");
panel2.add(label48, "cell 1 5"); panel2.add(label48, "cell 1 5");
//---- label54 ----
label54.setText("Test whether inserted rule affects display:");
panel2.add(label54, "cell 0 7 7 1");
//---- label56 ----
label56.setText("<html><head><style>body { color: red }</style></head>leading <big>red</big> trailing</html>");
panel2.add(label56, "cell 0 8 7 1");
//---- label57 ----
label57.setText("<html><style>body { color: red }</style><p>leading <big>red</big> trailing</p></html>");
panel2.add(label57, "cell 0 9 7 1");
} }
add(panel2, "cell 4 2"); add(panel2, "cell 4 0 1 3");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
} }

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8" JFDML JFormDesigner: "8.2.2.0.9999" Java: "21.0.1" encoding: "UTF-8"
new FormModel { new FormModel {
contentType: "form/swing" contentType: "form/swing"
@@ -7,7 +7,7 @@ new FormModel {
"JavaCodeGenerator.defaultVariableLocal": true "JavaCodeGenerator.defaultVariableLocal": true
} }
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3" "$layoutConstraints": "flowy,ltr,insets dialog,hidemode 3"
"$columnConstraints": "[grow,sizegroup 1,fill][grow,sizegroup 1,fill][grow,sizegroup 1,fill][grow,sizegroup 1,fill][fill]" "$columnConstraints": "[grow,sizegroup 1,fill][grow,sizegroup 1,fill][grow,sizegroup 1,fill][grow,sizegroup 1,fill][fill]"
"$rowConstraints": "[][fill][grow,fill]" "$rowConstraints": "[][fill][grow,fill]"
} ) { } ) {
@@ -39,7 +39,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3" "$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[fill][fill][fill]" "$columnConstraints": "[fill][fill][fill]"
"$rowConstraints": "[][][][][][][][][][][][]" "$rowConstraints": "[][][][][][][][][][][]unrel[][]unrel[][][]para[][]"
} ) { } ) {
name: "panel1" name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
@@ -50,7 +50,7 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6" name: "label6"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0" "value": "cell 1 0"
} ) } )
@@ -62,13 +62,13 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3" name: "label3"
"text": "JButon:" "text": "JButton:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1" "value": "cell 0 1"
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "javax.swing.JButton" ) {
name: "button1" name: "button1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1" "value": "cell 1 1"
} ) } )
@@ -86,7 +86,7 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton1" name: "toggleButton1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
"selected": true "selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2" "value": "cell 1 2"
@@ -106,7 +106,7 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "checkBox1" name: "checkBox1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3" "value": "cell 1 3"
} ) } )
@@ -124,7 +124,7 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JRadioButton" ) { add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton1" name: "radioButton1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4" "value": "cell 1 4"
} ) } )
@@ -142,7 +142,7 @@ new FormModel {
} ) } )
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu1" name: "menu1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5" "value": "cell 1 5"
} ) } )
@@ -160,7 +160,7 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JMenuItem" ) { add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem1" name: "menuItem1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6" "value": "cell 1 6"
} ) } )
@@ -178,7 +178,7 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) { add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "checkBoxMenuItem1" name: "checkBoxMenuItem1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
"selected": true "selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7" "value": "cell 1 7"
@@ -198,7 +198,7 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) { add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) {
name: "radioButtonMenuItem1" name: "radioButtonMenuItem1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
"selected": true "selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 8" "value": "cell 1 8"
@@ -216,17 +216,15 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9" "value": "cell 0 9"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JToolTip" ) {
name: "label15" name: "toolTip3"
"text": "(move mouse here)" "tipText": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
"toolTipText": "<html>Some <b>Bold</b> Text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 9" "value": "cell 1 9"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JToolTip" ) {
name: "label16" name: "toolTip4"
"text": "(move mouse here)" "tipText": "Some text"
"toolTipText": "Some text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 9" "value": "cell 2 9"
} ) } )
@@ -239,8 +237,8 @@ new FormModel {
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox1" name: "comboBox1"
"model": new javax.swing.DefaultComboBoxModel { "model": new javax.swing.DefaultComboBoxModel {
selectedItem: "<html>Some <b>Bold</b> Text" selectedItem: "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
addElement( "<html>Some <b>Bold</b> Text" ) addElement( "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>" )
addElement( "abc" ) addElement( "abc" )
addElement( "def" ) addElement( "def" )
} }
@@ -259,25 +257,110 @@ new FormModel {
"value": "cell 2 10" "value": "cell 2 10"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label18" name: "label56"
"text": "JXHyperlink:" "text": "JXBusyLabel:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11" "value": "cell 0 11"
} ) } )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) { add( new FormComponent( "org.jdesktop.swingx.JXBusyLabel" ) {
name: "xHyperlink1" name: "xBusyLabel1"
"text": "<html>Some <b>Bold</b> Text" "text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 11" "value": "cell 1 11"
} ) } )
add( new FormComponent( "org.jdesktop.swingx.JXBusyLabel" ) {
name: "xBusyLabel2"
"text": "Some text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 11"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label18"
"text": "JXHyperlink:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 12"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink1"
"text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 12"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) { add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink2" name: "xHyperlink2"
"text": "Some text" "text": "Some text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 11" "value": "cell 2 12"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label33"
"text": "JideLabel:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 13"
} )
add( new FormComponent( "com.jidesoft.swing.JideLabel" ) {
name: "jideLabel1"
"text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 13"
} )
add( new FormComponent( "com.jidesoft.swing.JideLabel" ) {
name: "jideLabel2"
"text": "Some text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label16"
"text": "JideButton:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 14"
} )
add( new FormComponent( "com.jidesoft.swing.JideButton" ) {
name: "jideButton1"
"text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 14"
} )
add( new FormComponent( "com.jidesoft.swing.JideButton" ) {
name: "jideButton2"
"text": "Some text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 14"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label54"
"text": "JideToggleButton:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 15"
} )
add( new FormComponent( "com.jidesoft.swing.JideToggleButton" ) {
name: "jideToggleButton1"
"text": "<html>Some <b>Bold</b> Text <kbd>kbd</kbd>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 15"
} )
add( new FormComponent( "com.jidesoft.swing.JideToggleButton" ) {
name: "jideToggleButton2"
"text": "Some text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 15"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "changeHtmlTextButton"
"text": "Change HTML Text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "changeHtmlText", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 16"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label15"
"text": "(use to check whether CSS is updated on text changes)"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 17 3 1"
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 0 1 2,aligny top,growy 0" "value": "cell 4 0 1 3,aligny top,growy 0"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1" name: "label1"
@@ -372,7 +455,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3" "$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[fill]para[fill][fill][fill][fill][fill][fill]" "$columnConstraints": "[fill]para[fill][fill][fill][fill][fill][fill]"
"$rowConstraints": "[][][][][][]para[]para[][][]" "$rowConstraints": "[][][][][][]"
} ) { } ) {
name: "panel2" name: "panel2"
auxiliary() { auxiliary() {
@@ -582,30 +665,12 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5" "value": "cell 1 5"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label54"
"text": "Test whether inserted rule affects display:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7 7 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label56"
"text": "<html><head><style>body { color: red }</style></head>leading <big>red</big> trailing</html>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 7 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label57"
"text": "<html><style>body { color: red }</style><p>leading <big>red</big> trailing</p></html>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9 7 1"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 2" "value": "cell 4 0 1 3"
} ) } )
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 ) "location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 905, 815 ) "size": new java.awt.Dimension( 905, 880 )
} ) } )
} }
} }