本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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 );
}
示例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);
}
}
示例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());
}
示例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();
}
示例14: createPDs
import java.awt.List; //导入依赖的package包/类
/** @return Propertydescriptors */
@Override
protected PropertyDescriptor[] createPDs() throws IntrospectionException {
return new PropertyDescriptor[] {
new PropertyDescriptor("multipleMode", List.class), // NOI18N
};
}
示例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;
}