Java Code Examples for java.awt.List#add()
The following examples show how to use
java.awt.List#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemEventTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public ItemEventTest() { try { robot = new Robot(); } catch(AWTException e) { throw new RuntimeException(e.getMessage()); } expectedSelectionOrder = "01230123"; list = new List(4, true); list.add("0"); list.add("1"); list.add("2"); list.add("3"); add(list); setSize(400,400); setLayout(new FlowLayout()); pack(); setVisible(true); robot.waitForIdle(); }
Example 2
Source File: MidiCommunication.java From jmg with GNU General Public License v2.0 | 6 votes |
private void fillFrame(Frame f, List dataList, MidiDevice.Info[] info) { try { f.setSize(340, 200); f.setLocation(Toolkit.getDefaultToolkit().getScreenSize().width / 2 - 170, Toolkit.getDefaultToolkit().getScreenSize().height / 2 - 100); String[] data = new String[info.length]; data[0] = "" + info[0]; data[1] = "" + info[1]; for(int i=2; i< info.length; i++) { data[i] = MidiSystem.getMidiDevice(info[i]).toString(); } for(int i=0; i< info.length; i++) { dataList.add(data[i]); } ScrollPane scrollPane = new ScrollPane(); scrollPane.add(dataList); f.add(scrollPane); } catch (Exception e) { System.out.println (e); System.exit (0); } }
Example 3
Source File: JTextAreaBinding.java From magarena with GNU General Public License v3.0 | 6 votes |
public void get(IValidatable bean) { try { String text = _textArea.getText(); if (!text.equals("")) { String[] items = text.split("\n"); List list = new ArrayList(); for (int i = 0; i < items.length; i++) { list.add(items[i]); } PropertyUtils.setProperty(bean, _property, list); } else { PropertyUtils.setProperty(bean, _property, null); } } catch (Exception e) { throw new BindingException(e); } }
Example 4
Source File: R2303044ListSelection.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
Example 5
Source File: R2303044ListSelection.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
Example 6
Source File: R2303044ListSelection.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
Example 7
Source File: R2303044ListSelection.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
Example 8
Source File: ActionEventTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public ActionEventTest() { try { robot = new Robot(); robot.setAutoDelay(100); robot.setAutoWaitForIdle(true); } catch(AWTException e) { throw new RuntimeException(e.getMessage()); } list = new List(1, false); list.add("0"); add(list); setSize(400,400); setLayout(new FlowLayout()); pack(); setVisible(true); }
Example 9
Source File: R2303044ListSelection.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
Example 10
Source File: ClassMemberTest.java From netbeans with Apache License 2.0 | 6 votes |
private MethodTree m(TreeMaker make) { // create method modifiers ModifiersTree parMods = make.Modifiers(Collections.<Modifier>emptySet(), Collections.<AnnotationTree>emptyList()); // create parameters VariableTree par1 = make.Variable(parMods, "a", make.PrimitiveType(TypeKind.INT), null); VariableTree par2 = make.Variable(parMods, "b", make.PrimitiveType(TypeKind.FLOAT), null); List<VariableTree> parList = new ArrayList<VariableTree>(2); parList.add(par1); parList.add(par2); // create method MethodTree newMethod = make.Method( make.Modifiers( Collections.singleton(Modifier.PUBLIC), // modifiers Collections.<AnnotationTree>emptyList() // annotations ), // modifiers and annotations "newlyCreatedMethod", // name make.PrimitiveType(TypeKind.VOID), // return type Collections.<TypeParameterTree>emptyList(), // type parameters for parameters parList, // parameters Collections.singletonList(make.Identifier("java.io.IOException")), // throws make.Block(Collections.<StatementTree>emptyList(), false), // empty statement block null // default value - not applicable here, used by annotations ); return newMethod; }
Example 11
Source File: R2303044ListSelection.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
Example 12
Source File: R2303044ListSelection.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
Example 13
Source File: ParmScreen.java From jmg with GNU General Public License v2.0 | 5 votes |
private void initializeVolumeList() { volumeList = new List(); int minVolume = 7; int maxVolume = 256; int volumeStep = 6; for ( int i = minVolume; i <= maxVolume; i += volumeStep) { volumeList.add( (new Integer(i)).toString() ); } }
Example 14
Source File: Calculo.java From dctb-utfpr-2018-1 with Apache License 2.0 | 5 votes |
public List<Character> Operacoes(String tipoOp) { List<Character> listOp = new ArrayList<Character>(); for (int i = 0; i < tipoOp.length(); i++) { if (verificarOp(tipoOp.charAt(i))) { listOp.add(new Character(tipoOp.charAt(i))); } } return listOp; }
Example 15
Source File: R2303044ListSelection.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
Example 16
Source File: ParmScreen.java From jmg with GNU General Public License v2.0 | 5 votes |
private void initializeTempoList() { tempoList = new List(); for (double x = 36.0; x <143.0; x+= 2.0) { tempoList.add( (new Double(x)).toString() ); } for (double y = 144.0; y <250.0; y+= 4.0) { tempoList.add( (new Double(y)).toString() ); } for (double z = 256.0; z < 404.0; z+= 8.0) { tempoList.add( (new Double(z)).toString() ); } }
Example 17
Source File: RangeMarkerTest.java From consulo with Apache License 2.0 | 5 votes |
private static List<RangeMarker> add(DocumentEx document, int... offsets) { List<RangeMarker> result = new ArrayList<RangeMarker>(); for (int i=0; i<offsets.length; i+=2) { int start = offsets[i]; int end = offsets[i+1]; RangeMarker m = document.createRangeMarker(start, end); result.add(m); } return result; }
Example 18
Source File: ExtendedModifiersTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void createGUI() { frame = new Frame(); frame.setTitle("ExtendedModifiersTest"); frame.setLayout(new GridLayout(1, 6)); button = new Button(); button.addKeyListener(this); frame.add(button); buttonLW = new LWButton(); buttonLW.addKeyListener(this); frame.add(buttonLW); textField = new TextField(5); textField.addKeyListener(this); frame.add(textField); textArea = new TextArea(5, 5); textArea.addKeyListener(this); frame.add(textArea); list = new List(); for (int i = 1; i <= 5; ++i) { list.add("item " + i); } list.addKeyListener(this); frame.add(list); listLW = new LWList(); for (int i = 1; i <= 5; ++i) { listLW.add("item " + i); } listLW.addKeyListener(this); frame.add(listLW); frame.setBackground(Color.gray); frame.setSize(500, 100); frame.setVisible(true); frame.toFront(); }
Example 19
Source File: ClassMemberTest.java From netbeans with Apache License 2.0 | 4 votes |
public void testAddConstructor() throws Exception { testFile = new File(getWorkDir(), "Test.java"); TestUtilities.copyStringToFile(testFile, "package hierbas.del.litoral;\n\n" + "public class Test {\n" + " \n" + " String prefix;\n" + " \n" + " public void method() {\n" + " }\n" + " \n" + "}\n" ); String golden = "package hierbas.del.litoral;\n\n" + "public class Test {\n" + " \n" + " String prefix;\n" + "\n" + " public Test(boolean prefix) {\n" + " }\n" + " \n" + " public void method() {\n" + " }\n" + " \n" + "}\n"; JavaSource src = getJavaSource(testFile); Task<WorkingCopy> task = new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws IOException { workingCopy.toPhase(Phase.RESOLVED); CompilationUnitTree cut = workingCopy.getCompilationUnit(); TreeMaker make = workingCopy.getTreeMaker(); for (Tree typeDecl : cut.getTypeDecls()) { // ensure that it is correct type declaration, i.e. class if (TreeUtilities.CLASS_TREE_KINDS.contains(typeDecl.getKind())) { ClassTree classTree = (ClassTree) typeDecl; ModifiersTree mods = make.Modifiers(EnumSet.of(Modifier.PUBLIC)); List<VariableTree> arguments = new ArrayList<VariableTree>(); arguments.add(make.Variable( make.Modifiers(EnumSet.noneOf(Modifier.class)), "prefix", make.PrimitiveType(TypeKind.BOOLEAN), null) ); MethodTree constructor = make.Method( mods, "<init>", null, Collections.<TypeParameterTree> emptyList(), arguments, Collections.<ExpressionTree>emptyList(), make.Block(Collections.<StatementTree>emptyList(), false), null ); ClassTree copy = make.insertClassMember(classTree, 2, constructor); workingCopy.rewrite(classTree, copy); } } } }; src.runModificationTask(task).commit(); String res = TestUtilities.copyFileToString(testFile); //System.err.println(res); assertEquals(golden, res); }
Example 20
Source File: ParmScreen.java From jmg with GNU General Public License v2.0 | 4 votes |
private void initializeInstrumentList() { instrumentList = new List(); instrumentList.add("Accordion 21"); instrumentList.add("Applausen 126"); instrumentList.add("Bandneon 23"); instrumentList.add("Banjo 105"); instrumentList.add("Bagpipes 109"); instrumentList.add("Bass (Acoustic) 32"); instrumentList.add("Bass (Fingerd) 33"); instrumentList.add("Bass (Fretless) 35"); instrumentList.add("Bass (Picked) 34"); instrumentList.add("Bass (Slap) 36"); instrumentList.add("Bass (Synth) 38"); instrumentList.add("Bass (Synth) 38"); instrumentList.add("Bassoon 70"); instrumentList.add("Bottle 76"); instrumentList.add("Brass (Synthetic) 62"); instrumentList.add("Calliope 82"); instrumentList.add("Celeste 8"); instrumentList.add("Cello 42"); instrumentList.add("Charang 84"); instrumentList.add("Choir 52"); instrumentList.add("Clarinet 71"); instrumentList.add("Clavinet 7"); instrumentList.add("Contrabass 43"); instrumentList.add("English Horn 69"); instrumentList.add("Fiddle 110"); instrumentList.add("French Horn 60"); instrumentList.add("Flute 73"); instrumentList.add("Glockenspiel 9"); instrumentList.add("Guitar (Clean) 27"); instrumentList.add("Guitar (Distorted) 30"); instrumentList.add("Guitar Harmonics 31"); instrumentList.add("Guitar (Jazz) 26"); instrumentList.add("Guitar (Muted) 28"); instrumentList.add("Guitar (Nylon) 24"); instrumentList.add("Guitar (Overdrive) 29"); instrumentList.add("Guitar (Steel) 25"); instrumentList.add("Harmonica 22"); instrumentList.add("Harp 46"); instrumentList.add("Harpsichord 76"); instrumentList.add("Marimba 12"); instrumentList.add("Music Box 10"); instrumentList.add("Oboe 68"); instrumentList.add("Ocarina 79"); instrumentList.add("Orchestra Hit 55"); instrumentList.add("Organ 16"); instrumentList.add("Organ (Church) 19"); instrumentList.add("Organ (Reed) 20"); instrumentList.add("Pan Flute 75"); instrumentList.add("Piano 0"); instrumentList.add("Piano (Electric) 4"); instrumentList.add("Piano (Honkeytonk) 3"); instrumentList.add("Piccolo 72"); instrumentList.add("Recorder 74"); instrumentList.add("Saxophone (Alto) 65"); instrumentList.add("Saxophone (Soprano) 64"); instrumentList.add("Saxophone (Tenor) 66"); instrumentList.add("Saxophone (Baritone) 67"); instrumentList.add("Shakuhachi 77"); instrumentList.add("Steel Drums 114"); instrumentList.add("Strings 48"); instrumentList.add("Strings (Pizzicato) 45"); instrumentList.add("Strings (Slow) 51"); instrumentList.add("Strings (Synth) 50"); instrumentList.add("Strings (Tremolo) 44"); instrumentList.add("Tom-Tom 119"); instrumentList.add("Trombone 57"); instrumentList.add("Trumpet 56"); instrumentList.add("Trumpet (Muted) 59"); instrumentList.add("Tuba 58"); instrumentList.add("Tubular Bell 14"); instrumentList.add("Timpani 47"); instrumentList.add("Vibraphone 11"); instrumentList.add("Viola 41"); instrumentList.add("Violin 40"); instrumentList.add("Voice 53"); instrumentList.add("Vox 56"); instrumentList.add("Whistle 78"); instrumentList.add("Wood Block 115"); instrumentList.add("Xylophone 13"); }