use of java.awt.event.ActionListener in project gephi-plugins-bootcamp by gephi.
the class NodesZOrderingUI method getPanel.
@Override
public JPanel getPanel() {
//Create a panel and add a label
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel labelColumn = new JLabel("Column:");
panel.add(labelColumn);
final JComboBox columnCombo = new JComboBox();
//Create the combob box model with all numerical attribute columns
ComboBoxModel comboBoxModel = createComboBoxModel();
columnCombo.setModel(comboBoxModel);
//Add the combo to the panel
panel.add(columnCombo);
//When combo selection is updated, update the preview property
columnCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
JComboBox comboBox = (JComboBox) e.getSource();
if (!comboBox.getSelectedItem().equals(NO_SELECTION)) {
previewModel.getProperties().putValue(NodesZOrdering.SORT_COLUMN, comboBox.getSelectedItem());
} else {
previewModel.getProperties().putValue(NodesZOrdering.SORT_COLUMN, null);
}
}
});
//Add a button to refresh the column
JButton refreshButton = new JButton("Refresh");
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ComboBoxModel comboBoxModel = createComboBoxModel();
columnCombo.setModel(comboBoxModel);
}
});
panel.add(refreshButton);
return panel;
}
use of java.awt.event.ActionListener in project binnavi by google.
the class ArrayTypePanel method createControls.
private void createControls() {
setLayout(new BorderLayout());
final JPanel contentPanel = new JPanel();
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
add(contentPanel, BorderLayout.CENTER);
final GridBagLayout gbl_m_contentPanel = new GridBagLayout();
gbl_m_contentPanel.columnWidths = new int[] { 0, 0, 0 };
gbl_m_contentPanel.rowHeights = new int[] { 0, 0, 0, 0, 0 };
gbl_m_contentPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gbl_m_contentPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
contentPanel.setLayout(gbl_m_contentPanel);
final JLabel lblSize = new JLabel("Number of elements:");
final GridBagConstraints gbc_lblSize = new GridBagConstraints();
gbc_lblSize.anchor = GridBagConstraints.WEST;
gbc_lblSize.insets = new Insets(0, 0, 5, 5);
gbc_lblSize.gridx = 0;
gbc_lblSize.gridy = 1;
contentPanel.add(lblSize, gbc_lblSize);
numberElements = new JSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1));
numberElements.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
updatePreview();
}
});
final GridBagConstraints gbc_numberElements = new GridBagConstraints();
gbc_numberElements.anchor = GridBagConstraints.WEST;
gbc_numberElements.insets = new Insets(0, 0, 5, 0);
gbc_numberElements.gridx = 1;
gbc_numberElements.gridy = 1;
contentPanel.add(numberElements, gbc_numberElements);
final JLabel lblFillWith = new JLabel("Element type:");
final GridBagConstraints gbc_lblFillWith = new GridBagConstraints();
gbc_lblFillWith.anchor = GridBagConstraints.WEST;
gbc_lblFillWith.insets = new Insets(0, 0, 5, 5);
gbc_lblFillWith.gridx = 0;
gbc_lblFillWith.gridy = 0;
contentPanel.add(lblFillWith, gbc_lblFillWith);
baseTypes = new TypeComboBox(new TypeListModel(typeManager.getTypes(), new TypeListModel.PrototypesFilter()));
baseTypes.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
updatePreview();
}
});
final GridBagConstraints gbc_baseTypes = new GridBagConstraints();
gbc_baseTypes.insets = new Insets(0, 0, 5, 0);
gbc_baseTypes.fill = GridBagConstraints.HORIZONTAL;
gbc_baseTypes.gridx = 1;
gbc_baseTypes.gridy = 0;
contentPanel.add(baseTypes, gbc_baseTypes);
final JLabel lblPreview = new JLabel("Preview:");
final GridBagConstraints gbc_lblPreview = new GridBagConstraints();
gbc_lblPreview.anchor = GridBagConstraints.WEST;
gbc_lblPreview.insets = new Insets(0, 0, 5, 5);
gbc_lblPreview.gridx = 0;
gbc_lblPreview.gridy = 2;
contentPanel.add(lblPreview, gbc_lblPreview);
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(null);
final GridBagConstraints gbc_scrollPane = new GridBagConstraints();
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
gbc_scrollPane.fill = GridBagConstraints.BOTH;
gbc_scrollPane.gridx = 1;
gbc_scrollPane.gridy = 2;
contentPanel.add(scrollPane, gbc_scrollPane);
preview = new JTextArea();
preview.setEditable(false);
scrollPane.setViewportView(preview);
}
use of java.awt.event.ActionListener in project binnavi by google.
the class MemberDialog method createControls.
private void createControls(final TypeManager typeManager) {
setBounds(100, 100, 450, 215);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
final GridBagLayout gbl_contentPanel = new GridBagLayout();
gbl_contentPanel.columnWidths = new int[] { 0, 0, 0 };
gbl_contentPanel.rowHeights = new int[] { 0, 0, 0, 0 };
gbl_contentPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
contentPanel.setLayout(gbl_contentPanel);
{
final JLabel lblMemberName = new JLabel("Member name:");
final GridBagConstraints gbc_lblMemberName = new GridBagConstraints();
gbc_lblMemberName.insets = new Insets(0, 0, 5, 5);
gbc_lblMemberName.anchor = GridBagConstraints.EAST;
gbc_lblMemberName.gridx = 0;
gbc_lblMemberName.gridy = 0;
contentPanel.add(lblMemberName, gbc_lblMemberName);
}
{
memberName = new JTextField();
final GridBagConstraints gbc_memberName = new GridBagConstraints();
gbc_memberName.insets = new Insets(0, 0, 5, 0);
gbc_memberName.fill = GridBagConstraints.HORIZONTAL;
gbc_memberName.gridx = 1;
gbc_memberName.gridy = 0;
contentPanel.add(memberName, gbc_memberName);
memberName.setColumns(10);
}
{
final JLabel lblMemberType = new JLabel("Member type:");
final GridBagConstraints gbc_lblMemberType = new GridBagConstraints();
gbc_lblMemberType.anchor = GridBagConstraints.EAST;
gbc_lblMemberType.insets = new Insets(0, 0, 5, 5);
gbc_lblMemberType.gridx = 0;
gbc_lblMemberType.gridy = 1;
contentPanel.add(lblMemberType, gbc_lblMemberType);
}
{
memberType = new TypeComboBox(new TypeListModel(typeManager.getTypes(), new TypeListModel.PrototypesFilter()));
final GridBagConstraints gbc_memberType = new GridBagConstraints();
gbc_memberType.insets = new Insets(0, 0, 5, 0);
gbc_memberType.fill = GridBagConstraints.HORIZONTAL;
gbc_memberType.gridx = 1;
gbc_memberType.gridy = 1;
contentPanel.add(memberType, gbc_memberType);
}
{
final JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
final JButton okButton = new JButton("OK");
okButton.addActionListener(new OkActionListener());
okButton.setActionCommand("OK");
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
final JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
dispose();
}
});
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}
use of java.awt.event.ActionListener in project binnavi by google.
the class TypeDialog method createButtons.
private void createButtons() {
final JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
final JButton okButton = new JButton("Ok");
okButton.addActionListener(new OkActionListener());
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
final JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
dispose();
}
});
buttonPane.add(cancelButton);
}
use of java.awt.event.ActionListener in project android-classyshark by google.
the class RecentArchivesButton method buildPopup.
private void buildPopup() {
popup.removeAll();
JMenuItem item;
for (String archiveName : RecentArchivesConfig.INSTANCE.getRecentArchiveNames()) {
item = new JMenuItem(archiveName);
theme.applyTo(item);
popup.add(item);
item.setHorizontalTextPosition(JMenuItem.RIGHT);
item.addActionListener(new RecentFilesListener(archiveName));
}
popup.addSeparator();
final JMenuItem clearRecentArchivesItem = new JMenuItem("Clear");
theme.applyTo(clearRecentArchivesItem);
popup.add(clearRecentArchivesItem);
clearRecentArchivesItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
RecentArchivesConfig.INSTANCE.clear();
popup.removeAll();
popup.updateUI();
popup.add(clearRecentArchivesItem);
}
});
}
Aggregations