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

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

源代码1 项目: filthy-rich-clients   文件: SplineControlPanel.java
private Component createTemplates() {
    DefaultListModel model = new DefaultListModel();
    model.addElement(createTemplate(0.0, 0.0, 1.0, 1.0));
    model.addElement(createTemplate(0.0, 1.0, 0.0, 1.0));
    model.addElement(createTemplate(0.0, 1.0, 1.0, 1.0));
    model.addElement(createTemplate(0.0, 1.0, 1.0, 0.0));
    model.addElement(createTemplate(1.0, 0.0, 0.0, 1.0));
    model.addElement(createTemplate(1.0, 0.0, 1.0, 1.0));
    model.addElement(createTemplate(1.0, 0.0, 1.0, 0.0));
    
    JList list = new JList(model);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setCellRenderer(new TemplateCellRenderer());
    list.addListSelectionListener(new TemplateSelectionHandler());
    
    JScrollPane pane = new JScrollPane(list);
    pane.getViewport().setPreferredSize(new Dimension(98, 97 * 3));
    return pane;
}
 
源代码2 项目: iBioSim   文件: FBAObjective.java
private static void removeObjective(JList objectiveList) {
	// find where the selected objective is on the list
	int index = objectiveList.getSelectedIndex();
	if (index != -1) {
		objectiveList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		// remove it
		Utility.remove(objectiveList);
		objectiveList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		if (index < objectiveList.getModel().getSize()) {
			objectiveList.setSelectedIndex(index);
		}
		else {
			objectiveList.setSelectedIndex(index - 1);
		}
	}
}
 
源代码3 项目: jason   文件: KillAgentGUI.java
@SuppressWarnings("unchecked")
protected void initComponents() {
    services = RuntimeServicesFactory.get();
    getContentPane().setLayout(new BorderLayout());

    // Fields
    Vector<String> agNames = new Vector<String>(services.getAgentsNames());
    Collections.sort(agNames);
    lAgs = new JList(agNames);
    lAgs.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    JPanel p = new JPanel(new BorderLayout());
    p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Current agents", TitledBorder.LEFT, TitledBorder.TOP));
    p.add(lAgs, BorderLayout.CENTER);

    getContentPane().add(p, BorderLayout.CENTER);
    getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
    ok.setText("Kill");
}
 
源代码4 项目: marathonv5   文件: DropDemo.java
private JPanel createList() {
    DefaultListModel listModel = new DefaultListModel();

    for (int i = 0; i < 10; i++) {
        listModel.addElement("List Item " + i);
    }

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    JScrollPane scrollPane = new JScrollPane(list);
    scrollPane.setPreferredSize(new Dimension(400, 100));

    list.setDragEnabled(true);
    list.setTransferHandler(new ListTransferHandler());

    dropCombo = new JComboBox(new String[] { "USE_SELECTION", "ON", "INSERT", "ON_OR_INSERT" });
    dropCombo.addActionListener(this);
    JPanel dropPanel = new JPanel();
    dropPanel.add(new JLabel("List Drop Mode:"));
    dropPanel.add(dropCombo);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(dropPanel, BorderLayout.SOUTH);
    panel.setBorder(BorderFactory.createTitledBorder("List"));
    return panel;
}
 
源代码5 项目: Open-LaTeX-Studio   文件: DbxFileActions.java
/**
 * Shows a .tex files list from user's dropbox and opens the selected one
 *
 * @return List, that contatins user's .tex files from his dropbox; can be
 * empty
 */
public void openFromDropbox(DropboxRevisionsTopComponent drtc, RevisionDisplayTopComponent revtc) {
    List<DbxEntryDto> dbxEntries = getDbxTexEntries(DbxUtil.getDbxClient());

    if (!dbxEntries.isEmpty()) {
        JList<DbxEntryDto> list = new JList(dbxEntries.toArray());
        list.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
        int option = JOptionPane.showConfirmDialog(null, list, "Open file from Dropbox", JOptionPane.OK_CANCEL_OPTION);

        if (option == JOptionPane.OK_OPTION && !list.isSelectionEmpty()) {
            DbxEntryDto entry = list.getSelectedValue();
            String localPath = ApplicationUtils.getAppDirectory() + File.separator + entry.getName();
            File outputFile = DbxUtil.downloadRemoteFile(entry, localPath);

            revtc.close();

            drtc.updateRevisionsList(entry.getPath());
            drtc.open();
            drtc.requestActive();

            String content = FileService.readFromFile(outputFile.getAbsolutePath());
            etc.setEditorContent(content);
            etc.setCurrentFile(outputFile);
            etc.getEditorState().setDbxState(new DbxState(entry.getPath(), entry.getRevision()));
            etc.getEditorState().setModified(false);
            etc.getEditorState().setPreviewDisplayed(false);
        }
    } else{
        JOptionPane.showMessageDialog(etc, "No .tex files found!", "Error", JOptionPane.ERROR_MESSAGE);
    }
}
 
源代码6 项目: netbeans   文件: FilesModifiedConfirmation.java
private JList createFilesList(SaveCookie[] saveCookies) {
    JList filesList = new JList(
                listModel = new ArrayListModel<SaveCookie>(saveCookies));
    filesList.setVisibleRowCount(8);
    filesList.setPrototypeCellValue(PROTOTYPE_LIST_CELL_VALUE);
    filesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    filesList.addListSelectionListener(listener);
    filesList.setCellRenderer(new ListCellRenderer());

    return filesList;
}
 
源代码7 项目: pentaho-reporting   文件: ConnectionPanel.java
protected void initPanel()
{
  setLayout(new BorderLayout());

  final JList dataSourceList = new JList(dialogModel.getConnections());
  dataSourceList.setCellRenderer(new DataSourceDefinitionListCellRenderer());
  dataSourceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  dataSourceList.addListSelectionListener(new DataSourceDefinitionListSelectionListener(dataSourceList));
  dataSourceList.setVisibleRowCount(10);

  final SelectionConnectionUpdateHandler theSelectedConnectionAction = new SelectionConnectionUpdateHandler(
      dataSourceList);
  dialogModel.addPropertyChangeListener(theSelectedConnectionAction);

  final EditDataSourceAction editDataSourceAction = new EditDataSourceAction(dataSourceList);
  dialogModel.addPropertyChangeListener(editDataSourceAction);

  final RemoveDataSourceAction removeDataSourceAction = new RemoveDataSourceAction(dataSourceList);
  dialogModel.addPropertyChangeListener(removeDataSourceAction);

  final JPanel connectionButtonPanel = new JPanel();
  connectionButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
  if (isSecurityConfigurationAvailable())
  {
    connectionButtonPanel.add(new JButton(createEditSecurityAction()));
    connectionButtonPanel.add(Box.createHorizontalStrut(40));
  }
  connectionButtonPanel.add(new BorderlessButton(editDataSourceAction));
  connectionButtonPanel.add(new BorderlessButton(new AddDataSourceAction(dataSourceList)));
  connectionButtonPanel.add(new BorderlessButton(removeDataSourceAction));

  final JPanel connectionButtonPanelWrapper = new JPanel(new BorderLayout());
  connectionButtonPanelWrapper.add(new JLabel(bundleSupport.getString("ConnectionPanel.Connections")), BorderLayout.CENTER);
  connectionButtonPanelWrapper.add(connectionButtonPanel, BorderLayout.EAST);

  add(BorderLayout.NORTH, connectionButtonPanelWrapper);
  add(BorderLayout.CENTER, new JScrollPane(dataSourceList));
}
 
源代码8 项目: Open-Realms-of-Stars   文件: DiplomacyView.java
/**
 * Create Fleet List from fleet array
 * @param fleets Which are used for creating Fleet List
 * @return JList full of fleets
 */
private JList<Fleet> createFleetList(final Fleet[] fleets) {
  JList<Fleet> fleetList = new JList<>(fleets);
  fleetList.setCellRenderer(new FleetListRenderer());
  fleetList.setBackground(Color.BLACK);
  fleetList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  return fleetList;
}
 
源代码9 项目: amidst   文件: LicenseWindow.java
private JList<License> createLicenseList(License[] licenses, final JTextArea textArea) {
	final JList<License> result = new JList<>(licenses);
	result.setBorder(new LineBorder(Color.darkGray, 1));
	result.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	result.addListSelectionListener(new ListSelectionListener() {
		@Override
		public void valueChanged(ListSelectionEvent e) {
			textArea.setText(result.getSelectedValue().getLicenseText());
			textArea.setCaretPosition(0);
		}
	});
	result.setSelectedIndex(0);
	return result;
}
 
源代码10 项目: triplea   文件: TripleAFrame.java
/**
 * Prompts the user to select the territory on which they wish to conduct a rocket attack.
 *
 * @param candidates The collection of territories on which the user may conduct a rocket attack.
 * @param from The territory from which the rocket attack is conducted.
 * @return The selected territory or {@code null} if no territory was selected.
 */
public Territory getRocketAttack(final Collection<Territory> candidates, final Territory from) {
  messageAndDialogThreadPool.waitForAll();
  mapPanel.centerOn(from);

  final Supplier<Territory> action =
      () -> {
        final JList<Territory> list = new JList<>(SwingComponents.newListModel(candidates));
        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list.setSelectedIndex(0);
        final JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        final JScrollPane scroll = new JScrollPane(list);
        panel.add(scroll, BorderLayout.CENTER);
        if (from != null) {
          panel.add(BorderLayout.NORTH, new JLabel("Targets for rocket in " + from.getName()));
        }
        final String[] options = {"OK", "Dont attack"};
        final String message = "Select Rocket Target";
        final int selection =
            JOptionPane.showOptionDialog(
                TripleAFrame.this,
                panel,
                message,
                JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE,
                null,
                options,
                null);
        return (selection == 0) ? list.getSelectedValue() : null;
      };
  return Interruptibles.awaitResult(() -> SwingAction.invokeAndWaitResult(action))
      .result
      .orElse(null);
}
 
源代码11 项目: snap-desktop   文件: SourceProductList.java
private JList<Object> createInputPathsList(InputListModel inputListModel) {
    JList<Object> list = new JList<>(inputListModel);
    list.setCellRenderer(new SourceProductListRenderer());
    list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    return list;
}
 
源代码12 项目: snap-desktop   文件: AddElevationAction.java
public SingleSelectionListComponentAdapter(JList list) {
    this.list = list;
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
 
源代码13 项目: nanoleaf-desktop   文件: GroupDeleterDialog.java
private void initUI(Component parent)
{
	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	setSize(474, 225);
	setLocationRelativeTo(parent);
	setUndecorated(true);
	JPanel contentPane = new JPanel();
	contentPane.setBackground(Color.DARK_GRAY);
	contentPane.setBorder(new LineBorder(new Color(128, 128, 128), 2));
	setContentPane(contentPane);
	contentPane.setLayout(new MigLayout("", "[255.00,grow][106.00,grow][grow]", "[][grow][]"));
	
	WindowDragListener wdl = new WindowDragListener(50);
	addMouseListener(wdl);
	addMouseMotionListener(wdl);
	
	JLabel lblTitle = new JLabel("Select a Group");
	lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 22));
	lblTitle.setForeground(Color.WHITE);
	contentPane.add(lblTitle, "gapx 15 0, cell 0 0");
	
	CloseButton btnClose = new CloseButton(this, JFrame.DISPOSE_ON_CLOSE);
	contentPane.add(btnClose, "cell 2 0,alignx right,gapx 0 15");
	
	JScrollPane devicesScrollPane = new JScrollPane();
	devicesScrollPane.setBorder(null);
	devicesScrollPane.getHorizontalScrollBar().setUI(new ModernScrollBarUI());
	devicesScrollPane.getVerticalScrollBar().setUI(new ModernScrollBarUI());
	contentPane.add(devicesScrollPane, "cell 0 1 3 1,grow");
	
	groupsModel = new DefaultListModel<String>();
	JList<String> listGroups = new JList<String>(groupsModel);
	listGroups.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	listGroups.setFont(new Font("Tahoma", Font.PLAIN, 20));
	listGroups.setBackground(Color.DARK_GRAY);
	listGroups.setBorder(new LineBorder(Color.GRAY));
	listGroups.setForeground(Color.WHITE);
	devicesScrollPane.setViewportView(listGroups);
	
	JButton btnCreateGroup = new ModernButton("Delete Group");
	btnCreateGroup.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			deleteGroup(listGroups.getSelectedValue());
		}
	});
	contentPane.add(btnCreateGroup, "cell 2 2");
}
 
public PerformanceVectorViewer(final PerformanceVector performanceVector, final IOContainer container) {
	setLayout(new BorderLayout());

	// all criteria
	final CardLayout cardLayout = new CardLayout();
	final JPanel mainPanel = new JPanel(cardLayout);
	add(mainPanel, BorderLayout.CENTER);
	List<String> criteriaNameList = new LinkedList<>();
	for (int i = 0; i < performanceVector.getSize(); i++) {
		PerformanceCriterion criterion = performanceVector.getCriterion(i);
		criteriaNameList.add(criterion.getName());
		JPanel component = ResultDisplayTools.createVisualizationComponent(criterion, container,
				"Performance Criterion", false);
		JScrollPane criterionPane = new ExtendedJScrollPane(component);
		criterionPane.setBorder(null);
		criterionPane.setBackground(Colors.WHITE);
		mainPanel.add(criterionPane, criterion.getName());
	}
	if (criteriaNameList.isEmpty()) {
		remove(mainPanel);
		add(new ResourceLabel("result_view.no_criterions"));
		return;
	}
	String[] criteriaNames = new String[criteriaNameList.size()];
	criteriaNameList.toArray(criteriaNames);

	// selection list
	final JList<String> criteriaList = new MenuShortcutJList<String>(criteriaNames, false) {

		private static final long serialVersionUID = 3031125186920370793L;

		@Override
		public Dimension getPreferredSize() {
			Dimension dim = super.getPreferredSize();
			dim.width = Math.max(150, dim.width);
			return dim;
		}
	};
	criteriaList.setCellRenderer(new CriterionListCellRenderer());
	criteriaList.setOpaque(false);

	criteriaList.setBorder(BorderFactory.createTitledBorder("Criterion"));
	criteriaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	criteriaList.addListSelectionListener(new ListSelectionListener() {

		@Override
		public void valueChanged(ListSelectionEvent e) {
			String selected = criteriaList.getSelectedValue();
			cardLayout.show(mainPanel, selected);
		}
	});

	JScrollPane listScrollPane = new ExtendedJScrollPane(criteriaList);
	listScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 2));
	add(listScrollPane, BorderLayout.WEST);

	// select first criterion
	criteriaList.setSelectedIndices(new int[] { 0 });
}
 
源代码15 项目: hortonmachine   文件: JFontChooser.java
private void init(Font font) {
    setLayout(new GridBagLayout());

    Insets ins = new Insets(2, 2, 2, 2);

    fontList = new JList(FONTS);
    fontList.setVisibleRowCount(10);
    fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    add(new JScrollPane(fontList), new GridBagConstraints(0, 0, 1, 1, 2, 2,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            ins, 0, 0));

    sizeList = new JList(SIZES);
    ((JLabel)sizeList.getCellRenderer()).setHorizontalAlignment(JLabel.RIGHT);
    sizeList.setVisibleRowCount(10);
    sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    add(new JScrollPane(sizeList), new GridBagConstraints(1, 0, 1, 1, 1, 2,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            ins, 0, 0));

    boldCheckBox = new JCheckBox("Bold");
    add(boldCheckBox, new GridBagConstraints(0, 1, 2, 1, 1, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            ins, 0, 0));

    italicCheckBox = new JCheckBox("Italic");
    add(italicCheckBox, new GridBagConstraints(0, 2, 2, 1, 1, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            ins, 0, 0));

    previewLabel = new JLabel("");
    previewLabel.setHorizontalAlignment(JLabel.CENTER);
    previewLabel.setVerticalAlignment(JLabel.CENTER);
    add(new JScrollPane(previewLabel), new GridBagConstraints(0, 3, 2, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            ins, 0, 0));

    setFont(font == null ? previewLabel.getFont() : font);

    fontList.addListSelectionListener(selectionUpdater);
    sizeList.addListSelectionListener(selectionUpdater);
    boldCheckBox.addChangeListener(selectionUpdater);
    italicCheckBox.addChangeListener(selectionUpdater);
}
 
源代码16 项目: pentaho-reporting   文件: JdbcDataSourceDialog.java
/**
 * Creates the panel which holds the main content of the dialog
 */
private void initDialog( final DesignTimeContext designTimeContext ) {
  this.designTimeContext = designTimeContext;

  setTitle( Messages.getString( "JdbcDataSourceDialog.Title" ) );
  setModal( true );

  globalTemplateAction = new GlobalTemplateAction();
  queryTemplateAction = new QueryTemplateAction();

  dialogModel = new NamedDataSourceDialogModel();
  dialogModel.addPropertyChangeListener( new ConfirmValidationHandler() );

  connectionComponent = new JdbcConnectionPanel( dialogModel, designTimeContext );
  maxPreviewRowsSpinner = new JSpinner( new SpinnerNumberModel( 10000, 1, Integer.MAX_VALUE, 1 ) );

  final QueryNameTextFieldDocumentListener updateHandler = new QueryNameTextFieldDocumentListener();
  dialogModel.getQueries().addListDataListener( updateHandler );

  queryNameList = new JList( dialogModel.getQueries() );
  queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  queryNameList.setVisibleRowCount( 5 );
  queryNameList.addListSelectionListener( new QuerySelectedHandler() );

  queryNameTextField = new JTextField();
  queryNameTextField.setColumns( 35 );
  queryNameTextField.setEnabled( dialogModel.isQuerySelected() );
  queryNameTextField.getDocument().addDocumentListener( updateHandler );

  queryTextArea = new RSyntaxTextArea();
  queryTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_SQL );
  queryTextArea.setEnabled( dialogModel.isQuerySelected() );
  queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() );

  globalScriptTextArea = new RSyntaxTextArea();
  globalScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );

  globalLanguageField = new SmartComboBox<ScriptEngineFactory>( new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  globalLanguageField.setRenderer( new QueryLanguageListCellRenderer() );
  globalLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  queryScriptTextArea = new RSyntaxTextArea();
  queryScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );
  queryScriptTextArea.getDocument().addDocumentListener( new QueryScriptDocumentListener() );

  queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

  queryLanguageField = new SmartComboBox<ScriptEngineFactory>( new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  queryLanguageField.setRenderer( queryLanguageListCellRenderer );
  queryLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  super.init();
}
 
源代码17 项目: pentaho-reporting   文件: QueryEditorPanel.java
@SuppressWarnings( "unchecked" )
private void init() {
  globalTemplateAction = new GlobalTemplateAction( this, dialogModel );
  queryTemplateAction = new QueryTemplateAction( this, dialogModel );

  queryNameList = new JList( dialogModel.getQueries() );
  queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  queryNameList.setVisibleRowCount( 5 );
  queryNameList.setCellRenderer( new QueryListCellRenderer() );
  queryNameList.addListSelectionListener( new QuerySelectedHandler( dialogModel, queryNameList ) );

  queryNameTextField = new JTextField();
  queryNameTextField.setColumns( 35 );
  queryNameTextField.setEnabled( dialogModel.isQuerySelected() );
  queryNameTextField.getDocument().addDocumentListener( new QueryNameUpdateHandler() );

  globalScriptTextArea = new RSyntaxTextArea();
  globalScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );
  globalScriptTextArea.getDocument().addDocumentListener( new GlobalScriptUpdateHandler() );

  globalLanguageField =
      new SmartComboBox( new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );
  globalLanguageField.setRenderer( new QueryLanguageListCellRenderer() );
  globalLanguageField.addActionListener( new UpdateGlobalScriptLanguageHandler() );

  queryScriptTextArea = new RSyntaxTextArea();
  queryScriptTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_NONE );
  queryScriptTextArea.getDocument().addDocumentListener( new QueryScriptUpdateHandler() );

  queryLanguageField =
      new SmartComboBox( new DefaultComboBoxModel( DataFactoryEditorSupport.getScriptEngineLanguages() ) );

  queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();
  queryLanguageField.setRenderer( queryLanguageListCellRenderer );
  queryLanguageField.addActionListener( new UpdateQueryScriptLanguageHandler() );

  dialogModel.addQueryDialogModelListener( new DialogModelChangesDispatcher() );

  initialize();
  createComponents();
}
 
源代码18 项目: tn5250j   文件: KeyConfigure.java
private JPanel createFunctionsPanel() {

      functions = new JList(lm);

      // add list selection listener to our functions list so that we
      //   can display the mapped key(s) to the function when a new
      //   function is selected.
      functions.addListSelectionListener(new ListSelectionListener() {
         public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {
               setKeyDescription(functions.getSelectedIndex());
            }
         }
      });

      loadList(LangTool.getString("key.labelKeys"));

      functions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      JScrollPane functionsScroll = new JScrollPane(functions);

      JPanel fp = new JPanel();

      JComboBox whichKeys = new JComboBox();
      whichKeys.addItem(LangTool.getString("key.labelKeys"));
      whichKeys.addItem(LangTool.getString("key.labelMacros"));
      whichKeys.addItem(LangTool.getString("key.labelSpecial"));

      whichKeys.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                JComboBox cb = (JComboBox)e.getSource();
                loadList((String)cb.getSelectedItem());
            }
        });

      fp.setBorder(BorderFactory.createTitledBorder(
                                    LangTool.getString("key.labelDesc")));
      fp.setLayout(new BoxLayout(fp,BoxLayout.Y_AXIS));

      fp.add(whichKeys);
      fp.add(functionsScroll);

      return fp;

   }
 
源代码19 项目: 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");
}
 
源代码20 项目: Astrosoft   文件: YogaCombinationsView.java
public YogaCombinationsView(String title, YogaResults yogaResults, PlanetaryInfo planetaryInfo) {
	
	super(viewSize, viewLoc);
	this.planetaryInfo = planetaryInfo;
	this.yogaResults = yogaResults;
	
	JPanel yogaPanel = new JPanel();
	
	yogaList = new JList(yogaResults.getYogas().toArray());
	yogaList.setFont(UIUtil.getFont("Tahoma", Font.PLAIN, 11));
	
	yogaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	yogaList.setSelectedIndex(0);
	
	yogaPanel.add(yogaList);
	
	yogaPanel.setPreferredSize(yogaSize);	
	
	
	final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, yogaPanel, createResultPane());
	
	yogaPanel.setBorder(BorderFactory.createEtchedBorder());
	splitPane.setBorder(BorderFactory.createEmptyBorder());
	
	yogaList.addListSelectionListener(new ListSelectionListener(){

		public void valueChanged(ListSelectionEvent e) {
			//splitPane.remove(chartPanel);
			yogaChanged((YogaResults.Result)yogaList.getSelectedValue());
			//splitPane.add(chartPanel);
		}
	});
	
	add(splitPane,BorderLayout.CENTER);
}