1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| import java.awt.Image; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JRootPane; import org.pushingpixels.substance.api.SubstanceLookAndFeel; import org.pushingpixels.substance.internal.ui.SubstanceRootPaneUI; import org.pushingpixels.substance.internal.utils.SubstanceTitlePane;
public class TitlePane extends SubstanceTitlePane {
private static final long serialVersionUID = 1L;
public TitlePane(JRootPane root, SubstanceRootPaneUI ui) { super(root, ui); }
public static void editTitleBar(JFrame frame, String titleText ) { JComponent title = SubstanceLookAndFeel.getTitlePaneComponent(frame); JLabel titleLabel = new JLabel("<html><font style=\"font-size:12px;\">"+titleText+"</font></html>"); int size = (int)(titleLabel.getFont().getSize2D() / 72 * 300); titleLabel.setBounds(32, 0, size * titleText.length(),23); titleLabel.putClientProperty( "substancelaf.internal.titlePane.extraComponentKind", ExtraComponentKind.TRAILING); title.add(titleLabel, 0); }
public static void editTitleBar(JFrame frame, Icon icon) { JComponent title = SubstanceLookAndFeel.getTitlePaneComponent(frame); ((ImageIcon)icon).getImage().getScaledInstance(24,24,Image.SCALE_DEFAULT); JLabel titleLabel = new JLabel(icon); titleLabel.setBounds(32, 0, 24,24); titleLabel.putClientProperty( "substancelaf.internal.titlePane.extraComponentKind", ExtraComponentKind.TRAILING); title.add(titleLabel, -1); }
public static void editTitleBar(JFrame frame, JComponent component) { JComponent title = SubstanceLookAndFeel.getTitlePaneComponent(frame); component.putClientProperty( "substancelaf.internal.titlePane.extraComponentKind", ExtraComponentKind.TRAILING); title.add(component, 0); } }
|