类java.awt.List源码实例Demo

下面列出了怎么用java.awt.List的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TencentKona-8   文件: R2303044ListSelection.java
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();
}
 
源代码2 项目: magarena   文件: OptJTextAreaBinding.java
public void put(IValidatable bean) {
	try {
		boolean selected = "true".equals(BeanUtils.getProperty(bean,
				_stateProperty));
		_button.setSelected(selected);
		_textArea.setEnabled(selected);
		List list = (List) PropertyUtils.getProperty(bean, _property);
		StringBuffer sb = new StringBuffer();
		if (list != null) {
			for (int i = 0; i < list.size(); i++) {
				sb.append(list.get(i));
				if (i < list.size() - 1) {
					sb.append("\n");
				}
			}
		}
		_textArea.setText(sb.toString());
	} catch (Exception e) {
		throw new BindingException(e);
	}
}
 
源代码3 项目: jdk8u-dev-jdk   文件: R2303044ListSelection.java
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();
}
 
源代码4 项目: jdk8u60   文件: R2303044ListSelection.java
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();
}
 
源代码5 项目: netbeans   文件: ClassMemberTest.java
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;
}
 
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();
}
 
源代码7 项目: openjdk-jdk9   文件: ItemEventTest.java
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();
}
 
源代码8 项目: magarena   文件: JTextAreaBinding.java
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);
	}
}
 
源代码9 项目: consulo   文件: RangeMarkerTest.java
public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception {
  final int N = 50000;
  Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N));

  final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true);
  for (int i=0; i<N-1;i++) {
    markupModel.addRangeHighlighter(2*i, 2*i+1, 0, null, HighlighterTargetArea.EXACT_RANGE);
  }
  markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE);

  PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), new ThrowableRunnable() {
    @Override
    public void run() {
      List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
      CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list);
      for (int i=0; i<N-1;i++) {
        list.clear();
        markupModel.processRangeHighlightersOverlappingWith(2*i, 2*i+1, coll);
        assertEquals(2, list.size());  // 1 line plus one exact range marker
      }
    }
  }).assertTiming();
}
 
源代码10 项目: hottub   文件: R2303044ListSelection.java
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();
}
 
源代码11 项目: jdk8u-jdk   文件: R2303044ListSelection.java
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();
}
 
源代码12 项目: openjdk-jdk9   文件: ListOperator.java
@Override
public boolean checkComponent(Component comp) {
    if (comp instanceof List) {
        if (label == null) {
            return true;
        }
        if (((List) comp).getItemCount() > itemIndex) {
            int ii = itemIndex;
            if (ii == -1) {
                ii = ((List) comp).getSelectedIndex();
                if (ii == -1) {
                    return false;
                }
            }
            return (comparator.equals(((List) comp).getItem(ii),
                    label));
        }
    }
    return false;
}
 
源代码13 项目: consulo   文件: RangeMarkerTest.java
public void testE4() {
  DocumentEx document = (DocumentEx)EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol(' ', 10));
  List<RangeMarker> mm =
          add(document, 3,5, 5,6, 4,8, 6,9, 8,9
          );
  edit(document, 6,0,0,  3,0,2);
  delete(mm, 1,0);
}
 
源代码14 项目: openjdk-8   文件: Test4750368.java
public static void main(String[] args) throws IntrospectionException {
    if (getLength(com.foo.test.Component.class) == getLength(Component.class)) {
        throw new Error("test failed for Component");
    }
    if (getLength(java.util.List.class) == getLength(List.class)) {
        throw new Error("test failed for List");
    }
}
 
源代码15 项目: dragonwell8_jdk   文件: Test4750368.java
public static void main(String[] args) throws IntrospectionException {
    if (getLength(com.foo.test.Component.class) == getLength(Component.class)) {
        throw new Error("test failed for Component");
    }
    if (getLength(java.util.List.class) == getLength(List.class)) {
        throw new Error("test failed for List");
    }
}
 
源代码16 项目: consulo   文件: RangeMarkerTest.java
public void testX2() {
  DocumentEx document = (DocumentEx)EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol(' ', 10));
  List<RangeMarker> mm =
          add(document, 2,9, 0,0, 7,7
          );
  delete(mm, 0);
}
 
源代码17 项目: TencentKona-8   文件: LWToolkit.java
@Override
public final ListPeer createList(List target) {
    PlatformComponent platformComponent = createPlatformComponent();
    LWListPeer peer = new LWListPeer(target, platformComponent);
    targetCreatedPeer(target, peer);
    peer.initialize();
    return peer;
}
 
源代码18 项目: consulo   文件: RangeMarkerTest.java
public void testE1() {
  DocumentEx document = (DocumentEx)EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol(' ', 10));
  List<RangeMarker> mm =
          add(document, 3,5, 0,1, 9,9
          );
  edit(document, 3,6,0);
  delete(mm, 0);
}
 
源代码19 项目: hottub   文件: LWToolkit.java
@Override
public final ListPeer createList(List target) {
    PlatformComponent platformComponent = createPlatformComponent();
    LWListPeer peer = new LWListPeer(target, platformComponent);
    targetCreatedPeer(target, peer);
    peer.initialize();
    return peer;
}
 
源代码20 项目: jdk8u60   文件: Test4520754.java
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
源代码21 项目: consulo   文件: RangeMarkerTest.java
public void testRangeHighlighterIteratorOrder() throws Exception {
  Document document = EditorFactory.getInstance().createDocument("1234567890");

  final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true);
  RangeHighlighter exact = markupModel.addRangeHighlighter(3, 6, 0, null, HighlighterTargetArea.EXACT_RANGE);
  RangeHighlighter line = markupModel.addRangeHighlighter(4, 5, 0, null, HighlighterTargetArea.LINES_IN_RANGE);
  List<RangeHighlighter> list = new ArrayList<RangeHighlighter>();
  markupModel.processRangeHighlightersOverlappingWith(2, 9, new CommonProcessors.CollectProcessor<RangeHighlighter>(list));
  assertEquals(Arrays.asList(line, exact), list);
}
 
源代码22 项目: jmg   文件: NoteEditor.java
private void initializeLists() {
    noteList = new List(6);
    noteList.add( "Rest" );        
    noteList.add( "A" );        
    noteList.add( "A#" );        
    noteList.add( "B" );        
    noteList.add( "C" );        
    noteList.add( "C#" );        
    noteList.add( "D" );        
    noteList.add( "D#" );        
    noteList.add( "E" );        
    noteList.add( "F" );        
    noteList.add( "F#" );        
    noteList.add( "G" );        
    noteList.add( "G#" );        
    
    octaveList = new List(6);
    octaveList.add("-1");
    octaveList.add("0");
    octaveList.add("1");
    octaveList.add("2");
    octaveList.add("3");
    octaveList.add("4");
    octaveList.add("5");
    octaveList.add("6");
    octaveList.add("7");
    octaveList.add("8");
    octaveList.add("9");
}
 
源代码23 项目: openjdk-jdk8u   文件: Test4750368.java
public static void main(String[] args) throws IntrospectionException {
    if (getLength(com.foo.test.Component.class) == getLength(Component.class)) {
        throw new Error("test failed for Component");
    }
    if (getLength(java.util.List.class) == getLength(List.class)) {
        throw new Error("test failed for List");
    }
}
 
源代码24 项目: openjdk-jdk8u   文件: Test4520754.java
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
源代码25 项目: openjdk-8   文件: LWToolkit.java
@Override
public ListPeer createList(List target) {
    PlatformComponent platformComponent = createPlatformComponent();
    LWListPeer peer = new LWListPeer(target, platformComponent);
    targetCreatedPeer(target, peer);
    peer.initialize();
    return peer;
}
 
源代码26 项目: consulo   文件: RangeMarkerTest.java
public void testE3() {
  DocumentEx document = (DocumentEx)EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol(' ', 10));
  List<RangeMarker> mm =
          add(document, 4,5, 6,8, 3,4, 4,9, 2,9
          );
  edit(document, 4,6,0);
  delete(mm, 0);
}
 
源代码27 项目: netbeans   文件: ListBeanInfo.java
/** @return Propertydescriptors */
@Override
protected PropertyDescriptor[] createPDs() throws IntrospectionException {
    return new PropertyDescriptor[] {
        new PropertyDescriptor("multipleMode", List.class), // NOI18N
    };
}
 
源代码28 项目: consulo   文件: RangeMarkerTest.java
public void testX3() {
  DocumentEx document = (DocumentEx)EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol(' ', 10));
  List<RangeMarker> mm =
          add(document, 1,9, 8,8, 8,8, 0,5, 4,5
          );
  delete(mm, 0);
}
 
源代码29 项目: openjdk-jdk8u-backup   文件: LWToolkit.java
@Override
public final ListPeer createList(List target) {
    PlatformComponent platformComponent = createPlatformComponent();
    LWListPeer peer = new LWListPeer(target, platformComponent);
    targetCreatedPeer(target, peer);
    peer.initialize();
    return peer;
}
 
源代码30 项目: jdk8u_jdk   文件: Test4520754.java
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
 类所在包
 同包方法