use of java.awt.event.MouseEvent in project pcgen by PCGen.
the class CampaignPanel method setupDisplay.
/**
* @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
*/
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
panel.setLayout(new GridBagLayout());
JLabel introLabel = new JLabel("Please select the Campaign(s) to Convert:");
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(25, 25, 5, 25);
panel.add(introLabel, gbc);
final CampaignTableModel model = new CampaignTableModel(gameModeCampaigns, folderName);
final JTable table = new JTable(model) {
//Implement table cell tool tips.
@Override
public String getToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint();
int rowIndex = rowAtPoint(p);
int colIndex = columnAtPoint(p);
String tip = String.valueOf(getValueAt(rowIndex, colIndex));
return tip;
}
};
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent event) {
pc.removeListFor(ListKey.CAMPAIGN);
int[] selRows = table.getSelectedRows();
if (selRows.length == 0) {
saveSourceSelection(pc);
fireProgressEvent(ProgressEvent.NOT_ALLOWED);
} else {
for (int row : selRows) {
Campaign selCampaign = (Campaign) model.getValueAt(row, 0);
pc.addToListFor(ListKey.CAMPAIGN, selCampaign);
}
saveSourceSelection(pc);
fireProgressEvent(ProgressEvent.ALLOWED);
}
}
});
JScrollPane listScroller = new JScrollPane(table);
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0);
gbc.fill = GridBagConstraints.BOTH;
panel.add(listScroller, gbc);
initSourceSelection(model, table);
}
use of java.awt.event.MouseEvent in project intellij-community by JetBrains.
the class MavenArtifactSearchPanel method initComponents.
private void initComponents(String initialText) {
myResultList = new Tree();
myResultList.setExpandableItemsEnabled(false);
myResultList.getEmptyText().setText("Loading...");
myResultList.setRootVisible(false);
myResultList.setShowsRootHandles(true);
myResultList.setModel(null);
MyArtifactCellRenderer renderer = myClassMode ? new MyClassCellRenderer(myResultList) : new MyArtifactCellRenderer(myResultList);
myResultList.setCellRenderer(renderer);
myResultList.setRowHeight(renderer.getPreferredSize().height);
mySearchField = new JTextField(initialText);
mySearchField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
int d;
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
d = 1;
} else if (e.getKeyCode() == KeyEvent.VK_UP) {
d = -1;
} else {
return;
}
int row = myResultList.getSelectionModel().getLeadSelectionRow();
row += d;
if (row >= 0 && row < myResultList.getRowCount()) {
myResultList.setSelectionRow(row);
}
}
});
setLayout(new BorderLayout());
add(mySearchField, BorderLayout.NORTH);
JScrollPane pane = ScrollPaneFactory.createScrollPane(myResultList);
pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
// Don't remove this line.
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
// Without VERTICAL_SCROLLBAR_ALWAYS policy our custom layout
// works incorrectly, see https://youtrack.jetbrains.com/issue/IDEA-72986
add(pane, BorderLayout.CENTER);
mySearchField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
scheduleSearch();
}
});
myResultList.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
if (!myAlarm.isEmpty())
return;
boolean hasSelection = !myResultList.isSelectionEmpty();
myListener.canSelectStateChanged(MavenArtifactSearchPanel.this, hasSelection);
}
});
myResultList.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER && myResultList.getLastSelectedPathComponent() != null) {
myListener.itemSelected();
e.consume();
}
}
});
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent e) {
final TreePath path = myResultList.getPathForLocation(e.getX(), e.getY());
if (path != null && myResultList.isPathSelected(path)) {
Object sel = path.getLastPathComponent();
if (sel != null && myResultList.getModel().isLeaf(sel)) {
myListener.itemSelected();
return true;
}
}
return false;
}
}.installOn(myResultList);
}
use of java.awt.event.MouseEvent in project robo4j by Robo4J.
the class LCDColorConverter method createButton.
private Component createButton(String string, final int buttonMaskVal) {
JButton button = new JButton(string);
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
MockupLcd.this.maskVal = MockupLcd.this.maskVal & ~buttonMaskVal;
}
@Override
public void mousePressed(MouseEvent e) {
MockupLcd.this.maskVal = MockupLcd.this.maskVal | buttonMaskVal;
try {
Thread.sleep(30);
} catch (InterruptedException e1) {
//
}
}
});
return button;
}
use of java.awt.event.MouseEvent in project ACS by ACS-Community.
the class LoggingClient method getStatusLinePnl.
/**
* Returns the panel for the status line
*
* @return the panel for the status line
*/
private JPanel getStatusLinePnl() {
if (statusLinePnl == null) {
try {
// Load the icons for the status of the connection
connectionStatusIcons = new ImageIcon[5];
connectionStatusIcons[CONNECTED_ICON] = new ImageIcon(this.getClass().getResource("/console-connected.png"));
connectionStatusIcons[CONNECTING_ICON] = new ImageIcon(this.getClass().getResource("/console-connecting.png"));
connectionStatusIcons[DISCONNECTED_ICON] = new ImageIcon(this.getClass().getResource("/console-disconnected.png"));
connectionStatusIcons[SUSPENDED_ICON] = new ImageIcon(this.getClass().getResource("/console-suspended.png"));
connectionStatusIcons[DELAY_ICON] = new ImageIcon(this.getClass().getResource("/console-delay.png"));
connectionStatusLbl = new JLabel(connectionStatusIcons[CONNECTING_ICON]);
// Create a label to show the status of the connection with the DB
connectionDBLbl = new JLabel();
statusLinePnl = new javax.swing.JPanel();
statusLinePnl.setName("Status_line");
statusLinePnl.setLayout(new java.awt.GridBagLayout());
GridBagConstraints constraintsProgressBar = new GridBagConstraints();
constraintsProgressBar.gridx = 0;
constraintsProgressBar.gridy = 0;
constraintsProgressBar.fill = GridBagConstraints.BOTH;
constraintsProgressBar.anchor = GridBagConstraints.WEST;
constraintsProgressBar.weightx = 1.0;
constraintsProgressBar.insets = new Insets(1, 2, 1, 1);
statusLinePnl.add(progressBar, constraintsProgressBar);
GridBagConstraints constraintsNumFlt = new GridBagConstraints();
constraintsNumFlt.gridx = 1;
constraintsNumFlt.gridy = 0;
constraintsNumFlt.insets = new Insets(1, 1, 1, 1);
maxNumOfLogsLbl.setVisible(true);
maxNumOfLogsLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fntNumFlt = maxNumOfLogsLbl.getFont();
Font newFontNumFlt = fntNumFlt.deriveFont(fntNumFlt.getSize() - 2);
maxNumOfLogsLbl.setFont(newFontNumFlt);
statusLinePnl.add(maxNumOfLogsLbl, constraintsNumFlt);
GridBagConstraints constraintsEngineFlt = new GridBagConstraints();
constraintsEngineFlt.gridx = 2;
constraintsEngineFlt.gridy = 0;
constraintsEngineFlt.insets = new Insets(1, 1, 1, 1);
engineFiltersLbl.setVisible(true);
engineFiltersLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fntEngineFlt = engineFiltersLbl.getFont();
Font newFontEngineFlt = fntEngineFlt.deriveFont(fntEngineFlt.getSize() - 2);
engineFiltersLbl.setFont(newFontEngineFlt);
statusLinePnl.add(engineFiltersLbl, constraintsEngineFlt);
GridBagConstraints constraintsTableFlt = new GridBagConstraints();
constraintsTableFlt.gridx = 3;
constraintsTableFlt.gridy = 0;
constraintsTableFlt.insets = new Insets(1, 1, 1, 1);
tableFiltersLbl.setVisible(true);
tableFiltersLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fntTableFlt = tableFiltersLbl.getFont();
Font newFontTableFlt = fntTableFlt.deriveFont(fntTableFlt.getSize() - 2);
tableFiltersLbl.setFont(newFontTableFlt);
statusLinePnl.add(tableFiltersLbl, constraintsTableFlt);
GridBagConstraints constraintsAudience = new GridBagConstraints();
constraintsAudience.gridx = 4;
constraintsAudience.gridy = 0;
constraintsAudience.insets = new Insets(1, 1, 1, 1);
audienceLbl.setVisible(true);
audienceLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fnt = audienceLbl.getFont();
Font newFont = fnt.deriveFont(fnt.getSize() - 2);
audienceLbl.setFont(newFont);
statusLinePnl.add(audienceLbl, constraintsAudience);
GridBagConstraints constraintsConnectionDBStatus = new GridBagConstraints();
constraintsConnectionDBStatus.gridx = 5;
constraintsConnectionDBStatus.gridy = 0;
constraintsConnectionDBStatus.insets = new Insets(1, 2, 1, 2);
statusLinePnl.add(connectionDBLbl, constraintsConnectionDBStatus);
GridBagConstraints constraintsJlogErrors = new GridBagConstraints();
constraintsConnectionDBStatus.gridx = 6;
constraintsConnectionDBStatus.gridy = 0;
constraintsConnectionDBStatus.insets = new Insets(1, 2, 1, 2);
statusLinePnl.add(jlogErrorLbl, constraintsJlogErrors);
jlogErrorLbl.setVisible(false);
jlogErrorLbl.setToolTipText("Error reading logs");
jlogErrorLbl.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
jlogErrorLbl.setVisible(false);
errorDialog.setVisible(true, LoggingClient.this);
super.mouseClicked(e);
}
});
GridBagConstraints constraintsConnectionStatus = new GridBagConstraints();
constraintsConnectionStatus.gridx = 7;
constraintsConnectionStatus.gridy = 0;
constraintsConnectionStatus.insets = new Insets(1, 2, 1, 2);
statusLinePnl.add(connectionStatusLbl, constraintsConnectionStatus);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
return statusLinePnl;
}
use of java.awt.event.MouseEvent in project EnrichmentMapApp by BaderLab.
the class ColumnHeaderRankOptionRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, final Object value, boolean isSelected, boolean hasFocus, int row, int col) {
// Convert RankingOption to display String
String text = null;
if (value instanceof RankingOption) {
RankingOption rankingOption = (RankingOption) value;
text = rankingOption.getTableHeaderText();
} else if (value instanceof RankOptionErrorHeader) {
RankOptionErrorHeader headerValue = (RankOptionErrorHeader) value;
text = headerValue.getRankingOption().getTableHeaderText();
}
// Use the default renderer to paint the header nicely (with sort arrows)
JTableHeader header = table.getTableHeader();
TableCellRenderer delegate = table.getTableHeader().getDefaultRenderer();
Component component = delegate.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, col);
// Create the panel
JButton button = new JButton("Sort");
SwingUtil.makeSmall(button);
if (isAquaLAF())
button.putClientProperty("JButton.buttonType", "gradient");
button.addActionListener(e -> menuButtonClicked(table, button));
JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.add(button, BorderLayout.CENTER);
buttonPanel.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
buttonPanel.setForeground(header.getForeground());
buttonPanel.setBackground(header.getBackground());
JPanel panel = new JPanel(new BorderLayout());
panel.setForeground(header.getForeground());
panel.setBackground(header.getBackground());
panel.add(component, BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.NORTH);
if (value instanceof RankOptionErrorHeader) {
JLabel icon = new JLabel(IconManager.ICON_TIMES_CIRCLE);
icon.setForeground(Color.RED.darker());
icon.setFont(iconManager.getIconFont(13.0f));
icon.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
icon.setOpaque(false);
panel.add(icon, BorderLayout.WEST);
}
// Add mouse listener
if (mouseListener != null) {
header.removeMouseListener(mouseListener);
}
header.addMouseListener(mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int col = header.columnAtPoint(e.getPoint());
if (col == colIndex)
if (e.getY() <= button.getHeight())
button.doClick();
else
sortColumn(table);
else
sortOrder = null;
}
});
return panel;
}
Aggregations