/*
* COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Notice
*
* The contents of this file are subject to the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.opensource.org/licenses/cddl1.txt
*
* The Original Code is SoftSmithy Utility Library. The Initial Developer of the
* Original Code is Florian Brunner (Sourceforge.net user: puce). All Rights Reserved.
*
* Contributor(s): .
*/
/*
* TextCustomizersSample.java
*
* Created on 8. April 2007, 12:49
*/
package samples.swing.customizer;
import java.awt.Color;
import javax.swing.JCheckBox;
import javax.swing.JRadioButton;
import org.softsmithy.lib.swing.customizer.JButtonCustomizer;
import org.softsmithy.lib.swing.customizer.JHtmlCustomizer;
import org.softsmithy.lib.swing.customizer.JLabelCustomizer;
import org.softsmithy.lib.swing.customizer.layout.AbsoluteTableConstraints;
import org.softsmithy.lib.swing.customizer.layout.InfiniteTableLayout;
/**
*
* @author Florian
*/
public class TextCustomizersSample extends javax.swing.JFrame {
/** Creates new form TextCustomizersSample */
public TextCustomizersSample() {
initComponents();
// create a CustomizerLayout
InfiniteTableLayout itl = new InfiniteTableLayout(customizerPane);
// set the layout
customizerPane.setCustomizerLayout(itl);
// create a JLabelCustomizer, which supports inline editing of a text
JLabelCustomizer labelCustomizer = new JLabelCustomizer("A Label Customizer - double click to edit!");
// add it to the JCustomizerPane
customizerPane.addCustomizer(labelCustomizer, new AbsoluteTableConstraints(50, 50, 270, 20, labelCustomizer, itl));
// create a JButtonCustomizer to customize a button using the String constructor.
JButtonCustomizer buttonCustomizer = new JButtonCustomizer("Double click to edit this button!");
// add it to the JCustomizerPane
customizerPane.addCustomizer(buttonCustomizer, new AbsoluteTableConstraints(300, 100, 210, 50, buttonCustomizer, itl));
// create a JButtonCustomizer to customize a JCheckBox
JButtonCustomizer checkBoxCustomizer = new JButtonCustomizer(new JCheckBox("Double click to edit this check box!", true));
// set the background color to white
checkBoxCustomizer.setBackground(Color.WHITE);
// add it to the JCustomizerPane
customizerPane.addCustomizer(checkBoxCustomizer, new AbsoluteTableConstraints(30, 160, 250, 20, checkBoxCustomizer, itl));
// create a JButtonCustomizer to customize a JRadioButton
JButtonCustomizer radioButtonCustomizer = new JButtonCustomizer(new JRadioButton("Double click to edit this radio button!", true));
// set the background color to white
radioButtonCustomizer.setBackground(Color.WHITE);
// add it to the JCustomizerPane
customizerPane.addCustomizer(radioButtonCustomizer, new AbsoluteTableConstraints(300, 200, 270, 20, radioButtonCustomizer, itl));
// create a JHtmlCustomizer, which supports inline editing of a text
JHtmlCustomizer htmlCustomizer = new JHtmlCustomizer();
// set some HTML text
htmlCustomizer.setHtmlBody("This is an editable HTML text! Double click!
" +
"This is a link!
" +
"And this " +
"is a " +
"colored text!
" +
"This is a very long text that shows automatic line wrapping!");
// add it to the JCustomizerPane
customizerPane.addCustomizer(htmlCustomizer, new AbsoluteTableConstraints(150, 250, 270, 150, htmlCustomizer, itl));
setSize(640, 480);
}
/** 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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
contentPane = new javax.swing.JPanel();
contentScrollPane = new javax.swing.JScrollPane();
customizerPane = new org.softsmithy.lib.swing.customizer.JCustomizerPane();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("A Text Customizers Sample");
contentPane.setLayout(new java.awt.BorderLayout());
contentScrollPane.setViewportView(customizerPane);
contentPane.add(contentScrollPane, java.awt.BorderLayout.CENTER);
getContentPane().add(contentPane, java.awt.BorderLayout.CENTER);
pack();
}// //GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TextCustomizersSample().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel contentPane;
private javax.swing.JScrollPane contentScrollPane;
private org.softsmithy.lib.swing.customizer.JCustomizerPane customizerPane;
// End of variables declaration//GEN-END:variables
}