protected void init() { addPropertyChangeListener( "action", new ActionUpdateHandler() ); putClientProperty( "JButton.buttonType", "square" ); putClientProperty( "JComponent.sizeVariant", "small" ); setHorizontalTextPosition( JButton.CENTER ); setVerticalTextPosition( JButton.BOTTOM ); revalidateAction(); }
/** * Creates a button with initial text and an icon. * * @param text the text of the button * @param icon the Icon image to display on the button */ public ToolbarButton( final String text, final Icon icon ) { super( text, icon ); init(); }
private void revalidateAction() { final Action a = getAction(); if ( a == null ) { putClientProperty( "hideActionText", Boolean.FALSE ); // NON-NLS } else { if ( a.getValue( Action.SMALL_ICON ) != null || a.getValue( Action.LARGE_ICON_KEY ) != null ) { putClientProperty( "hideActionText", Boolean.TRUE ); // NON-NLS } else { putClientProperty( "hideActionText", Boolean.FALSE );// NON-NLS } } } }
operatorButtonPanel.setOpaque( false ); operatorButtonPanel.setLayout( new HorizontalLayout( 2 ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "+", Messages.getInstance().getString( "FormulaEditorDialog.Operator.Add" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "-", Messages.getInstance().getString( "FormulaEditorDialog.Operator.Subtract" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "*", Messages.getInstance().getString( "FormulaEditorDialog.Operator.Multiply" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "/", Messages.getInstance().getString( "FormulaEditorDialog.Operator.Divide" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "^", Messages.getInstance().getString( "FormulaEditorDialog.Operator.Power" ) ) ) ); operatorButtonPanel.add( Box.createRigidArea( new Dimension( 10, 1 ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "=", Messages.getInstance().getString( "FormulaEditorDialog.Operator.Equal" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "<>", Messages.getInstance().getString( "FormulaEditorDialog.Operator.NotEqual" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "<", Messages.getInstance().getString( "FormulaEditorDialog.Operator.Lesser" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( ">", Messages.getInstance().getString( "FormulaEditorDialog.Operator.Greater" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( "<=", Messages.getInstance().getString( "FormulaEditorDialog.Operator.LesserEqual" ) ) ) ); operatorButtonPanel.add( new ToolbarButton ( new InsertOperatorAction( ">=",
/** * Creates a button with no set text or icon. */ public ToolbarButton() { init(); }
/** * Creates a button with an icon. * * @param icon the Icon image to display on the button */ public ToolbarButton( final Icon icon ) { super( icon ); init(); }
/** * Creates a button with text. * * @param text the text of the button */ public ToolbarButton( final String text ) { super( text ); init(); }
/** * Creates a button where properties are taken from the <code>Action</code> supplied. * * @param a the <code>Action</code> used to specify the new button * @since 1.3 */ public ToolbarButton( final Action a ) { super( a ); init(); }