當前位置: 首頁>>代碼示例>>Java>>正文


Java List類代碼示例

本文整理匯總了Java中java.awt.List的典型用法代碼示例。如果您正苦於以下問題:Java List類的具體用法?Java List怎麽用?Java List使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


List類屬於java.awt包,在下文中一共展示了List類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: m

import java.awt.List; //導入依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:ClassMemberTest.java

示例2: getUserInfo

import java.awt.List; //導入依賴的package包/類
@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;		
	}
 
開發者ID:tojaoomy,項目名稱:private-WeChat,代碼行數:32,代碼來源:AuthorizationService.java

示例3: layoutWhoPanel

import java.awt.List; //導入依賴的package包/類
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;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:19,代碼來源:UserDialogAWT.java

示例4: main

import java.awt.List; //導入依賴的package包/類
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();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:R2303044ListSelection.java

示例5: ActionEventTest

import java.awt.List; //導入依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:ActionEventTest.java

示例6: ItemEventTest

import java.awt.List; //導入依賴的package包/類
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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:ItemEventTest.java

示例7: checkComponent

import java.awt.List; //導入依賴的package包/類
@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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:ListOperator.java

示例8: ActionEventTest

import java.awt.List; //導入依賴的package包/類
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();
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:17,代碼來源:ActionEventTest.java

示例9: init

import java.awt.List; //導入依賴的package包/類
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();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:27,代碼來源:Demo.java

示例10: setup

import java.awt.List; //導入依賴的package包/類
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 );
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:21,代碼來源:QtListPeer.java

示例11: fireChoice

import java.awt.List; //導入依賴的package包/類
/**
 * 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);
      }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:19,代碼來源:QtListPeer.java

示例12: testDocSynchronizerPrefersLineBoundaryChanges

import java.awt.List; //導入依賴的package包/類
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());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:RangeMarkerTest.java

示例13: testRangeHighlighterLinesInRangeForLongLinePerformance

import java.awt.List; //導入依賴的package包/類
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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:RangeMarkerTest.java

示例14: createPDs

import java.awt.List; //導入依賴的package包/類
/** @return Propertydescriptors */
@Override
protected PropertyDescriptor[] createPDs() throws IntrospectionException {
    return new PropertyDescriptor[] {
        new PropertyDescriptor("multipleMode", List.class), // NOI18N
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:ListBeanInfo.java

示例15: createList

import java.awt.List; //導入依賴的package包/類
@Override
public final ListPeer createList(List target) {
    PlatformComponent platformComponent = createPlatformComponent();
    LWListPeer peer = new LWListPeer(target, platformComponent);
    targetCreatedPeer(target, peer);
    peer.initialize();
    return peer;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:LWToolkit.java


注:本文中的java.awt.List類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。