addMouseListener ( )源码实例Demo

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

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

源代码1 项目: TencentKona-8   文件: CheckRenderer.java
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
源代码2 项目: jdk8u60   文件: CheckRenderer.java
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
源代码3 项目: openjdk-jdk8u   文件: CheckRenderer.java
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
源代码4 项目: marathonv5   文件: Main.java
public Main() {
    super("Demo Programs");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    List<String> resources = FindResources.findClasses("Demo");
    final ResourceListModel dataModel = new ResourceListModel(resources);
    final JList list = new JList(dataModel);
    list.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                int index = list.locationToIndex(e.getPoint());
                if (index != -1)
                    dataModel.load(index);
            }
        }
    });
    add(new JScrollPane(list));
    pack();
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: CheckRenderer.java
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
源代码6 项目: openjdk-jdk9   文件: CheckRenderer.java
public CheckRenderer(final JList<Object> list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
源代码7 项目: hottub   文件: CheckRenderer.java
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
源代码8 项目: openjdk-8-source   文件: CheckRenderer.java
public CheckRenderer(final JList list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
源代码9 项目: Spark   文件: MissedCalls.java
public MissedCalls() {
    model = new DefaultListModel();
    list = new JList(model);
    gui = getMissedCallPanel();


    list.setCellRenderer(new MissedCallRenderer());
    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent mouseEvent) {
            if (mouseEvent.getClickCount() == 2) {
                placeCall((MissedCall)list.getSelectedValue());
            }
        }
    });

    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }

            int selectedIndex = list.getSelectedIndex();
            boolean enabled = selectedIndex != -1;
            callBackButton.setEnabled(enabled);
            deleteButton.setEnabled(enabled);
        }
    });
}
 
源代码10 项目: iBioSim   文件: Utility.java
public static/* Create add/remove/edit panel */
JPanel createPanel(ActionListener listener, String panelName,
		JList panelJList, JButton addButton, JButton removeButton,
		JButton editButton) {
	JPanel Panel = new JPanel(new BorderLayout());
	JPanel addRem = new JPanel();
	if (addButton != null) {
		addButton.addActionListener(listener);
		addRem.add(addButton);
	}
	if (removeButton != null) {
		removeButton.addActionListener(listener);
		addRem.add(removeButton);
	}
	if (editButton != null) {
		addRem.add(editButton);
		editButton.addActionListener(listener);
	}

	JLabel panelLabel = new JLabel("List of " + panelName + ":");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(panelJList);

	if (listener instanceof MouseListener) {
		panelJList.addMouseListener((MouseListener) listener);
	}
	Panel.add(panelLabel, "North");
	Panel.add(scroll, "Center");
	Panel.add(addRem, "South");
	return Panel;
}
 
源代码11 项目: iBioSim   文件: Units.java
public Units(BioModel gcm, ModelEditor modelEditor) {
	super(new BorderLayout());
	this.bioModel = gcm;
	this.modelEditor = modelEditor;
	Model model = gcm.getSBMLDocument().getModel();
	addUnit = new JButton("Add Unit");
	removeUnit = new JButton("Remove Unit");
	editUnit = new JButton("Edit Unit");
	unitDefs = new JList();
	ListOf<UnitDefinition> listOfUnits = model.getListOfUnitDefinitions();
	String[] units = new String[model.getUnitDefinitionCount()];
	for (int i = 0; i < model.getUnitDefinitionCount(); i++) {
		UnitDefinition unit = listOfUnits.get(i);
		units[i] = unit.getId();
		// GET OTHER THINGS
	}
	JPanel addRem = new JPanel();
	addRem.add(addUnit);
	addRem.add(removeUnit);
	addRem.add(editUnit);
	addUnit.addActionListener(this);
	removeUnit.addActionListener(this);
	editUnit.addActionListener(this);
	JLabel panelLabel = new JLabel("List of Units:");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(unitDefs);
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(units);
	unitDefs.setListData(units);
	unitDefs.setSelectedIndex(0);
	unitDefs.addMouseListener(this);
	this.add(panelLabel, "North");
	this.add(scroll, "Center");
	this.add(addRem, "South");
}
 
源代码12 项目: ganttproject   文件: RoleSetPage.java
@Override
public Component getComponent() {
  Box domainBox = new Box(BoxLayout.PAGE_AXIS);
  JLabel label = new JLabel(GanttLanguage.getInstance().getText("chooseRoleSets"));

  final JList roleSetsList = new JList(myListModel);
  roleSetsList.setCellRenderer(myListModel.getCellRenderer());
  roleSetsList.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      int index = roleSetsList.locationToIndex(e.getPoint());
      myListModel.toggle(index);
    }
  });
  roleSetsList.setAlignmentX(0);
  label.setLabelFor(roleSetsList);
  label.setAlignmentX(0);

  domainBox.add(label);
  domainBox.add(Box.createVerticalStrut(5));
  domainBox.add(roleSetsList);

  JPanel result = new JPanel(new BorderLayout());
  result.add(domainBox, BorderLayout.CENTER);
  // result.setBorder(LineBorder.createBlackLineBorder());
  return result;
}
 
源代码13 项目: importer-exporter   文件: CheckBoxListDecorator.java
public CheckBoxListDecorator(JList<T> list) {
	this.list = list;

	list.setCellRenderer(new CheckBoxListCellRenderer<T>());
	list.addMouseListener(this); 
	list.addPropertyChangeListener(this);
	list.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED); 

	checkBoxSelectionModel = new DefaultListSelectionModel();
	checkBoxSelectionModel.addListSelectionListener(this);

	enabled = new HashMap<Integer, Boolean>();
	width = new JCheckBox().getPreferredSize().width;
}
 
源代码14 项目: 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);
}
 
源代码15 项目: radiance   文件: JCarouselMenu.java
/**
 * Creates a new instance of JCarouselMenu
 * @param border The border to use to draw items in the menu
 */
public JCarouselMenu(ImageBorder border) {
    carousel = new JCarosel();
    carousel.setLayout(new OffsetCaroselLayout(carousel));
    carousel.setBackground(null);
    carousel.setOpaque(false);
    carousel.setContentWidth(256);
    
    super.setLayout(new GridLayout(1,2));
    super.add(carousel);
    
    upButton.setForeground(Color.WHITE);
    downButton.setForeground(Color.WHITE);
    
    JPanel menuPanel = new JPanel();
    menuPanel.setBackground(null);
    menuPanel.setOpaque(false);
    menuPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc  = new GridBagConstraints();
    
    menu = new JList();
    menuScroll = new JScrollPane(menu, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    menuScroll.getViewport().setOpaque(false);
    menuScroll.setBorder(null);
    menuScroll.getViewport().addChangeListener(this);
    menu.setModel(menuModel);
    menu.setCellRenderer(new CarouselListCellRenderer(border));
    menu.setBackground(null);       
    menu.setOpaque(false);
    menu.addListSelectionListener(this);
    menuScroll.setOpaque(true);
    menuScroll.setBackground(Color.BLACK);
    menuScroll.setBorder(BorderFactory.createEmptyBorder());
    
    gbc.weightx=0.0;
    gbc.weighty=0.0;
    gbc.gridy=0;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    menuPanel.add(upButton,gbc);
    gbc.weighty=1.0;
    gbc.weightx=1.0;
    gbc.gridy++;
    gbc.fill=GridBagConstraints.BOTH;
    menuPanel.add(menuScroll,gbc);
    gbc.weighty=0.0;
    gbc.weightx=0.0;
    gbc.gridy++;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    menuPanel.add(downButton,gbc);
    menu.addMouseListener(this);
    menu.addKeyListener(this);
            
    //Don't want it to listen to itself...
    carousel.removeMouseWheelListener(carousel);
    carousel.addMouseWheelListener(this);
    menu.addMouseWheelListener(this);
    menuScroll.addMouseWheelListener(this);
    menuPanel.addMouseWheelListener(this);
    
    super.add(menuPanel);
}
 
源代码16 项目: Spark   文件: ChatHistory.java
public ChatHistory() {
    list = new JList(model);

    list.setCellRenderer(new HistoryItemRenderer());

    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.setBackground(Color.white);


    final BackgroundPane titlePane = new BackgroundPane() {
        public Dimension getPreferredSize() {
            final Dimension size = super.getPreferredSize();
            size.width = 0;
            return size;
        }
    };

    titlePane.setLayout(new GridBagLayout());
    titlePane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));


    JLabel userImage = new JLabel();
    userImage.setHorizontalAlignment(JLabel.LEFT);
    userImage.setText(FpRes.getString("title.previous.chats"));
    userImage.setIcon(FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_24x24));
    titlePane.add(userImage, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    userImage.setFont(new Font("Dialog", Font.BOLD, 12));
    mainPanel.add(titlePane, BorderLayout.NORTH);

    mainPanel.add(list, BorderLayout.CENTER);

    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
    init();

    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                HistoryItem historyItem = (HistoryItem)list.getSelectedValue();
                showTranscript(historyItem.getSessionID());
            }
        }
    });
}
 
源代码17 项目: nullpomino   文件: NullpoMinoSwing.java
/**
 * Init top screen
 */
protected void initTopScreenUI(JComponent p) {
	p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

	// Label
	lModeSelect = new JLabel(getUIText("Top_ModeSelect"));
	lModeSelect.setAlignmentX(0f);
	p.add(lModeSelect);

	// Mode & rule select panel
	JPanel subpanelModeSelect = new JPanel(new BorderLayout());
	subpanelModeSelect.setBorder(new EtchedBorder());
	subpanelModeSelect.setAlignmentX(0f);
	p.add(subpanelModeSelect);

	// * Mode select listbox
	listboxMode = new JList(modeList);
	listboxMode.addMouseListener(new ListboxModeMouseAdapter());
	listboxMode.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent e) {
			String strMode = (String)listboxMode.getSelectedValue();
			lModeSelect.setText(getModeDesc(strMode));
			prepareRuleList(strMode);
		}
	});
	JScrollPane scpaneListboxMode = new JScrollPane(listboxMode);
	scpaneListboxMode.setPreferredSize(new Dimension(280, 375));
	subpanelModeSelect.add(scpaneListboxMode, BorderLayout.WEST);

	// * Rule select listbox
	listmodelRule = new DefaultListModel();
	listboxRule = new JList(listmodelRule);
	listboxRule.addMouseListener(new ListboxModeMouseAdapter());
	JScrollPane scpaneListBoxRule = new JScrollPane(listboxRule);
	scpaneListBoxRule.setPreferredSize(new Dimension(150, 375));
	subpanelModeSelect.add(scpaneListBoxRule, BorderLayout.CENTER);

	// * Set default selected index
	listboxMode.setSelectedValue(propGlobal.getProperty("name.mode", ""), true);
	if(listboxMode.getSelectedIndex() == -1) listboxMode.setSelectedIndex(0);
	prepareRuleList((String)listboxMode.getSelectedValue());

	// Start button
	JButton buttonStartOffline = new JButton(getUIText("Top_StartOffline"));
	buttonStartOffline.setMnemonic('S');
	buttonStartOffline.addActionListener(this);
	buttonStartOffline.setActionCommand("Top_StartOffline");
	buttonStartOffline.setAlignmentX(0f);
	buttonStartOffline.setMaximumSize(new Dimension(Short.MAX_VALUE, buttonStartOffline.getMaximumSize().height));
	p.add(buttonStartOffline);
	this.getRootPane().setDefaultButton(buttonStartOffline);

	// Menu
	initMenu();
}
 
源代码18 项目: iBioSim   文件: FBAObjective.java
public FBAObjective(BioModel bioModel) {
	super(new BorderLayout());
	this.bioModel = bioModel;
	fbc = bioModel.getSBMLFBC();
	
	bigPanel = new JPanel(new BorderLayout());
	objectiveStringArray = new String[fbc.getListOfObjectives().size()];
	activeObjective = fbc.getListOfObjectives().getActiveObjective();
		
	for (int i = 0; i < fbc.getListOfObjectives().size(); i++) {
		String objective = "";
		Type type = fbc.getObjective(i).getType();
		String id = fbc.getObjective(i).getId();
		if(activeObjective.equals(id)){
			objective = "*";
		}
		if (type.equals(Type.MINIMIZE)) {
			objective += "Min";
		}
		else {
			objective += "Max";
		}
		objective += "(" + id + ") = ";
		boolean first = true;
		for (int j = 0; j < fbc.getObjective(i).getListOfFluxObjectives().size(); j++) {
			FluxObjective fluxObjective = fbc.getObjective(i).getListOfFluxObjectives().get(j);
			String indexStr = SBMLutilities.getIndicesString(fluxObjective, "fbc:reaction");
			if (!first) objective += " + "; else first = false;
			objective += fluxObjective.getCoefficient() + " * " + fluxObjective.getReaction() + indexStr;
		}
		objectiveStringArray[i] = objective;
	}
	objectives = new JList();
	objectiveList = new JList();
	
	JPanel ObjectiveCreationPanel = new JPanel(new BorderLayout());
	JPanel buttons = new JPanel();
	JButton addObjective = new JButton("Add");
	JButton removeObjective = new JButton("Remove");
	JButton editObjective = new JButton("Edit");
	buttons.add(addObjective);
	buttons.add(removeObjective);
	buttons.add(editObjective);
	addObjective.addActionListener(this);
	removeObjective.addActionListener(this);
	editObjective.addActionListener(this);
	JLabel ObjectiveCreationLabel = new JLabel("List of Objectives:");
	objectiveList.removeAll();
	objectiveList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(objectiveList);
	
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(objectiveStringArray);
	objectiveList.setListData(objectiveStringArray);
	objectiveList.setSelectedIndex(0);
	objectiveList.addMouseListener(this);
	ObjectiveCreationPanel.add(ObjectiveCreationLabel, "North");
	ObjectiveCreationPanel.add(scroll, "Center");
	ObjectiveCreationPanel.add(buttons, "South");
	
	bigPanel.add(ObjectiveCreationPanel, "South");
}
 
源代码19 项目: iBioSim   文件: Constraints.java
public Constraints(BioModel bioModel, ModelEditor modelEditor) {
	super(new BorderLayout());
	this.bioModel = bioModel;
	this.modelEditor = modelEditor;
	Model model = bioModel.getSBMLDocument().getModel();
	addConstraint = new JButton("Add Constraint");
	removeConstraint = new JButton("Remove Constraint");
	editConstraint = new JButton("Edit Constraint");
	constraints = new JList();
	ListOf<Constraint> listOfConstraints = model.getListOfConstraints();
	String[] cons = new String[model.getConstraintCount()];
	for (int i = 0; i < model.getConstraintCount(); i++) {
		Constraint constraint = listOfConstraints.get(i);
		if (!constraint.isSetMetaId()) {
			String constraintId = "c0";
			int cn = 0;
			while (bioModel.isSIdInUse(constraintId)) {
				cn++;
				constraintId = "c" + cn;
			}
			SBMLutilities.setMetaId(constraint, constraintId);
		}
		cons[i] = constraint.getMetaId();
		cons[i] += SBMLutilities.getDimensionString(constraint);
	}
	JPanel addRem = new JPanel();
	addRem.add(addConstraint);
	addRem.add(removeConstraint);
	addRem.add(editConstraint);
	addConstraint.addActionListener(this);
	removeConstraint.addActionListener(this);
	editConstraint.addActionListener(this);
	JLabel panelLabel = new JLabel("List of Constraints:");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(constraints);
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(cons);
	constraints.setListData(cons);
	constraints.setSelectedIndex(0);
	constraints.addMouseListener(this);
	this.add(panelLabel, "North");
	this.add(scroll, "Center");
	this.add(addRem, "South");
}
 
源代码20 项目: filthy-rich-clients   文件: SpringDemo.java
private JComponent buildList() {
    Application[] elements = new Application[] {
        new Application("Address Book", "x-office-address-book.png"),
        new Application("Calendar",     "x-office-calendar.png"),
        new Application("Presentation", "x-office-presentation.png"),
        new Application("Spreadsheet",  "x-office-spreadsheet.png"),
    };
    
    list = new JList(elements);
    list.setCellRenderer(new ApplicationListCellRenderer());
    list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    list.setVisibleRowCount(2);
    list.setBorder(BorderFactory.createEtchedBorder());
    list.addMouseListener(new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
             if (e.getClickCount() == 2) {
                 int index = list.getSelectedIndex();
                 
                 Rectangle bounds = list.getCellBounds(index, index);
                 Point location = new Point(bounds.x, bounds.y);
                 location = SwingUtilities.convertPoint(list, location, glassPane);
                 location.y -= 13;
                 bounds.setLocation(location);
                 
                 glassPane.showSpring(bounds,
                         ((Application) list.getSelectedValue()).icon.getImage());
             }
         }
     });
    
    JPanel panel = new JPanel(new GridBagLayout());
    panel.add(new JLabel("Launcher"),
            new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
                GridBagConstraints.LINE_START, GridBagConstraints.NONE,
                new Insets(0, 0, 0, 0), 0, 0));
    panel.add(list, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0), 0, 0));
    panel.add(new JLabel("Double-click an icon to launch the program"),
            new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0,
                GridBagConstraints.LINE_START, GridBagConstraints.NONE,
                new Insets(0, 0, 0, 0), 0, 0));
    
    return panel;
}