/*
* @(#)CheckBoxTest.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.*;
/**
* CheckBoxTest.
*
* @author Werner Randelshofer
* @version 1.0 13 February 2005 Created.
*/
public class CheckBoxTest extends javax.swing.JPanel {
/** Creates new form. */
public CheckBoxTest() {
initComponents();
for (JComponent c:new JComponent[]{smallCheckBox1,smallCheckBox2,smallLabel}) {
c.putClientProperty("JComponent.sizeVariant","small");
}
for (JComponent c:new JComponent[]{miniCheckBox1,miniCheckBox2,miniLabel}) {
c.putClientProperty("JComponent.sizeVariant","mini");
}
// Try to get a better layout with J2SE6
try {
int BASELINE_LEADING = GridBagConstraints.class.getDeclaredField("BASELINE_LEADING").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);
}
}
} catch (Exception ex) {
// bail
}
}
public static void main(String args[]) {
try {
UIManager.setLookAndFeel(QuaquaManager.getLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
JFrame f = new JFrame("Quaqua CheckBox Test");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new CheckBoxTest());
((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;
checkBox1 = new javax.swing.JCheckBox();
enabledLabel = new javax.swing.JLabel();
checkBox2 = new javax.swing.JCheckBox();
disabledLabel = new javax.swing.JLabel();
separator = new javax.swing.JSeparator();
smallLabel = new javax.swing.JLabel();
smallCheckBox1 = new javax.swing.JCheckBox();
smallCheckBox2 = new javax.swing.JCheckBox();
separator1 = new javax.swing.JSeparator();
miniLabel = new javax.swing.JLabel();
miniCheckBox1 = new javax.swing.JCheckBox();
miniCheckBox2 = new javax.swing.JCheckBox();
jSeparator1 = new javax.swing.JSeparator();
bigCheckBox = new javax.swing.JCheckBox();
bigLabel = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
setBorder(javax.swing.BorderFactory.createEmptyBorder(16, 17, 17, 17));
setLayout(new java.awt.GridBagLayout());
checkBox1.setSelected(true);
checkBox1.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(checkBox1, 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);
checkBox2.setSelected(true);
checkBox2.setText("Ångström H");
checkBox2.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(checkBox2, 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 = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(8, 0, 8, 0);
add(separator, 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);
smallCheckBox1.setSelected(true);
smallCheckBox1.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(smallCheckBox1, gridBagConstraints);
smallCheckBox2.setSelected(true);
smallCheckBox2.setText("Ångström H");
smallCheckBox2.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(smallCheckBox2, 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(separator1, 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);
miniCheckBox1.setSelected(true);
miniCheckBox1.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(miniCheckBox1, gridBagConstraints);
miniCheckBox2.setSelected(true);
miniCheckBox2.setText("Ångström H");
miniCheckBox2.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(miniCheckBox2, 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);
bigCheckBox.setFont(new java.awt.Font("Lucida Grande", 0, 24));
bigCheckBox.setText("Ångström H");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(bigCheckBox, gridBagConstraints);
bigLabel.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(bigLabel, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 99;
gridBagConstraints.weighty = 1.0;
add(jPanel1, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox bigCheckBox;
private javax.swing.JLabel bigLabel;
private javax.swing.JCheckBox checkBox1;
private javax.swing.JCheckBox checkBox2;
private javax.swing.JLabel disabledLabel;
private javax.swing.JLabel enabledLabel;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JCheckBox miniCheckBox1;
private javax.swing.JCheckBox miniCheckBox2;
private javax.swing.JLabel miniLabel;
private javax.swing.JSeparator separator;
private javax.swing.JSeparator separator1;
private javax.swing.JCheckBox smallCheckBox1;
private javax.swing.JCheckBox smallCheckBox2;
private javax.swing.JLabel smallLabel;
// End of variables declaration//GEN-END:variables
}