本文整理匯總了Java中java.awt.Choice.addItem方法的典型用法代碼示例。如果您正苦於以下問題:Java Choice.addItem方法的具體用法?Java Choice.addItem怎麽用?Java Choice.addItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Choice
的用法示例。
在下文中一共展示了Choice.addItem方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DrawControls
import java.awt.Choice; //導入方法依賴的package包/類
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
this.target = target;
setLayout(new FlowLayout());
setBackground(Color.lightGray);
target.setForeground(Color.red);
CheckboxGroup group = new CheckboxGroup();
Checkbox b;
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.red);
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.green);
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.blue);
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.pink);
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.orange);
add(b = new Checkbox(null, group, true));
b.addItemListener(this);
b.setForeground(Color.black);
target.setForeground(b.getForeground());
Choice shapes = new Choice();
shapes.addItemListener(this);
shapes.addItem("Lines");
shapes.addItem("Points");
shapes.setBackground(Color.lightGray);
add(shapes);
}
示例2: CardTest
import java.awt.Choice; //導入方法依賴的package包/類
@SuppressWarnings("LeakingThisInConstructor")
public CardTest() {
setLayout(new BorderLayout());
add("Center", cards = new CardPanel(this));
Panel p = new Panel();
p.setLayout(new FlowLayout());
add("South", p);
Button b = new Button("first");
b.addActionListener(this);
p.add(b);
b = new Button("next");
b.addActionListener(this);
p.add(b);
b = new Button("previous");
b.addActionListener(this);
p.add(b);
b = new Button("last");
b.addActionListener(this);
p.add(b);
Choice c = new Choice();
c.addItem("one");
c.addItem("two");
c.addItem("three");
c.addItem("four");
c.addItem("five");
c.addItem("six");
c.addItemListener(this);
p.add(c);
}
示例3: drawForm
import java.awt.Choice; //導入方法依賴的package包/類
public void drawForm()
{
removeAll();
cRightAxis = new Choice();
Panel mainPanel = new Panel();
mainPanel.setLayout( new GridLayout(recorder.plotSize + 2, 0) );
mainPanel.add(L1);
cRightAxis.addItem("Parameters (0 to 1)");
cRightAxis.addItem("Currents");
mainPanel.add(cRightAxis);
for (int x = 0; x < recorder.plotSize; x++)
{
c[x] = new Checkbox(recorder.names[x] );
c[x].setForeground( recorder.colorArray[x] );
c[x].setState( recorder.plot[x] );
mainPanel.add(c[x]);
}
setLayout( new BorderLayout());
add("Center", mainPanel);
validate();
}
示例4: updateComboBox
import java.awt.Choice; //導入方法依賴的package包/類
private void updateComboBox(Choice certificateComboBox){
certificateComboBox.removeAll();
certificateComboBox.addItem("Loading Certificates...");
certificateComboBox.select(0);
ArrayList<CertificateData> certList = new ArrayList<CertificateData>();
try {
certList = signEngine.loadSmartCardCertificateList(readAllCertificates).certificateList;
} catch (Exception e) {
e.printStackTrace();
SignUtils.playBeeps(1);
JOptionPane.showMessageDialog(null, "ERROR LOADING CERTIFICATES:\n"+e.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
}
certificateComboBox.removeAll();
certificateComboBox.addItem("--Select Certificate--");
for(int i=0;i<certList.size();i++)
certificateComboBox.addItem(certList.get(i).id);
if(certificateComboBox.getItemCount()==1){
certificateComboBox.removeAll();
certificateComboBox.addItem("--No Certificates Available!--");
SignUtils.playBeeps(2);
}
else{
if(certificateComboBox.getItemCount()==2){
certificateComboBox.remove(0);
}
SignUtils.playBeeps(1);
}
}
示例5: ProfileSelector
import java.awt.Choice; //導入方法依賴的package包/類
/**
* Create the dialog.
*/
public ProfileSelector() {
setTitle("Puma-Pass - Profile Select");
setBounds(100, 100, 250, 135);
setMinimumSize(new Dimension(250, 135));
ImageIcon img = new ImageIcon("res/logo.png");
setIconImage(img.getImage());
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(null);
//
Choice choice = new Choice();
choice.setBounds(91, 10, 100, 20);
contentPanel.add(choice);
Vault.checkManifest();
this.profileNames = Vault.getProfileList();
if (profileNames != null)
{
for (int z = 0; z < profileNames.size(); z++)
{
choice.addItem(profileNames.get(z));
}
}
passwordField = new JPasswordField();
passwordField.setBounds(91, 36, 100, 20);
contentPanel.add(passwordField);
JLabel lblProfile = new JLabel("Profile:");
lblProfile.setBounds(10, 10, 75, 14);
contentPanel.add(lblProfile);
JLabel lblPassword = new JLabel("Password:");
lblPassword.setBounds(10, 36, 75, 14);
contentPanel.add(lblPassword);
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
JButton btnCancel = new JButton("Cancel");
buttonPane.add(btnCancel);
JButton btnCreateNew = new JButton("Create New");
buttonPane.add(btnCreateNew);
JButton btnLogin = new JButton("Login");
buttonPane.add(btnLogin);
}
}
示例6: main
import java.awt.Choice; //導入方法依賴的package包/類
public static void main(String[] args) {
String s = "Java Tips";
final int size = 64;
if (args.length > 0)
s = args[0];
Panel controls = new Panel();
final Choice choice = new Choice();
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
Font[] allFonts = ge.getAllFonts();
for (int i = 0; i < allFonts.length; i++)
choice.addItem(allFonts[i].getName());
Font defaultFont = new Font(allFonts[0].getName(), Font.PLAIN, size);
final TextBouncer bouncer = new TextBouncer(s, defaultFont);
Frame f = new AnimationFrame(bouncer);
f.setFont(new Font("Serif", Font.PLAIN, 12));
controls.add(bouncer.createCheckbox("Antialiasing",
TextBouncer.ANTIALIASING));
controls.add(bouncer.createCheckbox("Gradient", TextBouncer.GRADIENT));
controls.add(bouncer.createCheckbox("Shear", TextBouncer.SHEAR));
controls.add(bouncer.createCheckbox("Rotate", TextBouncer.ROTATE));
controls.add(bouncer.createCheckbox("Axes", TextBouncer.AXES));
Panel fontControls = new Panel();
choice.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent ie) {
Font font = new Font(choice.getSelectedItem(), Font.PLAIN, size);
bouncer.setFont(font);
}
});
fontControls.add(choice);
Panel allControls = new Panel(new GridLayout(2, 1));
allControls.add(controls);
allControls.add(fontControls);
f.add(allControls, BorderLayout.NORTH);
f.setSize(300,300);
f.setVisible(true);
}
示例7: StyleCellEditor
import java.awt.Choice; //導入方法依賴的package包/類
/**
* Create a new instance of StyleCellEditor.
*/
public StyleCellEditor(JTextField textField, StyleEditor styleEditor)
{
super(textField);
editField = textField;
this.styleEditor = styleEditor;
// Establish representation for inclusion choices.
inclusionCheckbox = new JCheckBox();
// Establish menu for inclusion choices.
volumeChoiceMenu = new Choice();
for( int i = VOLUME_MAX; i >= VOLUME_MIN; i-- )
{
volumeChoiceMenu.addItem("" + i);
}
}