litesoft
@ 947
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.aokeyhole.swing.namevaluecomponents; import org.litesoft.aokeyhole.swing.simplecomponents.*; import org.litesoft.aokeyhole.toolkit.*; import javax.swing.*; import java.awt.*; public abstract class LabeledComponent extends JPanelPlus implements VerticalGrowableIndicatingComponent { protected String mLabelText; private boolean mShouldUiIndicateRequired; protected JLabel mLabel = null; protected LabeledComponent( LabeledComponentParams pParams ) { mLabelText = pParams.getLabel(); mShouldUiIndicateRequired = pParams.shouldUiIndicateRequired(); } public LabeledComponent initialize() { buildPanel(); return this; } @Override public boolean growsVertically() { return false; } protected void buildPanel() { setLayout( new BorderLayout() ); add( createNorthContent(), BorderLayout.NORTH ); add( new JLabel( " " ), BorderLayout.WEST ); add( createCenterContent(), BorderLayout.CENTER ); } protected JComponent createNorthContent() { return createLabel(); } protected JComponent createLabel() { String label = mLabelText + ":"; if ( mShouldUiIndicateRequired ) { label += " *"; } return mLabel = new JLabel( label ); } abstract protected JComponent createCenterContent(); } |