Package java.awt

Examples of java.awt.Choice$ChoiceStateController


public class remove implements Testlet
{

  public void test(TestHarness harness)
  {
    Choice c = new Choice();
   
    // testing remove with only one item
    harness.check(c.getSelectedIndex(), -1);
    harness.check(c.getItemCount(), 0);
    c.add("item1");
    harness.check(c.getSelectedIndex(), 0);
    harness.check(c.getItemCount(), 1);
    c.select(0);
    harness.check(c.getSelectedIndex(), 0);
    c.remove(0);
    harness.check(c.getSelectedIndex(), -1);
    harness.check(c.getItemCount(), 0);
   
    // testing remove with two items
    c.add("item1");
    c.add("item2");
    harness.check(c.getItemCount(), 2);
    c.select(0);
    harness.check(c.getSelectedIndex(), 0);
    c.select(1);
    harness.check(c.getSelectedIndex(), 1);
    c.remove(1);
    harness.check(c.getSelectedIndex(), 0);
    harness.check(c.getItemCount(), 1);
    c.remove(0);
    harness.check(c.getSelectedIndex(), -1);
    harness.check(c.getItemCount(), 0);
   
    // testing remove with more than two items
    harness.check(c.getSelectedIndex(), -1);
    c.add("item1");
    harness.check(c.getSelectedIndex(), 0);
    c.add("item2");
    harness.check(c.getSelectedIndex(), 0);
    c.add("item3");
    harness.check(c.getSelectedIndex(), 0);
    c.add("item4");
    harness.check(c.getSelectedIndex(), 0);   
    harness.check(c.getItemCount(), 4);
    c.select(2);
    harness.check(c.getSelectedIndex(), 2);
    c.select(1);
    harness.check(c.getSelectedIndex(), 1);
    c.remove(1);
    harness.check(c.getSelectedIndex(), 0);
    harness.check(c.getItemCount(), 3);
    c.remove(0);
    harness.check(c.getSelectedIndex(), 0);
    harness.check(c.getItemCount(), 2);
    c.remove(0);
    harness.check(c.getSelectedIndex(), 0);
    harness.check(c.getItemCount(), 1);
    c.remove(0);
    harness.check(c.getSelectedIndex(), -1);
    harness.check(c.getItemCount(), 0);
   
    // testing remove with invalid indexes.
    boolean fail = false;
    try
      {
        c.remove(2);
      }
    catch (ArrayIndexOutOfBoundsException e)
      {
        fail = true;
      }
    harness.check(fail);
   
    // testing remove on last index
    c.add("item1");
    c.add("item2");
    c.add("item3");
    harness.check(c.getSelectedIndex(), 0);
    c.select(2);
    harness.check(c.getSelectedIndex(), 2);
    c.remove(2);
    harness.check(c.getSelectedIndex(), 0);
  }
View Full Code Here


        pText.setBackground(SystemColor.control);
        pLabel.setBackground(SystemColor.control);
        pButton.setBackground(SystemColor.control);
        pLabel.add(createLabel("Recent:"));

        recent = new Choice();

        try {
            settings = ConnectionDialogCommon.loadRecentConnectionSettings();
        } catch (java.io.IOException ioe) {
            ioe.printStackTrace();
        }

        recent.add(ConnectionDialogCommon.emptySettingName);

        Enumeration en = settings.elements();

        while (en.hasMoreElements()) {
            recent.add(((ConnectionSetting) en.nextElement()).getName());
        }

        recent.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {

                String s = (String) e.getItem();
                ConnectionSetting setting =
                    (ConnectionSetting) settings.get(s);

                if (setting != null) {
                    mName.setText(setting.getName());
                    mDriver.setText(setting.getDriver());
                    mURL.setText(setting.getUrl());
                    mUser.setText(setting.getUser());
                    mPassword.setText(setting.getPassword());
                }
            }
        });
        pText.add(recent);

        Button b;

        b = new Button("Clr");

        b.setActionCommand("Clear");
        b.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                ConnectionDialogCommon.deleteRecentConnectionSettings();

                settings = new Hashtable();

                recent.removeAll();
                recent.add(ConnectionDialogCommon.emptySettingName);
                mName.setText(null);
            }
        });
        pClearButton.add(b);
        pLabel.add(createLabel("Setting Name:"));

        mName = new TextField("");

        pText.add(mName);
        pLabel.add(createLabel("Type:"));

        types     = new Choice();
        connTypes = ConnectionDialogCommon.getTypes();

        for (int i = 0; i < connTypes.length; i++) {
            types.add(connTypes[i][0]);
        }
View Full Code Here

        panSetting.add(tooltipDelay);

        tempPanel.add(panSetting);

        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));
        unitStartChar = new Choice();
        // Add option for "A, B, C, D..."
        unitStartChar.addItem("\u0041, \u0042, \u0043, \u0044..."); //$NON-NLS-1$
        // Add option for "ALPHA, BETA, GAMMA, DELTA..."
        unitStartChar.addItem("\u0391, \u0392, \u0393, \u0394..."); //$NON-NLS-1$
        // Add option for "alpha, beta, gamma, delta..."
        unitStartChar.addItem("\u03B1, \u03B2, \u03B3, \u03B4..."); //$NON-NLS-1$
        panSetting.add(unitStartChar);
        panSetting.add(new Label(Messages
                .getString("CommonSettingsDialog.protoMechUnitCodes"))); //$NON-NLS-1$

        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));
        panSetting.add(new Label(Messages
                .getString("CommonSettingsDialog.pathFiderTimeLimit"))); //$NON-NLS-1$
        maxPathfinderTime = new TextField(5);
        panSetting.add(maxPathfinderTime);
        tempPanel.add(panSetting);

        getFocus = new Checkbox(Messages
                .getString("CommonSettingsDialog.getFocus")); //$NON-NLS-1$
        tempPanel.add(getFocus);
        tempPanel.add(panSetting);

        // player-specific settings
        defaultAutoejectDisabled = new Checkbox(Messages
                .getString("CommonSettingsDialog.defaultAutoejectDisabled")); //$NON-NLS-1$
        defaultAutoejectDisabled.addItemListener(this);
        tempPanel.add(defaultAutoejectDisabled);

        useAverageSkills = new Checkbox(Messages
                .getString("CommonSettingsDialog.useAverageSkills")); //$NON-NLS-1$
        useAverageSkills.addItemListener(this);
        tempPanel.add(useAverageSkills);

        showUnitId = new Checkbox(Messages
                .getString("CommonSettingsDialog.showUnitId")); //$NON-NLS-1$
        showUnitId.addItemListener(this);
        tempPanel.add(showUnitId);

        // client-side gameLog settings
        keepGameLog = new Checkbox(Messages
                .getString("CommonSettingsDialog.keepGameLog")); //$NON-NLS-1$
        keepGameLog.addItemListener(this);
        tempPanel.add(keepGameLog);

        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));
        panSetting.add(new Label(Messages
                .getString("CommonSettingsDialog.logFileName"))); //$NON-NLS-1$
        gameLogFilename = new TextField(15);
        panSetting.add(gameLogFilename);
        tempPanel.add(panSetting);

        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));
        panSetting.add(new Label(Messages
                .getString("CommonSettingsDialog.tileset"))); //$NON-NLS-1$
        tileSetChoice = new Choice();
        panSetting.add(tileSetChoice);
        tempPanel.add(panSetting);

        /*
         * panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));
         * panSetting.add( new
         * Label(Messages.getString("CommonSettingsDialog.logFileMaxSize")) );
         * //$NON-NLS-1$ gameLogMaxSize = new TextField(5); panSetting.add(
         * gameLogMaxSize ); tempPanel.add( panSetting );
         */

        stampFilenames = new Checkbox(Messages
                .getString("CommonSettingsDialog.stampFilenames")); //$NON-NLS-1$
        stampFilenames.addItemListener(this);
        tempPanel.add(stampFilenames);

        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));
        panSetting.add(new Label(Messages
                .getString("CommonSettingsDialog.stampFormat"))); //$NON-NLS-1$
        stampFormat = new TextField(15);
        panSetting.add(stampFormat);
        tempPanel.add(panSetting);

        // scrolling options
        tempPanel.add(new AdvancedLabel(Messages
                .getString("CommonSettingsDialog.mapScrollText"))); //$NON-NLS-1$

        rightDragScroll = new Checkbox(Messages
                .getString("CommonSettingsDialog.rightDragScroll")); //$NON-NLS-1$
        tempPanel.add(rightDragScroll);

        ctlScroll = new Checkbox(Messages
                .getString("CommonSettingsDialog.ctlScroll")); //$NON-NLS-1$
        tempPanel.add(ctlScroll);

        clickEdgeScroll = new Checkbox(Messages
                .getString("CommonSettingsDialog.clickEdgeScroll")); //$NON-NLS-1$
        tempPanel.add(clickEdgeScroll);

        alwaysRightClickScroll = new Checkbox(Messages
                .getString("CommonSettingsDialog.alwaysRightClickScroll")); //$NON-NLS-1$
        tempPanel.add(alwaysRightClickScroll);

        autoEdgeScroll = new Checkbox(Messages
                .getString("CommonSettingsDialog.autoEdgeScroll")); //$NON-NLS-1$
        tempPanel.add(autoEdgeScroll);

        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));
        panSetting.add(new Label(Messages
                .getString("CommonSettingsDialog.scrollSesitivity"))); //$NON-NLS-1$
        scrollSensitivity = new TextField(4);
        panSetting.add(scrollSensitivity);
        tempPanel.add(panSetting);

        // locale settings
        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));
        panSetting.add(new Label(Messages
                .getString("CommonSettingsDialog.locale"))); //$NON-NLS-1$
        // locale = new TextField(8);
        locale = new Choice();
        locale.add(Messages.getString("CommonSettingsDialog.locale.English")); //$NON-NLS-1$
        locale.add(Messages.getString("CommonSettingsDialog.locale.Deutsch")); //$NON-NLS-1$
        locale.add(Messages.getString("CommonSettingsDialog.locale.Russian")); //$NON-NLS-1$
        panSetting.add(locale);
        tempPanel.add(panSetting);
View Full Code Here

        labTeam = new Label(
                Messages.getString("ChatLounge.labTeam"), Label.RIGHT); //$NON-NLS-1$
        labCamo = new Label(
                Messages.getString("ChatLounge.labCamo"), Label.RIGHT); //$NON-NLS-1$

        choTeam = new Choice();
        setupTeams();
        choTeam.addItemListener(this);

        butCamo = new ImageButton();
        butCamo.setLabel(Messages.getString("ChatLounge.noCamo")); //$NON-NLS-1$
View Full Code Here

        slBoardSize = new SimpleLine(NORMAL_LINE_WIDTH);

        // Normal setting components...
        labElevation = new Label(Messages
                .getString("RandomMapDialog.labElevation"), Label.LEFT); //$NON-NLS-1$
        choElevation = new Choice();
        fillChoice(choElevation);
        slElevation = new SimpleLine(NORMAL_LINE_WIDTH);

        labCliffs = new Label(
                Messages.getString("RandomMapDialog.labCliffs"), Label.LEFT); //$NON-NLS-1$
        choCliffs = new Choice();
        fillChoice(choCliffs);
        slCliffs = new SimpleLine(NORMAL_LINE_WIDTH);

        labWoods = new Label(
                Messages.getString("RandomMapDialog.labWoods"), Label.LEFT); //$NON-NLS-1$
        choWoods = new Choice();
        fillChoice(choWoods);
        slWoods = new SimpleLine(NORMAL_LINE_WIDTH);

        labLakes = new Label(
                Messages.getString("RandomMapDialog.labLakes"), Label.LEFT); //$NON-NLS-1$
        choLakes = new Choice();
        fillChoice(choLakes);
        slLakes = new SimpleLine(NORMAL_LINE_WIDTH);

        labRough = new Label(
                Messages.getString("RandomMapDialog.labRough"), Label.LEFT); //$NON-NLS-1$
        choRough = new Choice();
        fillChoice(choRough);
        slRough = new SimpleLine(NORMAL_LINE_WIDTH);

        labSwamp = new Label(
                Messages.getString("RandomMapDialog.labSwamp"), Label.LEFT); //$NON-NLS-1$
        choSwamp = new Choice();
        fillChoice(choSwamp);
        slSwamp = new SimpleLine(NORMAL_LINE_WIDTH);

        labPavement = new Label(Messages
                .getString("RandomMapDialog.labPavement"), Label.LEFT);
        choPavement = new Choice();
        fillChoice(choPavement);
        slPavement = new SimpleLine(NORMAL_LINE_WIDTH);

        labRubble = new Label(Messages.getString("RandomMapDialog.labRubble"),
                Label.LEFT);
        choRubble = new Choice();
        fillChoice(choRubble);
        slRubble = new SimpleLine(NORMAL_LINE_WIDTH);

        labFortified = new Label(Messages
                .getString("RandomMapDialog.labFortified"), Label.LEFT);
        choFortified = new Choice();
        fillChoice(choFortified);
        slFortified = new SimpleLine(NORMAL_LINE_WIDTH);

        labIce = new Label(Messages.getString("RandomMapDialog.labIce"),
                Label.LEFT);
        choIce = new Choice();
        fillChoice(choIce);
        slIce = new SimpleLine(NORMAL_LINE_WIDTH);

        labCraters = new Label(
                Messages.getString("RandomMapDialog.labCraters"), Label.LEFT);
        choCraters = new Choice();
        fillChoice(choCraters);
        slCraters = new SimpleLine(NORMAL_LINE_WIDTH);

        labRivers = new Label(
                Messages.getString("RandomMapDialog.labRivers"), Label.LEFT); //$NON-NLS-1$
        choRivers = new Choice();
        fillChoice(choRivers);
        slRivers = new SimpleLine(NORMAL_LINE_WIDTH);

        labRoads = new Label(
                Messages.getString("RandomMapDialog.labRoads"), Label.LEFT); //$NON-NLS-1$
        choRoads = new Choice();
        fillChoice(choRoads);
        slRoads = new SimpleLine(NORMAL_LINE_WIDTH);

        labCity = new Label(
                Messages.getString("RandomMapDialog.labCity"), Label.LEFT); //$NON-NLS-1$
        choCity = new Choice();
        choCity.add(NONE);
        choCity.add("HUB");
        choCity.add("GRID");
        choCity.add("METRO");
        choCity.add("TOWN");
        slCity = new SimpleLine(NORMAL_LINE_WIDTH);

        labMountain = new Label(Messages
                .getString("RandomMapDialog.labMountain"), Label.LEFT); //$NON-NLS-1$
        choMountain = new Choice();
        fillChoice(choMountain);
        slMountain = new SimpleLine(NORMAL_LINE_WIDTH);

        // Advanced setting components...
        labTheme = new Label(Messages.getString("RandomMapDialog.labTheme"),
View Full Code Here

        Panel panel = new Panel();
        this.add(panel, BorderLayout.NORTH);
        panel.setLayout(new GridBagLayout());
        GridBagConstraints layout = new GridBagConstraints();
        layout.anchor = GridBagConstraints.CENTER;
        categories = new Choice();
        panel.add(categories, layout);

        // Fill the pulldown. Include the "no camo" category.
        // Make sure the "no camo" and "root camo" are at top.
        // Only add the "root camo" category if it contains items.
View Full Code Here

            unitList = new List(8, false);
            unitList.addItemListener(this);
            unitList.addKeyListener(clientgui.menuBar);

            m_chMode = new Choice();
            m_chMode.add("   "); //$NON-NLS-1$
            m_chMode.setEnabled(false);
            m_chMode.addItemListener(this);
            m_chMode.addKeyListener(clientgui.menuBar);
View Full Code Here

            curSensorsL = new TransparentLabel((Messages
                    .getString("MechDisplay.CurrentSensors")).concat(" "), fm,
                    Color.white, TransparentLabel.CENTER);

            chSensors = new Choice();
            chSensors.addItemListener(this);

            narcLabel = new TransparentLabel(
                    Messages.getString("MechDisplay.AffectedBy"), fm, Color.white, TransparentLabel.CENTER); //$NON-NLS-1$
View Full Code Here

        butDelTerrain = new Button(Messages
                .getString("BoardEditor.butDelTerrain")); //$NON-NLS-1$
        butDelTerrain.addActionListener(this);

        choTerrainType = new Choice();
        for (int i = 1; i < Terrains.SIZE; i++) {
            choTerrainType.add(Terrains.getName(i));
        }

        texTerrainLevel = new TextField("1", 1); //$NON-NLS-1$
View Full Code Here

        private Choice m_choice;
        private Mounted m_mounted;

        public SantaAnnaChoicePanel(Mounted m) {
            m_mounted = m;
            m_choice = new Choice();
            for (int i = 0; i <= m_mounted.getShotsLeft(); i++) {
                m_choice.add(Integer.toString(i));
            }
            int loc;
            loc = m.getLocation();
View Full Code Here

TOP

Related Classes of java.awt.Choice$ChoiceStateController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.