/*
* @(#)ButtonTest.java 1.0 13 February 2005
*
* Copyright (c) 2004 Werner Randelshofer, Immensee, Switzerland.
* All rights reserved.
*
* You may not use, copy or modify this file, except in compliance with the
* license agreement you entered into with Werner Randelshofer.
* For details see accompanying license terms.
*/
package test;
import ch.randelshofer.quaqua.*;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.*;
import javax.swing.border.*;
/**
* ButtonTest.
*
* @author Werner Randelshofer
* @version 1.0 13 February 2005 Created.
*/
public class PushButtonTest extends javax.swing.JPanel {
/** Creates new form. */
public PushButtonTest() {
initComponents();
// Client properties for the Aqua Look and Feel TN2196
// https://developer.apple.com/mac/library/technotes/tn2007/tn2196.html
for (JComponent c : new JComponent[]{smallDisabledButton, smallEnabledButton,
smallLabel}) {
c.putClientProperty("JComponent.sizeVariant", "small");
}
for (JComponent c : new JComponent[]{miniDisabledButton, miniEnabledButton,
miniLabel}) {
c.putClientProperty("JComponent.sizeVariant", "mini");
}
/*
for (JComponent c:new JComponent[]{largeButton,largeLabel}) {
c.putClientProperty("JComponent.sizeVariant","large");
}*/
// Try to get a better layout with J2SE6
try {
int BASELINE_LEADING = GridBagConstraints.class.getDeclaredField("BASELINE_LEADING").getInt(null);
int BASELINE = GridBagConstraints.class.getDeclaredField("BASELINE").getInt(null);
GridBagLayout layout = (GridBagLayout) getLayout();
for (Component c : getComponents()) {
GridBagConstraints gbc = layout.getConstraints(c);
if (gbc.anchor == GridBagConstraints.WEST) {
gbc.anchor = BASELINE_LEADING;
layout.setConstraints(c, gbc);
} else if (gbc.anchor == GridBagConstraints.CENTER) {
gbc.anchor = BASELINE;
layout.setConstraints(c, gbc);
}
}
} catch (Exception ex) {
// bail
}
}
/*
public void paint(Graphics g) {
long start = System.currentTimeMillis();
super.paint(g);
long end = System.currentTimeMillis();
System.out.println(end - start);
}*/
public static void main(String args[]) {
try {
UIManager.setLookAndFeel(QuaquaManager.getLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
JFrame f = new JFrame("Quaqua Push Button Test");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new PushButtonTest());
((JComponent) f.getContentPane()).setBorder(new EmptyBorder(9, 17, 17, 17));
f.pack();
f.setVisible(true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
enabledButton = new javax.swing.JButton();
enabledLabel = new javax.swing.JLabel();
disabledButton = new javax.swing.JButton();
disabledLabel = new javax.swing.JLabel();
jSeparator2 = new javax.swing.JSeparator();
smallEnabledButton = new javax.swing.JButton();
smallLabel = new javax.swing.JLabel();
smallDisabledButton = new javax.swing.JButton();
jSeparator3 = new javax.swing.JSeparator();
miniEnabledButton = new javax.swing.JButton();
miniDisabledButton = new javax.swing.JButton();
miniLabel = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
largeButton = new javax.swing.JButton();
largeLabel = new javax.swing.JLabel();
borderNotPaintedButton = new javax.swing.JButton();
borderNotPaintedLabel = new javax.swing.JLabel();
borderlessButton = new javax.swing.JButton();
borderlessLabel = new javax.swing.JLabel();
zeroMarginButton = new javax.swing.JButton();
zeroMarginLabel = new javax.swing.JLabel();
coloredButton = new javax.swing.JButton();
coloredLabel = new javax.swing.JLabel();
borderlessColoredButton = new javax.swing.JButton();
borderlessColoredLabel = new javax.swing.JLabel();
springPanel = new javax.swing.JPanel();
setBorder(javax.swing.BorderFactory.createEmptyBorder(16, 17, 17, 17));
setLayout(new java.awt.GridBagLayout());
enabledButton.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(enabledButton, gridBagConstraints);
enabledLabel.setText("Enabled");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(enabledLabel, gridBagConstraints);
disabledButton.setText("Ångström H");
disabledButton.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(disabledButton, gridBagConstraints);
disabledLabel.setText("Disabled");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(disabledLabel, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(8, 0, 8, 0);
add(jSeparator2, gridBagConstraints);
smallEnabledButton.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(smallEnabledButton, gridBagConstraints);
smallLabel.setText("Small");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(smallLabel, gridBagConstraints);
smallDisabledButton.setText("Ångström H");
smallDisabledButton.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(smallDisabledButton, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(8, 0, 8, 0);
add(jSeparator3, gridBagConstraints);
miniEnabledButton.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(miniEnabledButton, gridBagConstraints);
miniDisabledButton.setText("Ångström H");
miniDisabledButton.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(miniDisabledButton, gridBagConstraints);
miniLabel.setText("Mini");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(miniLabel, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(8, 0, 8, 0);
add(jSeparator1, gridBagConstraints);
largeButton.setFont(new java.awt.Font("Dialog", 0, 24));
largeButton.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(largeButton, gridBagConstraints);
largeLabel.setText("Large Font");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(largeLabel, gridBagConstraints);
borderNotPaintedButton.setText("Ångström H");
borderNotPaintedButton.setBorderPainted(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(borderNotPaintedButton, gridBagConstraints);
borderNotPaintedLabel.setText("Border not painted");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(borderNotPaintedLabel, gridBagConstraints);
borderlessButton.setText("Ångström H");
borderlessButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(borderlessButton, gridBagConstraints);
borderlessLabel.setText("Empty Border");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(borderlessLabel, gridBagConstraints);
zeroMarginButton.setText("Ångström H");
zeroMarginButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(zeroMarginButton, gridBagConstraints);
zeroMarginLabel.setText("Zero Margin");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(zeroMarginLabel, gridBagConstraints);
coloredButton.setBackground(new java.awt.Color(181, 212, 107));
coloredButton.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(coloredButton, gridBagConstraints);
coloredLabel.setText("Colored");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(coloredLabel, gridBagConstraints);
borderlessColoredButton.setBackground(new java.awt.Color(181, 212, 107));
borderlessColoredButton.setText("Ångström H");
borderlessColoredButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
borderlessColoredButton.setBorderPainted(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
add(borderlessColoredButton, gridBagConstraints);
borderlessColoredLabel.setText("Empty Border & Colored");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
add(borderlessColoredLabel, gridBagConstraints);
springPanel.setLayout(new java.awt.BorderLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.weighty = 1.0;
add(springPanel, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton borderNotPaintedButton;
private javax.swing.JLabel borderNotPaintedLabel;
private javax.swing.JButton borderlessButton;
private javax.swing.JButton borderlessColoredButton;
private javax.swing.JLabel borderlessColoredLabel;
private javax.swing.JLabel borderlessLabel;
private javax.swing.JButton coloredButton;
private javax.swing.JLabel coloredLabel;
private javax.swing.JButton disabledButton;
private javax.swing.JLabel disabledLabel;
private javax.swing.JButton enabledButton;
private javax.swing.JLabel enabledLabel;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JButton largeButton;
private javax.swing.JLabel largeLabel;
private javax.swing.JButton miniDisabledButton;
private javax.swing.JButton miniEnabledButton;
private javax.swing.JLabel miniLabel;
private javax.swing.JButton smallDisabledButton;
private javax.swing.JButton smallEnabledButton;
private javax.swing.JLabel smallLabel;
private javax.swing.JPanel springPanel;
private javax.swing.JButton zeroMarginButton;
private javax.swing.JLabel zeroMarginLabel;
// End of variables declaration//GEN-END:variables
}