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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
package com.explodingpixels.macwidgets;
import javax.swing.ComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.JTextField;
import com.explodingpixels.macwidgets.plaf.HudButtonUI;
import com.explodingpixels.macwidgets.plaf.HudCheckBoxUI;
import com.explodingpixels.macwidgets.plaf.HudComboBoxUI;
import com.explodingpixels.macwidgets.plaf.HudLabelUI;
import com.explodingpixels.macwidgets.plaf.HudPasswordFieldUI;
import com.explodingpixels.macwidgets.plaf.HudRadioButtonUI;
import com.explodingpixels.macwidgets.plaf.HudSliderUI;
import com.explodingpixels.macwidgets.plaf.HudTextFieldUI;
/**
* A factory for creating HUD style widgets. These widgets should be added to a
* {@link com.explodingpixels.macwidgets.HudWindow}.
*/
public class HudWidgetFactory {
private HudWidgetFactory() {
// utility class - no constructor needed.
}
/**
* Creates a Heads Up Display (HUD) style label, similar to that seen in various iApps (e.g.
* iPhoto).
* <br/><br/>
* <img src="../../../../graphics/HUDLabelUI.png">
*
* @param labelText the text of the label.
* @return the HUD style label.
* @see HudLabelUI
*/
public static JLabel createHudLabel(String labelText) {
JLabel label = new JLabel(labelText);
label.setUI(new HudLabelUI());
return label;
}
/**
* Creates a Heads Up Display (HUD) style button, similar to that seen in various iApps (e.g.
* iPhoto).
* <br/><br/>
* <img src="../../../../graphics/HUDButtonUI.png">
*
* @param buttonText the text of the button.
* @return the HUD style button.
* @see HudButtonUI
*/
public static JButton createHudButton(String buttonText) {
JButton button = new JButton(buttonText);
button.setUI(new HudButtonUI());
return button;
}
/**
* Creates a Heads Up Display (HUD) style check box, similar to that seen in various iApps (e.g.
* iPhoto).
* <br/><br/>
* <img src="../../../../graphics/HUDCheckBoxUI.png">
*
* @param checkBoxText the text of the check box.
* @return the HUD style check box.
* @see HudCheckBoxUI
*/
public static JCheckBox createHudCheckBox(String checkBoxText) {
JCheckBox checkBox = new JCheckBox(checkBoxText);
checkBox.setUI(new HudCheckBoxUI());
return checkBox;
}
/**
* Creates a Heads Up Display (HUD) style combo box, similar to that seen in various iApps (e.g.
* iPhoto).
* <br/><br/>
* <img src="../../../../graphics/HUDComboBoxUI.png">
*
* @param model the model containing the combo box items.
* @return the HUD style combo box.
* @see HudComboBoxUI
*/
public static JComboBox createHudComboBox(ComboBoxModel model) {
JComboBox comboBox = new JComboBox(model);
comboBox.setUI(new HudComboBoxUI());
return comboBox;
}
/**
* Creates a Heads Up Display (HUD) style text field, similar to that seen in various iApps
* (e.g. iPhoto).
* <br/><br/>
* <img src="../../../../graphics/HUDTextFieldUI.png">
*
* @param text the initial text in the text field.
* @return the HUD style text field.
* @see HudTextFieldUI
*/
public static JTextField createHudTextField(String text) {
JTextField textField = new JTextField(text);
textField.setUI(new HudTextFieldUI());
return textField;
}
/**
* Creates a Heads Up Display (HUD) style password field, similar to that seen in various iApps
* (e.g. iPhoto).
* <br/><br/>
*
* @param text the initial text in the password field.
* @return the HUD style password field.
* @see HudPasswordFieldUI
*/
public static JPasswordField createHudPasswordField(String text) {
JPasswordField passwordField = new JPasswordField(text);
passwordField.setUI(new HudPasswordFieldUI());
return passwordField;
}
/**
* Creates a Heads Up Display (HUD) style radio button, similar to that seen in various iApps
* (e.g. iPhoto).
* <br/><br/>
* <img src="../../../../graphics/HUDRadioButtonUI.png">
*
* @param text the text of the radio button.
* @return the HUD style radio button.
* @see HudRadioButtonUI
*/
public static JRadioButton createHudRadioButton(String text) {
JRadioButton radioButton = new JRadioButton(text);
radioButton.setUI(new HudRadioButtonUI());
return radioButton;
}
/**
* Creates a Heads Up Display (HUD) style slider, similar to that seen in various iApps
* (e.g. iPhoto).
* <br/><br/>
* <img src="../../../../../graphics/HUDSliderUI-round.png">
* <br/>
* <img src="../../../../../graphics/HUDSliderUI-pointy.png">
*
* @return the HUD style slider.
* @see HudSliderUI
*/
public static JSlider createHudSlider() {
JSlider slider = new JSlider();
slider.setUI(new HudSliderUI(slider));
return slider;
}
}
|