All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.alantea.swing.action.LabeledActionButton Maven / Gradle / Ivy

The newest version!
package net.alantea.swing.action;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import net.alantea.swing.layout.percent.PercentConstraints;
import net.alantea.swing.layout.percent.PercentLayout;
import net.alantea.swing.layout.percent.Where;
import net.alantea.utils.MultiMessages;

/**
 * The Class LabeledTextField.
 */
public class LabeledActionButton extends JPanel
{
   
   /** The Constant serialVersionUID. */
   private static final long serialVersionUID = 1L;
   
   /** The label. */
   private JLabel label;

   /** The button. */
   private JButton button;
   
    /**
     * Instantiates a new labeled button field.
     *
     * @param parent the parent
     * @param target the target
     * @param actionKey the action key
     */
    public LabeledActionButton(JPanel parent, Object target, String actionKey)
    {
       super();
       setLayout(new PercentLayout());
       
       button = new ActionButton(this, target, actionKey);
       PercentConstraints fieldConstraints = new PercentConstraints(0, 0, 0, 0.0);
       fieldConstraints.setXReferent(null, Where.FAR);
       fieldConstraints.setWReferent(null, Where.PREFERRED);
       fieldConstraints.setHReferent(null, Where.PREFERRED);
       add(button, fieldConstraints);

       label = new JLabel();
       PercentConstraints labelConstraints = new PercentConstraints(0, 0, 0.0, 1.0);
       fieldConstraints.setWReferent(button, Where.BEFORE);
       add(label, labelConstraints);
       
       parent.add(this);
    }
    
    /**
     * Sets the label text.
     *
     * @param value the new label text
     */
    public void setLabelText(String value)
    {
       label.setText(MultiMessages.get(value));
    }
    
    /**
     * Gets the label.
     *
     * @return the label
     */
    public JLabel getLabel()
    {
       return label;
    }
    
    /**
     * Gets the text field.
     *
     * @return the text field
     */
   public JButton getButton()
   {
      return button;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy