Java 类java.awt.List 实例源码

项目:incubator-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;
}
项目:private-WeChat    文件:AuthorizationService.java   
@SuppressWarnings({ "deprecation", "unchecked" })
    public SNSUserInfo getUserInfo(String accessToken,String openId){
        logger.info("getUserInfo accessToken : {} , openId : {} ", accessToken, openId);
        SNSUserInfo user = null;
        String requestUrl = userinfo_url.replace("OPENID", openId).replace("ACCESS_TOKEN", accessToken);
        JSONObject jsonObject = CommonUtil.httpsRequest(requestUrl, "GET", null);
        if(null != jsonObject){
//          logger.info("授权返回JSONObject 数据 : " + com.meidusa.fastjson.JSONObject.toJSONString(jsonObject));
            logger.info("授权返回JSONObject 数据 : Key : {}, values : {} " ,com.alibaba.fastjson.JSONObject.toJSONString(jsonObject.keySet()), 
                    com.alibaba.fastjson.JSONObject.toJSONString(jsonObject.values()));
            try{
                user = new SNSUserInfo();
                user.setOpenId(jsonObject.getString("openid"));
                user.setNickname(jsonObject.getString("nickname"));
                user.setSex(jsonObject.getInt("sex"));
                user.setProvince(jsonObject.getString("province"));
                user.setCity(jsonObject.getString("city"));
                user.setCountry(jsonObject.getString("country"));
                user.setHeadimgurl(jsonObject.getString("headimgurl"));
                user.setPrivilegeList(JSONArray.toList(jsonObject.getJSONArray("privilege"), List.class));
            }catch(Exception e){
                logger.error("网页授权获取用户信息失败 " + e.getMessage());
                user = null;
                int errCode = jsonObject.getInt("errcode");
                String errMsg = jsonObject.getString("errmsg");
                logger.error("网页授权获取用户信息失败 errCode : {} , errmsg : {} ", errCode,errMsg);
            }
        }
        logger.info("getUserInfo => 返回  : " + com.alibaba.fastjson.JSONObject.toJSONString(user));
        return user;        
    }
项目:VASSAL-src    文件:UserDialogAWT.java   
private Panel layoutWhoPanel() {
  Panel panel = new Panel();
  panel.setLayout(new BorderLayout());
  panel.add("North", new Label("Who's On:"));
  panel.add("Center", zPeersList = new List(25, false));
  zPeersList.addActionListener(
    new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        String lineRest = e.getActionCommand();
        int spaceAt = lineRest.indexOf(' ');
        if (spaceAt != -1)
          handlePrivateMessageWindowRequest(lineRest.substring(0, spaceAt));
        zChatText.requestFocus();
      }
    }
  );
  return panel;
}
项目: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();
}
项目:openjdk-jdk10    文件:ActionEventTest.java   
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);
}
项目:openjdk-jdk10    文件: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();
}
项目:openjdk-jdk10    文件: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();
}
项目:openjdk-jdk10    文件: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;
}
项目:openjdk9    文件:ActionEventTest.java   
public ActionEventTest() {
    try {
        robot = new Robot();
    } 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);
    robot.waitForIdle();
}
项目:openjdk9    文件: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();
}
项目:openjdk9    文件: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();
}
项目:openjdk9    文件: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;
}
项目: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();
}
项目:lookaside_java-1.8.0-openjdk    文件: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();
}
项目:javify    文件:Demo.java   
public void init ()
{
  initted = true;

  Panel p = new Panel ();
  p.setLayout (new GridLayout (3, 1));

  List l = new List (5, true);
  for (int i = 0; i < 10; i++)
    l.add ("List item " + i);

  p.add (l);

  add (p, "Center");

  Button cb = new Button ("Close");
  cb.addActionListener(new ActionListener () {
      public void actionPerformed (ActionEvent e) {
        dispose();
      }
    });

  add (cb, "South");
  setTitle ("List");
  pack();
}
项目:javify    文件:QtListPeer.java   
protected void setup()
{
  super.setup();
  List o = (List)owner;
  // Multiple selection
  setMultipleMode(o.isMultipleMode());
  // Add initial list items.
  String[] items = o.getItems();
  for (int i = 0; i < items.length; i++)
    add(items[i], i);

  // Initial selections.
  int[] selected = o.getSelectedIndexes();
  for (int i = 0; i < selected.length; i++)
    select(selected[i]);

  // If no initial selection, use 0.
  if(selected.length == 0 && items.length > 0)
    select( 0 );
}
项目:javify    文件:QtListPeer.java   
/**
 * Called back when a row is selected. -1 if no row is selected.
 */
private void fireChoice( int index )
{
  ignoreNextSelect = true;
  if( index == -1)
    ((List)owner).deselect( ((List)owner).getSelectedIndex() );
    else
      {
        ((List)owner).select( index );
        ItemEvent e = new ItemEvent((List)owner,
                                    ItemEvent.ITEM_STATE_CHANGED,
                                    ""+index,
                                    ItemEvent.SELECTED);
        QtToolkit.eventQueue.postEvent(e);
      }
}
项目:intellij-ce-playground    文件:RangeMarkerTest.java   
public void testDocSynchronizerPrefersLineBoundaryChanges() throws Exception {
  String text = "import java.awt.List;\n" +
                  "[import java.util.ArrayList;\n]" +
                  "import java.util.HashMap;\n" +
                  "import java.util.Map;";
  RangeMarker marker = createMarker(text);
  synchronizer.startTransaction(getProject(), document, psiFile);

  String newText = StringUtil.replaceSubstring(document.getText(), TextRange.create(marker), "");
  synchronizer.replaceString(document, 0, document.getTextLength(), newText);

  final List<DocumentEvent> events = new ArrayList<DocumentEvent>();
  document.addDocumentListener(new DocumentAdapter() {
    @Override
    public void documentChanged(DocumentEvent e) {
      events.add(e);
    }
  });
  synchronizer.commitTransaction(document);

  assertEquals(newText, document.getText());
  DocumentEvent event = assertOneElement(events);
  assertEquals("DocumentEventImpl[myOffset=22, myOldLength=28, myNewLength=0, myOldString='import java.util.ArrayList;\n', myNewString=''].", event.toString());
}
项目:intellij-ce-playground    文件: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();
}
项目:incubator-netbeans    文件:ListBeanInfo.java   
/** @return Propertydescriptors */
@Override
protected PropertyDescriptor[] createPDs() throws IntrospectionException {
    return new PropertyDescriptor[] {
        new PropertyDescriptor("multipleMode", List.class), // NOI18N
    };
}
项目:OpenJSharp    文件: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;
}
项目:jdk8u-jdk    文件: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;
}
项目:jdk8u-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");
    }
}
项目: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);
}
项目:openjdk-jdk10    文件: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;
}
项目:openjdk-jdk10    文件:ItemEventTest.java   
@Override
public boolean handleEvent(Event e) {
    if (e.target instanceof List) {
        if (e.id == Event.LIST_DESELECT || e.id == Event.LIST_SELECT) {
            actualSelectionOrder.append(e.arg);
        }
    }
    return true;
}
项目:openjdk-jdk10    文件: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");
    }
}
项目:openjdk-jdk10    文件: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);
}
项目:openjdk-jdk10    文件:ListOperator.java   
@Override
public Hashtable<String, Object> getDump() {
    Hashtable<String, Object> result = super.getDump();
    addToDump(result, ITEM_PREFIX_DPROP, ((List) getSource()).getItems());
    addToDump(result, SELECTED_ITEM_PREFIX_DPROP, ((List) getSource()).getSelectedItems());
    return result;
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.addActionListener(ActionListener)} through queue
 */
public void addActionListener(final ActionListener actionListener) {
    runMapping(new MapVoidAction("addActionListener") {
        @Override
        public void map() {
            ((List) getSource()).addActionListener(actionListener);
        }
    });
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.addItemListener(ItemListener)} through queue
 */
public void addItemListener(final ItemListener itemListener) {
    runMapping(new MapVoidAction("addItemListener") {
        @Override
        public void map() {
            ((List) getSource()).addItemListener(itemListener);
        }
    });
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.deselect(int)} through queue
 */
public void deselect(final int i) {
    runMapping(new MapVoidAction("deselect") {
        @Override
        public void map() {
            ((List) getSource()).deselect(i);
        }
    });
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.getItem(int)} through queue
 */
public String getItem(final int i) {
    return (runMapping(new MapAction<String>("getItem") {
        @Override
        public String map() {
            return ((List) getSource()).getItem(i);
        }
    }));
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.getItemCount()} through queue
 */
public int getItemCount() {
    return (runMapping(new MapIntegerAction("getItemCount") {
        @Override
        public int map() {
            return ((List) getSource()).getItemCount();
        }
    }));
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.getItems()} through queue
 */
public String[] getItems() {
    return ((String[]) runMapping(new MapAction<Object>("getItems") {
        @Override
        public Object map() {
            return ((List) getSource()).getItems();
        }
    }));
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.getMinimumSize(int)} through queue
 */
public Dimension getMinimumSize(final int i) {
    return (runMapping(new MapAction<Dimension>("getMinimumSize") {
        @Override
        public Dimension map() {
            return ((List) getSource()).getMinimumSize(i);
        }
    }));
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.getPreferredSize(int)} through queue
 */
public Dimension getPreferredSize(final int i) {
    return (runMapping(new MapAction<Dimension>("getPreferredSize") {
        @Override
        public Dimension map() {
            return ((List) getSource()).getPreferredSize(i);
        }
    }));
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.getRows()} through queue
 */
public int getRows() {
    return (runMapping(new MapIntegerAction("getRows") {
        @Override
        public int map() {
            return ((List) getSource()).getRows();
        }
    }));
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.getSelectedIndex()} through queue
 */
public int getSelectedIndex() {
    return (runMapping(new MapIntegerAction("getSelectedIndex") {
        @Override
        public int map() {
            return ((List) getSource()).getSelectedIndex();
        }
    }));
}
项目:openjdk-jdk10    文件:ListOperator.java   
/**
 * Maps {@code List.getSelectedIndexes()} through queue
 */
public int[] getSelectedIndexes() {
    return ((int[]) runMapping(new MapAction<Object>("getSelectedIndexes") {
        @Override
        public Object map() {
            return ((List) getSource()).getSelectedIndexes();
        }
    }));
}