/*
* 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): .
*/
/*
* ConfigureButtonsSample.java
*
* Created on 15. September 2006, 00:14
*/
package samples.swing.action;
import java.awt.event.ActionEvent;
import java.util.Locale;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import org.softsmithy.lib.swing.action.AbstractXAction;
import org.softsmithy.lib.swing.action.GeneralActionFactory;
import org.softsmithy.lib.swing.action.IconType;
import org.softsmithy.lib.swing.action.XAction;
import org.softsmithy.lib.swing.action.XActions;
/**
*
* @author puce
*/
public class ConfigureButtonsSample extends javax.swing.JFrame {
/** Creates new form ConfigureButtonsSample */
public ConfigureButtonsSample() {
initComponents();
XAction[] xActions = createActions();
addMenuItems(xActions);
addToolbarStandardButtons(xActions);
addToolbarCoolButtons(xActions);
setSize(500, 300);
}
/** 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() {
jPanel1 = new javax.swing.JPanel();
toolBarStandard = new javax.swing.JToolBar();
toolBarCool = new javax.swing.JToolBar();
jMenuBar1 = new javax.swing.JMenuBar();
menu = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Configure Buttons Sample");
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jPanel1.add(toolBarStandard);
jPanel1.add(toolBarCool);
getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
menu.setText("Menu");
jMenuBar1.add(menu);
setJMenuBar(jMenuBar1);
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 ConfigureButtonsSample().setVisible(true);
}
});
}
private void addMenuItems(XAction[] xActions ) {
for (int i=0; i < xActions.length; i++){
JMenuItem item = new JMenuItem();
XActions.configureButton(item, xActions[i], IconType.SMALL_ICON, true, false);
menu.add(item);
}
}
private void addToolbarStandardButtons(XAction[] xActions ) {
for (int i=0; i < xActions.length; i++){
JButton button = new JButton();
XActions.configureButton(button, xActions[i], IconType.LARGE_ICON, false, false);
toolBarStandard.add(button);
}
}
private void addToolbarCoolButtons(XAction[] xActions ) {
for (int i=0; i < xActions.length; i++){
JButton button = new JButton();
XActions.configureButton(button, xActions[i], IconType.LARGE_ICON, false, true);
toolBarCool.add(button);
}
}
private XAction[] createActions() {
GeneralActionFactory[] factories = {GeneralActionFactory.CUT, GeneralActionFactory.COPY, GeneralActionFactory.PASTE};
XAction[] xActions = new XAction[factories.length];
for (int i=0; i