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

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

源代码1 项目: netbeans   文件: ExitDialog.java
/** Constructs rest of dialog.
*/
private void draw () {
    list = new JList(listModel);
    list.addListSelectionListener (new javax.swing.event.ListSelectionListener () {
                                       public void valueChanged (javax.swing.event.ListSelectionEvent evt) {
                                           updateSaveButton ();
                                       }
                                   }
                                  );
    // bugfix 37941, select first item in list
    if (!listModel.isEmpty ()) {
        list.setSelectedIndex (0);
    } else {                              
        updateSaveButton ();
    }
    JScrollPane scroll = new JScrollPane (list);
 setBorder(BorderFactory.createEmptyBorder( 12, 12, 11, 12));
    add(scroll, java.awt.BorderLayout.CENTER);
    list.setCellRenderer(new ExitDlgListCellRenderer());
    list.getAccessibleContext().setAccessibleName((NbBundle.getBundle(ExitDialog.class)).getString("ACSN_ListOfChangedFiles"));
    list.getAccessibleContext().setAccessibleDescription((NbBundle.getBundle(ExitDialog.class)).getString("ACSD_ListOfChangedFiles"));
    this.getAccessibleContext().setAccessibleDescription((NbBundle.getBundle(ExitDialog.class)).getString("ACSD_ExitDialog"));
}
 
源代码2 项目: jdal   文件: ListPane.java
public void init() {
	setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
	tableIcon = FormUtils.getIcon(tableIcon, DEFAULT_TABLE_ICON);
	for (PanelHolder p : panels)
		p.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
		
	list = new JList(new ListListModel(panels));
	list.setBorder(BorderFactory.createEmptyBorder(5, 5	, 5, 5));
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.setVisibleRowCount(-1);
	list.addListSelectionListener(this);
	list.setCellRenderer(renderer);
	list.setSelectedIndex(0);
	
	if (cellHeight != 0)
		list.setFixedCellHeight(cellHeight);
	
	JScrollPane scroll = new JScrollPane(list);
	split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scroll, editorPanel);
	split.setResizeWeight(0);
	split.setDividerLocation(150);
	add(split);
}
 
源代码3 项目: jdal   文件: TableEditorFrame.java
public void init() {
	
	tableIcon = FormUtils.getIcon(tableIcon, DEFAULT_TABLE_ICON);
	for (TableEditor<?> editor : editors)
		editor.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
		
	list = new JList(editors);
	list.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.setVisibleRowCount(-1);
	JScrollPane scroll = new JScrollPane(list);
	split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scroll, editorPanel);
	getContentPane().add(split);
	list.addListSelectionListener(this);
	list.setCellRenderer(new ListCellRenderer());
	list.setSelectedIndex(0);
	setSize(800, 600);
}
 
源代码4 项目: jsyn   文件: InstrumentBrowser.java
public InstrumentBrowser(InstrumentLibrary library) {
    this.library = library;
    JPanel horizontalPanel = new JPanel();
    horizontalPanel.setLayout(new GridLayout(1, 2));

    final JList<VoiceDescription> instrumentList = new JList<VoiceDescription>(library.getVoiceDescriptions());
    setupList(instrumentList);
    instrumentList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                int n = instrumentList.getSelectedIndex();
                if (n >= 0) {
                    showPresetList(n);
                }
            }
        }
    });

    JScrollPane listScroller1 = new JScrollPane(instrumentList);
    listScroller1.setPreferredSize(new Dimension(250, 120));
    add(listScroller1);

    instrumentList.setSelectedIndex(0);
}
 
源代码5 项目: jsyn   文件: InstrumentBrowser.java
public InstrumentBrowser(InstrumentLibrary library) {
    this.library = library;
    JPanel horizontalPanel = new JPanel();
    horizontalPanel.setLayout(new GridLayout(1, 2));

    final JList<VoiceDescription> instrumentList = new JList<VoiceDescription>(library.getVoiceDescriptions());
    setupList(instrumentList);
    instrumentList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                int n = instrumentList.getSelectedIndex();
                if (n >= 0) {
                    showPresetList(n);
                }
            }
        }
    });

    JScrollPane listScroller1 = new JScrollPane(instrumentList);
    listScroller1.setPreferredSize(new Dimension(250, 120));
    add(listScroller1);

    instrumentList.setSelectedIndex(0);
}
 
@Override
protected JComponent createColorPicker() {
    List<ColorItem> colors = getColorItems();
    JList<ColorItem> view = new JList<>(new AbstractListModel<ColorItem>() {
        @Override
        public int getSize() {
            return colors.size();
        }

        @Override
        public ColorItem getElementAt(int index) {
            return colors.get(index);
        }
    });
    view.setCellRenderer(new ColorItemListCellRenderer());
    view.addListSelectionListener(e -> {
        setSelectedColor(view.getSelectedValue().color);
    });
    return new JScrollPane(view);
}
 
源代码7 项目: 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);
}
 
源代码8 项目: 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));
}
 
源代码9 项目: JAVA-MVC-Swing-Monopoly   文件: FrameConfig.java
/**
 * 
 * ��ͼѡ�����
 * 
 */
private JPanel createMapSelectPanel() {
	JPanel jp = new JPanel();
	jp.setLayout(new GridLayout());
	jp.setBackground(new Color(235,236,237));
	JPanel lPane = new JPanel(new BorderLayout());
	String[] maps = { "\"LOVE��ͼ\"", "\"���ݵ�ͼ\"", "\"���˵�ͼ\"" };
	final ImageIcon[] maps1 = {
			new ImageIcon("images/other/1.png"),
			new ImageIcon("images/other/2.png"),
			new ImageIcon("images/other/3.png") };
	final JList jlst = new JList(maps);
	jlst.setSelectedIndex(0);
	final JLabel mapV = new JLabel(maps1[0]);
	final JButton ok = new JButton("ȷ��");
	ok.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent arg0) {
			GameRunning.MAP = jlst.getSelectedIndex() + 1;
			ok.setText("��ѡ");
		}
	});
	jlst.addListSelectionListener(new ListSelectionListener() {
		@Override
		public void valueChanged(ListSelectionEvent e) {
			mapV.setIcon(maps1[jlst.getSelectedIndex()]);
			ok.setText("ȷ��");
		}
	});
	lPane.add(jlst);
	lPane.add(ok, BorderLayout.SOUTH);
	JPanel rPane = new JPanel();
	rPane.add(mapV);
	JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
			false, lPane, rPane);
	jp.add(jSplitPane);
	return jp;
}
 
源代码10 项目: netbeans   文件: GitUtils.java
public QuickSearchCallback (List<T> items, JList component, DefaultListModel model, SearchCallback<T> callback) {
    this.items = new ArrayList<T>(items);
    results = new ArrayList<T>(items);
    this.component = component;
    this.model = model;
    this.callback = callback;
    this.currentPosition = component.getSelectedIndex();
    component.addListSelectionListener(this);
}
 
源代码11 项目: 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;
}
 
源代码12 项目: tda   文件: FilterDialog.java
public FilterPanel(Frame owner) {
    this.owner = owner;
    setLayout(new BorderLayout());

    buttonFlow = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    add(Box.createVerticalStrut(5), BorderLayout.NORTH);
    add(Box.createHorizontalStrut(5), BorderLayout.WEST);
    JPanel innerButtonPanel = new JPanel(new GridLayout(3, 1, 5, 5));

    innerButtonPanel.add(addButton = new JButton("Add"));
    innerButtonPanel.add(removeButton = new JButton("Remove"));
    innerButtonPanel.add(editButton = new JButton("Edit"));
    removeButton.setEnabled(false);
    editButton.setEnabled(false);

    addButton.addActionListener(this);
    removeButton.addActionListener(this);
    editButton.addActionListener(this);

    buttonFlow.add(innerButtonPanel);

    add(buttonFlow, BorderLayout.EAST);
    setPreferredSize(new Dimension(380, 290));

    //createList();
    filterList = new JList(PrefManager.get().getFilters());
    scrollPane = new JScrollPane(filterList);
    filterList.addListSelectionListener(this);

    add(scrollPane, BorderLayout.CENTER);

}
 
源代码13 项目: netbeans   文件: ClassMethodSelector.java
ProjectSelector() {
    projectListModel = new DefaultListModel();
    final FilteredListModel<Lookup.Provider> filteredProjects = new FilteredListModel<Lookup.Provider>(projectListModel) {
        protected boolean matchesFilter(Lookup.Provider proj, GenericFilter filter) {
            return filter.passes(ProjectUtilities.getDisplayName(proj));
        }
    };
    final HintRenderer hintRenderer = new HintRenderer();
    projectList = new JList(filteredProjects) {
        public Dimension getPreferredScrollableViewportSize() {
            Dimension dim = super.getPreferredScrollableViewportSize();
            dim.width = LIST_WIDTH;
            return dim;
        }
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            
            if (getModel().getSize() == 0) {
                hintRenderer.setup(true, getSize());
                hintRenderer.paint(g);
            }
        }
    };
    projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    filteredProjects.setSelectionModel(projectList.getSelectionModel());
    projectList.setCellRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            DefaultListCellRenderer c = (DefaultListCellRenderer)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            Lookup.Provider val = (Lookup.Provider)value;
            c.setText(ProjectUtilities.getDisplayName(val));
            c.setIcon(ProjectUtilities.getIcon(val));
            return c;
        }
    });
    projectList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) projectSelected();
        }
    });
    
    JLabel projectsLabel = new JLabel(Bundle.ClassMethodSelector_capProjects(), JLabel.LEADING);
    projectsLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    JToolBar projectsTools = new FilteringToolbar(Bundle.ClassMethodSelector_lblFilterItems()) {
        protected void filterChanged() {
            filteredProjects.setFilter(getFilter());
        }
    };
    
    setOpaque(false);
    setLayout(new BorderLayout());
    add(projectsLabel, BorderLayout.NORTH);
    add(new JScrollPane(projectList), BorderLayout.CENTER);
    add(projectsTools, BorderLayout.SOUTH);
}
 
源代码14 项目: bigtable-sql   文件: ColumnListDialog.java
/**
 * Creates the UI for this dialog.
 */
private void init(String[] columnNames) {
    super.setModal(true);        
    if (_mode == DROP_COLUMN_MODE) {
        setTitle(i18n.DROP_TITLE);
    } 
    if (_mode == MODIFY_COLUMN_MODE) {
        setTitle(i18n.MODIFY_TITLE);
    }
    if (_mode == ADD_PRIMARY_KEY_MODE) {
        setTitle(i18n.PRIMARY_KEY_TITLE);
    }
    if (_mode == DROP_PRIMARY_KEY_MODE) {
        setTitle(i18n.DROP_PRIMARY_KEY_TITLE);
    }
    setSize(425, 250);
    EmptyBorder border = new EmptyBorder(new Insets(5,5,5,5));
    Dimension mediumField = new Dimension(126, 20);
    
    JPanel pane = new JPanel();
    pane.setLayout(new GridBagLayout());
    pane.setBorder(new EmptyBorder(10,0,0,30));

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = -1;

    // Table name
    tableNameLabel = getBorderedLabel(i18n.TABLE_NAME_LABEL, border);
    pane.add(tableNameLabel, getLabelConstraints(c));
    
    tableNameTextField = new JTextField();
    tableNameTextField.setPreferredSize(mediumField);
    tableNameTextField.setEditable(false);
    pane.add(tableNameTextField, getFieldConstraints(c));
            
    // Primary Key name
    if (_mode == ADD_PRIMARY_KEY_MODE
            || _mode == DROP_PRIMARY_KEY_MODE) {
        primaryKeyNameLabel = new JLabel(i18n.PRIMARY_KEY_NAME_LABEL);
        pane.add(primaryKeyNameLabel, getLabelConstraints(c));
        
        primaryKeyNameTF = new JTextField();
        primaryKeyNameTF.setPreferredSize(mediumField);
        if (_mode == ADD_PRIMARY_KEY_MODE) {
            primaryKeyNameTF.setEditable(true);
        } else {
            primaryKeyNameTF.setEditable(false);
        }
        pane.add(primaryKeyNameTF, getFieldConstraints(c));
    }
    
    // Column list        
    columnListLabel = getBorderedLabel(i18n.COLUMN_NAME_LABEL, border);
    columnListLabel.setVerticalAlignment(JLabel.NORTH);
    pane.add(columnListLabel, getLabelConstraints(c));
    
    columnList = new JList(columnNames);
    columnList.addListSelectionListener(new ColumnListSelectionListener());

    JScrollPane sp = new JScrollPane(columnList);
    c = getFieldConstraints(c);
    c.weightx = 1;
    c.weighty = 1;        
    c.fill=GridBagConstraints.BOTH;
    pane.add(sp, c);
            
    Container contentPane = super.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(pane, BorderLayout.CENTER);
    
    contentPane.add(getButtonPanel(), BorderLayout.SOUTH);
}
 
源代码15 项目: pentaho-reporting   文件: PmdDataSourceEditor.java
private void init( final DesignTimeContext context ) {
  if ( context == null ) {
    throw new NullPointerException();
  }

  this.context = context;
  setModal( true );
  setTitle( Messages.getString( "PmdDataSourceEditor.Title" ) );

  maxPreviewRowsSpinner = new JSpinner( new SpinnerNumberModel( 10000, 1, Integer.MAX_VALUE, 1 ) );
  previewAction = new PreviewAction();
  globalTemplateAction = new GlobalTemplateAction();
  queryTemplateAction = new QueryTemplateAction();

  filenameField = new JTextField( null, 0 );
  filenameField.setColumns( 30 );
  filenameField.getDocument().addDocumentListener( new FilenameDocumentListener() );

  queryNameList = new JList();
  queryNameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
  queryNameList.setVisibleRowCount( 5 );
  queryNameList.addListSelectionListener( new QueryNameListSelectionListener() );
  queryNameList.setCellRenderer( new QueryNameListCellRenderer() );

  queryAddButton = new BorderlessButton( new AddQueryAction() );
  queryRemoveButton = new BorderlessButton( new RemoveQueryAction() );

  queryNameTextField = new JTextField( null, 0 );
  queryNameTextField.setColumns( 35 );
  queryNameTextField.getDocument().addDocumentListener( new QueryNameTextFieldDocumentListener() );

  domainIdTextField = new JTextField( null, 0 );
  domainIdTextField.setColumns( 35 );
  domainIdTextField.getDocument().addDocumentListener( new DomainTextFieldDocumentListener() );

  queryTextArea = new RSyntaxTextArea();
  queryTextArea.setSyntaxEditingStyle( SyntaxConstants.SYNTAX_STYLE_XML );
  queryTextArea.setWrapStyleWord( true );
  queryTextArea.setLineWrap( true );
  queryTextArea.setRows( 5 );
  queryTextArea.getDocument().addDocumentListener( new QueryDocumentListener() );

  queryDesignerButton = new JButton( new QueryDesignerAction() );
  queryDesignerButton.setEnabled( false );
  queryDesignerButton.setBorder( new EmptyBorder( 0, 0, 0, 0 ) );

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

  globalLanguageField = new SmartComboBox( new DefaultComboBoxModel( 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( new DefaultComboBoxModel( getScriptEngineLanguages() ) );
  queryLanguageField.setRenderer( queryLanguageListCellRenderer );
  queryLanguageField.addActionListener( new UpdateScriptLanguageHandler() );

  super.init();
}
 
源代码16 项目: 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();
}
 
源代码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 项目: pcgen   文件: SourceSelectionDialog.java
@Override
public void actionPerformed(ActionEvent e)
{
	String command = e.getActionCommand();
       switch (command)
       {
           case SAVE_COMMAND:
               final JList sourcesList = new JList<>();
               final JTextField nameField = new JTextField();
               ListFacade<SourceSelectionFacade> sources = new SortedListFacade<>(Comparators.toStringIgnoreCaseCollator(),
                       FacadeFactory.getCustomSourceSelections());
               sourcesList.setModel(new FacadeListModel<>(sources));
               sourcesList.addListSelectionListener(lse -> nameField.setText(sourcesList.getSelectedValue().toString()));
               JPanel panel = new JPanel(new BorderLayout());
               panel.add(new JScrollPane(sourcesList), BorderLayout.CENTER);
               panel.add(nameField, BorderLayout.SOUTH);
               int ret = JOptionPane.showOptionDialog(this, panel, "Save the source selection as...",
                       JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
               if (ret == JOptionPane.OK_OPTION)
               {
                   String name = nameField.getText();
                   List<Campaign> selectedCampaigns = advancedPanel.getSelectedCampaigns();
                   GameMode selectedGameMode = advancedPanel.getSelectedGameMode();

                   SourceSelectionFacade selection = null;
                   for (SourceSelectionFacade sourceSelectionFacade : sources)
                   {
                       if (sourceSelectionFacade.toString().equals(name))
                       {
                           selection = sourceSelectionFacade;
                           break;

                       }
                   }
                   if (selection == null)
                   {
                       selection = FacadeFactory.createCustomSourceSelection(name);
                   }
                   selection.setCampaigns(selectedCampaigns);
                   selection.setGameMode(selectedGameMode);
                   basicPanel.setSourceSelection(selection);
               }
               break;
           case DELETE_COMMAND:
               FacadeFactory.deleteCustomSourceSelection(basicPanel.getSourceSelection());
               break;
           case LOAD_COMMAND:
               fireSourceLoad();
               break;
           case INSTALLDATA_COMMAND:
               // Swap to the install data dialog.
               setVisible(false);
               DataInstaller di = new DataInstaller();
               di.setVisible(true);
               break;
           default: //must be the cancel command
               setVisible(false);
               break;
       }
}
 
源代码19 项目: cropplanning   文件: ListAdaptor.java
/**
 * Creates a new JListAdaptor for the given list and text component.
 * @param list the list that contains the items that are used for automatic
 * completion
 * @param textComponent the text component that will be used automatic
 * completion
 * @param stringConverter the converter used to transform items to strings
 */
public ListAdaptor(JList list, JTextComponent textComponent, ObjectToStringConverter stringConverter) {
    this.list = list;
    this.textComponent = textComponent;
    this.stringConverter = stringConverter;
    // when a new item is selected set and mark the text
    list.addListSelectionListener(this);
}
 
源代码20 项目: Spark   文件: ColorPreferencePanel.java
private void createUI() {

	_colorsettings = ColorSettingManager.getColorSettings();
	Set<String> sets  = _colorsettings.getKeys();
	
	
	Vector<String> keys= new Vector<>();
	for(String s : sets)
	{
	    keys.add(s);
	}	
	sortList(keys);
	
	JPanel rightpanel = new JPanel(new GridBagLayout());
	
	_colorpick = new ColorPick(true);
	
	final JButton savebutton = new JButton(Res.getString("apply"));
	
	final JButton restoreDefaults = new JButton(Res.getString("use.default"));
	
	_errorlabel = new JLabel(" ");
	_errorlabel.setForeground(Color.red);
	
	
	rightpanel.add(_colorpick, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));

	
	rightpanel.add(savebutton, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
	rightpanel.add(restoreDefaults, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));

	rightpanel.add(_errorlabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));

	_colorliste = new JList(keys);
		JScrollPane _jScrollPane = new JScrollPane( _colorliste );
	
	setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
	add( _jScrollPane );
	add(rightpanel);
	
	
	_colorliste.addListSelectionListener( e -> {

    String v = (String) _colorliste.getSelectedValue();

    Color c = _colorsettings.getColorFromProperty(v);

    _colorpick.setColor(c);
    _errorlabel.setText("");
    } );
	
	savebutton.addActionListener( e -> savebuttonaction(e) );
	
	restoreDefaults.addActionListener( e -> {
    ColorSettingManager.restoreDefault();
    _colorsettings = ColorSettingManager.getColorSettings();
    } );

    }