javax.swing.JList#getInsets ( )源码实例Demo

下面列出了javax.swing.JList#getInsets ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: stendhal   文件: MemberCellRenderer.java
@Override
public Component getListCellRendererComponent(JList<? extends Member> list,
		Member member, int index, boolean isSelected, boolean cellHasFocus) {
	label.setText(member.getName());
	if (member.isLeader()) {
		label.setFont(boldFont);
	} else {
		label.setFont(normalFont);
	}

	/*
	 * This is very, very ugly. JList does not resize the component
	 * normally, so the StatusDisplayBar never gets the chance to update
	 * the model. Try to figure out the correct width.
	 */
	Insets insets = hpBar.getInsets();
	int barWidth = list.getWidth() - insets.left - insets.right - 2;
	insets = list.getInsets();
	barWidth -= insets.left + insets.right;
	hpBar.getModel().setMaxRepresentation(barWidth);

	if (member.isPresent()) {
		hpBar.setPresent(true);
		hpBar.setRatio(member.getHpRatio());
	} else {
		hpBar.setPresent(false);
	}

	return renderer;
}
 
源代码2 项目: chipster   文件: ToolFilterPanel.java
public ToolFilterPanel(ToolPanel parent,
       List<ToolCategory> categories) {
    super(new GridLayout(1, 2));
    this.toolPanel = parent;
    this.categories = categories;
    
    categoryList = new JList();
    categoryList.setSelectedIndex(0);
    categoryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    categoryList.addListSelectionListener(this);
    categoryList.setCellRenderer(new ToolSelectorPanel.CategoryListRenderer());
    categoryList.getInsets().right = 1;
    categoryList.setName("categoryList");
    
    // Operation list shows the results
    visibleOperationsList = new JList();
    visibleOperationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    visibleOperationsList.addListSelectionListener(this);
    visibleOperationsList.setCellRenderer(new ToolSelectorPanel.FontSizeFriendlyListRenderer());
    visibleOperationsList.getInsets().right = 1;
    visibleOperationsList.setName("operationList");
    
    JScrollPane categoryListScroller = new JScrollPane(categoryList);       
    JScrollPane operationListScroller = new JScrollPane(visibleOperationsList);
    categoryListScroller.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1,
            VisualConstants.TOOL_LIST_BORDER_COLOR));
    operationListScroller.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    this.add(categoryListScroller);
    this.add(operationListScroller);        
}
 
源代码3 项目: chipster   文件: ToolSelectorPanel.java
/**
 * Creates a new ToolSelectorPanel.
 * 
 * @param parent The ToolPanel, for communication purposes.
 */
public ToolSelectorPanel(ToolPanel parent, ToolModule toolModule) {
	super(new GridLayout(1, 2));
	this.toolPanel = parent;
	this.toolModule = toolModule;
	
       List<ToolCategory> toolCategories;
       toolCategories = Collections.list(Collections.enumeration(toolModule.getVisibleCategories()));
       
	categoryList = new JList();
	categoryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	categoryList.addListSelectionListener(this);
	categoryList.setCellRenderer(new CategoryListRenderer());
	categoryList.getInsets().right = 1;
	categoryList.setName("categoryList");
	categoryList.setListData(toolCategories.toArray());
	
	
	
	toolList = new JList();
	toolList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	toolList.addListSelectionListener(this);
	toolList.setCellRenderer(new FontSizeFriendlyListRenderer());
	toolList.addMouseListener(new MouseClickListener());
	toolList.getInsets().right = 1;
	toolList.setName("toolList");
	
	JScrollPane categoryListScroller = new JScrollPane(categoryList);		
	JScrollPane toolListScroller = new JScrollPane(toolList);
	
	//Remove useless borders
	categoryListScroller.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1,
	        VisualConstants.TOOL_LIST_BORDER_COLOR));
	toolListScroller.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
	
	this.add(categoryListScroller);
	this.add(toolListScroller);
}