List of usage examples for java.awt Choice Choice
public Choice() throws HeadlessException
From source file:TextBouncer.java
public static void main(String[] args) { String s = "Java Source and Support"; final int size = 64; if (args.length > 0) s = args[0];//from w w w. java2 s.co m 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() { 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); }
From source file:ImageBouncer.java
public static void main(String[] args) { String filename = "java2sLogo.png"; if (args.length > 0) filename = args[0];/* w w w . j a v a 2s.c o m*/ Image image = null; try { image = blockingLoad(new URL(filename)); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } final ImageBouncer bouncer = new ImageBouncer(image); Frame f = new AnimationFrame(bouncer); f.setFont(new Font("Serif", Font.PLAIN, 12)); Panel controls = new Panel(); controls.add(bouncer.createCheckbox("Bilinear", ImageBouncer.BILINEAR)); controls.add(bouncer.createCheckbox("Transform", ImageBouncer.TRANSFORM)); final Choice typeChoice = new Choice(); typeChoice.add("TYPE_INT_RGB"); typeChoice.add("TYPE_INT_ARGB"); typeChoice.add("TYPE_INT_ARGB_PRE"); typeChoice.add("TYPE_3BYTE_BGR"); typeChoice.add("TYPE_BYTE_GRAY"); typeChoice.add("TYPE_USHORT_GRAY"); typeChoice.add("TYPE_USHORT_555_RGB"); typeChoice.add("TYPE_USHORT_565_RGB"); controls.add(typeChoice); f.add(controls, BorderLayout.NORTH); typeChoice.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { String type = typeChoice.getSelectedItem(); bouncer.setImageType(type); } }); f.setSize(200, 200); f.setVisible(true); }
From source file:Presentation.MainWindow.java
/** Ajout la fentre de la liste de ports COM dtectes par l'ordinateur pour rcuprer les donnes */ public void addCOMPorts(ArrayList<String> Ports) { Panel panel = new Panel(); Label label = new Label("Ports COM"); Choice COMPorts = new Choice(); for (String port : Ports) { COMPorts.add(port);//w w w .j a va 2s. c om } panel.add(label); panel.add(COMPorts); mPanel.add(panel); show(); }
From source file:WebCrawler.java
public void init() { // set up the main UI panel panelMain = new Panel(); panelMain.setLayout(new BorderLayout(5, 5)); // text entry components Panel panelEntry = new Panel(); panelEntry.setLayout(new BorderLayout(5, 5)); Panel panelURL = new Panel(); panelURL.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); Label labelURL = new Label("Starting URL: ", Label.RIGHT); panelURL.add(labelURL);//from w ww . j a v a 2 s. c o m textURL = new TextField("", 40); panelURL.add(textURL); panelEntry.add("North", panelURL); Panel panelType = new Panel(); panelType.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); Label labelType = new Label("Content type: ", Label.RIGHT); panelType.add(labelType); choiceType = new Choice(); choiceType.addItem("text/html"); choiceType.addItem("audio/basic"); choiceType.addItem("audio/au"); choiceType.addItem("audio/aiff"); choiceType.addItem("audio/wav"); choiceType.addItem("video/mpeg"); choiceType.addItem("video/x-avi"); panelType.add(choiceType); panelEntry.add("South", panelType); panelMain.add("North", panelEntry); // list of result URLs Panel panelListButtons = new Panel(); panelListButtons.setLayout(new BorderLayout(5, 5)); Panel panelList = new Panel(); panelList.setLayout(new BorderLayout(5, 5)); Label labelResults = new Label("Search results"); panelList.add("North", labelResults); Panel panelListCurrent = new Panel(); panelListCurrent.setLayout(new BorderLayout(5, 5)); listMatches = new List(10); panelListCurrent.add("North", listMatches); labelStatus = new Label(""); panelListCurrent.add("South", labelStatus); panelList.add("South", panelListCurrent); panelListButtons.add("North", panelList); // control buttons Panel panelButtons = new Panel(); Button buttonSearch = new Button(SEARCH); buttonSearch.addActionListener(this); panelButtons.add(buttonSearch); Button buttonStop = new Button(STOP); buttonStop.addActionListener(this); panelButtons.add(buttonStop); panelListButtons.add("South", panelButtons); panelMain.add("South", panelListButtons); add(panelMain); setVisible(true); repaint(); // initialize search data structures vectorToSearch = new Vector(); vectorSearched = new Vector(); vectorMatches = new Vector(); // set default for URL access URLConnection.setDefaultAllowUserInteraction(false); }
From source file:SumUp.java
/** init() is an Applet method called by the browser to initialize */ public void init() { setBackground(Color.magenta); // The layout of the Applet is a Grid; always add things in pairs! setLayout(new GridLayout(0, 2)); Choice c;/* w ww.j a v a 2s . c o m*/ add(new Label("Option 1")); add(c = new Choice()); c.addItem("0"); c.addItem("100"); c.addItem("200"); c.addItem("400"); cs[numChoices++] = c; add(new Label("Option 2")); add(c = new Choice()); c.addItem("0"); c.addItem("100"); c.addItem("200"); c.addItem("400"); cs[numChoices++] = c; Panel p = new Panel(); p.setBackground(Color.pink); p.add(new Label("Total:")); p.add(resultField = new Label("000000")); add(p); sendButton = new Button("Send it"); add(sendButton); // connect Button into Applet sendButton.addActionListener(this); // connect it back to Applet }
From source file:SplineAnim.java
private void createControlPanel(Panel p) { GridBagLayout gl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); p.setLayout(gl);/*from w w w. j ava 2 s . c o m*/ gbc.weightx = 100; gbc.weighty = 100; gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; interpLabel = new Label("Interpolation Type", Label.LEFT); p.add(interpLabel, gbc); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; interpChoice = new Choice(); interpChoice.add("Spline"); interpChoice.add("Linear"); p.add(interpChoice, gbc); interpChoice.addItemListener(this); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 2; gbc.gridheight = 1; speedSlider = new Scrollbar(Scrollbar.HORIZONTAL, 2, 1, 0, 11); speedSlider.setUnitIncrement(1); p.add(speedSlider, gbc); speedSlider.addAdjustmentListener(this); gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 2; gbc.gridheight = 1; speedLabel = new Label(" - Animation Speed +", Label.CENTER); p.add(speedLabel, gbc); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; gbc.gridheight = 1; animateButton = new Button("Stop Animation"); p.add(animateButton, gbc); animateButton.addActionListener(this); }
From source file:MultiTextureTest.java
public void init() { if (stoneImage == null) { // the path to the image for an applet try {/*from www. j a va 2 s . com*/ stoneImage = new java.net.URL(getCodeBase().toString() + "/stone.jpg"); } catch (java.net.MalformedURLException ex) { System.out.println(ex.getMessage()); System.exit(1); } } if (skyImage == null) { // the path to the image for an applet try { skyImage = new java.net.URL(getCodeBase().toString() + "/bg.jpg"); } catch (java.net.MalformedURLException ex) { System.out.println(ex.getMessage()); System.exit(1); } } setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); BranchGroup scene = createSceneGraph(); u = new SimpleUniverse(c); ViewingPlatform viewingPlatform = u.getViewingPlatform(); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. viewingPlatform.setNominalViewingTransform(); // add orbit behavior but disable translate OrbitBehavior orbit = new OrbitBehavior(c, OrbitBehavior.REVERSE_ALL | OrbitBehavior.DISABLE_TRANSLATE); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); orbit.setSchedulingBounds(bounds); viewingPlatform.setViewPlatformBehavior(orbit); u.addBranchGraph(scene); // create the gui choice = new Choice(); choice.addItem("stone + light"); choice.addItem("stone"); choice.addItem("lightMap"); choice.addItem("sky"); choice.addItem("stone + sky"); choice.addItemListener(this); add("North", choice); }
From source file:gdsc.smlm.ij.plugins.SpotAnalysis.java
private void createFrame() { Panel mainPanel = new Panel(); add(mainPanel);/* w w w.j a v a2 s. com*/ inputChoice = new Choice(); mainPanel.add(createChoicePanel(inputChoice, "")); widthTextField = new TextField(); mainPanel.add(createTextPanel(widthTextField, "PSF width", "1.2")); blurTextField = new TextField(); mainPanel.add(createTextPanel(blurTextField, "Blur (relative to width)", "1")); gainTextField = new TextField(); mainPanel.add(createTextPanel(gainTextField, "Gain", "37.7")); exposureTextField = new TextField(); mainPanel.add(createTextPanel(exposureTextField, "ms/Frame", "20")); smoothingTextField = new TextField(); mainPanel.add(createTextPanel(smoothingTextField, "Smoothing", "0.25")); profileButton = new Button("Profile"); profileButton.addActionListener(this); addButton = new Button("Add"); addButton.addActionListener(this); deleteButton = new Button("Remove"); deleteButton.addActionListener(this); saveButton = new Button("Save"); saveButton.addActionListener(this); saveTracesButton = new Button("Save Traces"); saveTracesButton.addActionListener(this); currentLabel = new Label(); mainPanel.add(createLabelPanel(currentLabel, "", "")); rawFittedLabel = new Label(); mainPanel.add(createLabelPanel(rawFittedLabel, "", "")); blurFittedLabel = new Label(); mainPanel.add(createLabelPanel(blurFittedLabel, "", "")); JPanel buttonPanel = new JPanel(); FlowLayout l = new FlowLayout(); l.setVgap(0); buttonPanel.setLayout(l); buttonPanel.add(profileButton, BorderLayout.CENTER); buttonPanel.add(addButton, BorderLayout.CENTER); buttonPanel.add(deleteButton, BorderLayout.CENTER); buttonPanel.add(saveButton, BorderLayout.CENTER); buttonPanel.add(saveTracesButton, BorderLayout.CENTER); mainPanel.add(buttonPanel); listModel = new DefaultListModel<Spot>(); onFramesList = new JList<Spot>(listModel); onFramesList.setVisibleRowCount(15); onFramesList.addListSelectionListener(this); //mainPanel.add(onFramesList); JScrollPane scrollPane = new JScrollPane(onFramesList); scrollPane.getVerticalScrollBarPolicy(); mainPanel.add(scrollPane); GridBagLayout mainGrid = new GridBagLayout(); int y = 0; GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.insets = new Insets(2, 2, 2, 2); for (Component comp : mainPanel.getComponents()) { c.gridy = y++; mainGrid.setConstraints(comp, c); } mainPanel.setLayout(mainGrid); }