use of java.awt.event.MouseEvent in project libgdx by libgdx.
the class ExternalExtensionsDialog method uiLayout.
private void uiLayout() {
topPanel = new JPanel(new GridBagLayout());
topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
warningNotice = new JLabel("List of third party extensions for LibGDX");
warningNotice2 = new JLabel("These are not maintained by the LibGDX team, please see the support links for info and help");
warningNotice.setHorizontalAlignment(JLabel.CENTER);
warningNotice2.setHorizontalAlignment(JLabel.CENTER);
topPanel.add(warningNotice, new GridBagConstraints(0, 0, 1, 1, 1, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
topPanel.add(warningNotice2, new GridBagConstraints(0, 1, 1, 1, 1, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
JSeparator separator = new JSeparator();
separator.setForeground(new Color(85, 85, 85));
separator.setBackground(new Color(85, 85, 85));
topPanel.add(separator, new GridBagConstraints(0, 2, 1, 1, 1, 1, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
tableModel = new ExtensionTableModel();
table = new JTable(tableModel) {
@Override
public String getToolTipText(MouseEvent e) {
return ((ExtensionTableModel) getModel()).getToolTip(e);
}
};
table.getColumnModel().getColumn(0).setPreferredWidth(10);
table.getColumnModel().getColumn(1).setPreferredWidth(50);
table.getColumnModel().getColumn(2).setPreferredWidth(100);
table.getColumnModel().getColumn(3).setPreferredWidth(20);
table.getColumnModel().getColumn(4).setPreferredWidth(30);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
table.getTableHeader().setReorderingAllowed(false);
table.getModel().addTableModelListener(this);
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
int column = table.getSelectedColumn();
if (column == 5) {
URI uri = ((ExtensionTableModel) table.getModel()).getURI(row, column);
if (uri != null) {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
});
scrollPane = new JScrollPane(table);
bottomPanel = new JPanel(new GridBagLayout());
buttonPanel = new JPanel(new GridBagLayout());
buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
buttonOK = new SetupButton("Save");
buttonCancel = new SetupButton("Cancel");
buttonPanel.add(buttonOK, new GridBagConstraints(0, 0, 1, 1, 0, 0, CENTER, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
buttonPanel.add(buttonCancel, new GridBagConstraints(1, 0, 1, 1, 0, 0, CENTER, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
bottomPanel.add(buttonPanel, new GridBagConstraints(3, 0, 1, 1, 1, 1, SOUTHEAST, NONE, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(topPanel, new GridBagConstraints(0, 0, 1, 1, 1, 0.1, NORTH, BOTH, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 1, 1, NORTH, BOTH, new Insets(0, 0, 0, 0), 0, 0));
contentPane.add(bottomPanel, new GridBagConstraints(0, 2, 1, 1, 1, 0, SOUTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
try {
initData();
} catch (Exception e) {
e.printStackTrace();
}
}
use of java.awt.event.MouseEvent in project libgdx by libgdx.
the class EditorPanel method initializeComponents.
protected void initializeComponents() {
setLayout(new GridBagLayout());
{
titlePanel = new JPanel(new GridBagLayout());
add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 0, 3, 0), 0, 0));
titlePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
{
nameLabel = new JLabel(name);
titlePanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD));
}
{
descriptionLabel = new JLabel(description);
titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
}
{
advancedButton = new JToggleButton("Advanced");
titlePanel.add(advancedButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
advancedButton.setVisible(false);
}
{
activeButton = new JToggleButton("Active");
titlePanel.add(activeButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
}
{
removeButton = new JButton("X");
titlePanel.add(removeButton, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
}
}
{
contentPanel = new JPanel(new GridBagLayout());
add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0));
contentPanel.setVisible(false);
}
{
advancedPanel = new JPanel(new GridBagLayout());
add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0));
advancedPanel.setVisible(false);
}
titlePanel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent event) {
if (!isAlwaysShown)
showContent(!contentPanel.isVisible());
}
});
activeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
activate();
}
});
advancedButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
advancedPanel.setVisible(advancedButton.isSelected());
}
});
removeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
removePanel();
}
});
}
use of java.awt.event.MouseEvent in project libgdx by libgdx.
the class Hiero method initializeEvents.
private void initializeEvents() {
fontList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
if (evt.getValueIsAdjusting())
return;
prefs.put("system.font", (String) fontList.getSelectedValue());
updateFont();
}
});
class FontUpdateListener implements ChangeListener, ActionListener {
public void stateChanged(ChangeEvent evt) {
updateFont();
}
public void actionPerformed(ActionEvent evt) {
updateFont();
}
public void addSpinners(JSpinner[] spinners) {
for (int i = 0; i < spinners.length; i++) {
final JSpinner spinner = spinners[i];
spinner.addChangeListener(this);
((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().addKeyListener(new KeyAdapter() {
String lastText;
public void keyReleased(KeyEvent evt) {
JFormattedTextField textField = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
String text = textField.getText();
if (text.length() == 0)
return;
if (text.equals(lastText))
return;
lastText = text;
int caretPosition = textField.getCaretPosition();
try {
spinner.setValue(Integer.valueOf(text));
} catch (NumberFormatException ex) {
}
textField.setCaretPosition(caretPosition);
}
});
}
}
}
FontUpdateListener listener = new FontUpdateListener();
listener.addSpinners(new JSpinner[] { padTopSpinner, padRightSpinner, padBottomSpinner, padLeftSpinner, padAdvanceXSpinner, padAdvanceYSpinner });
fontSizeSpinner.addChangeListener(listener);
gammaSpinner.addChangeListener(listener);
glyphPageWidthCombo.addActionListener(listener);
glyphPageHeightCombo.addActionListener(listener);
boldCheckBox.addActionListener(listener);
italicCheckBox.addActionListener(listener);
monoCheckBox.addActionListener(listener);
resetCacheButton.addActionListener(listener);
javaRadio.addActionListener(listener);
nativeRadio.addActionListener(listener);
freeTypeRadio.addActionListener(listener);
sampleTextRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
glyphCachePanel.setVisible(false);
}
});
glyphCacheRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
glyphCachePanel.setVisible(true);
}
});
fontFileText.getDocument().addDocumentListener(new DocumentListener() {
public void removeUpdate(DocumentEvent evt) {
changed();
}
public void insertUpdate(DocumentEvent evt) {
changed();
}
public void changedUpdate(DocumentEvent evt) {
changed();
}
private void changed() {
File file = new File(fontFileText.getText());
if (fontList.isEnabled() && (!file.exists() || !file.isFile()))
return;
prefs.put("font.file", fontFileText.getText());
updateFont();
}
});
final ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
updateFontSelector();
updateFont();
}
};
systemFontRadio.addActionListener(al);
fontFileRadio.addActionListener(al);
browseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
FileDialog dialog = new FileDialog(Hiero.this, "Choose TrueType font file", FileDialog.LOAD);
dialog.setLocationRelativeTo(null);
dialog.setFile("*.ttf");
dialog.setDirectory(prefs.get("dir.font", ""));
dialog.setVisible(true);
if (dialog.getDirectory() != null) {
prefs.put("dir.font", dialog.getDirectory());
}
String fileName = dialog.getFile();
if (fileName == null)
return;
fontFileText.setText(new File(dialog.getDirectory(), fileName).getAbsolutePath());
}
});
backgroundColorLabel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
java.awt.Color color = JColorChooser.showDialog(null, "Choose a background color", EffectUtil.fromString(prefs.get("background", "000000")));
if (color == null)
return;
renderingBackgroundColor = new Color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1);
backgroundColorLabel.setIcon(getColorIcon(color));
prefs.put("background", EffectUtil.toString(color));
}
});
effectsList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
ConfigurableEffect selectedEffect = (ConfigurableEffect) effectsList.getSelectedValue();
boolean enabled = selectedEffect != null;
for (Iterator iter = effectPanels.iterator(); iter.hasNext(); ) {
ConfigurableEffect effect = ((EffectPanel) iter.next()).getEffect();
if (effect == selectedEffect) {
enabled = false;
break;
}
}
addEffectButton.setEnabled(enabled);
}
});
effectsList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
if (evt.getClickCount() == 2 && addEffectButton.isEnabled())
addEffectButton.doClick();
}
});
addEffectButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
new EffectPanel((ConfigurableEffect) effectsList.getSelectedValue());
}
});
openMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
FileDialog dialog = new FileDialog(Hiero.this, "Open Hiero settings file", FileDialog.LOAD);
dialog.setLocationRelativeTo(null);
dialog.setFile("*.hiero");
dialog.setDirectory(prefs.get("dir.open", ""));
dialog.setVisible(true);
if (dialog.getDirectory() != null) {
prefs.put("dir.open", dialog.getDirectory());
}
String fileName = dialog.getFile();
if (fileName == null)
return;
lastOpenFilename = fileName;
open(new File(dialog.getDirectory(), fileName));
}
});
saveMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
FileDialog dialog = new FileDialog(Hiero.this, "Save Hiero settings file", FileDialog.SAVE);
dialog.setLocationRelativeTo(null);
dialog.setFile("*.hiero");
dialog.setDirectory(prefs.get("dir.save", ""));
if (lastSaveFilename.length() > 0) {
dialog.setFile(lastSaveFilename);
} else if (lastOpenFilename.length() > 0) {
dialog.setFile(lastOpenFilename);
}
dialog.setVisible(true);
if (dialog.getDirectory() != null) {
prefs.put("dir.save", dialog.getDirectory());
}
String fileName = dialog.getFile();
if (fileName == null)
return;
if (!fileName.endsWith(".hiero"))
fileName += ".hiero";
lastSaveFilename = fileName;
File file = new File(dialog.getDirectory(), fileName);
try {
save(file);
} catch (IOException ex) {
throw new RuntimeException("Error saving Hiero settings file: " + file.getAbsolutePath(), ex);
}
}
});
saveBMFontMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
FileDialog dialog = new FileDialog(Hiero.this, "Save BMFont files", FileDialog.SAVE);
dialog.setLocationRelativeTo(null);
dialog.setFile("*.fnt");
dialog.setDirectory(prefs.get("dir.savebm", ""));
if (lastSaveBMFilename.length() > 0) {
dialog.setFile(lastSaveBMFilename);
} else if (lastOpenFilename.length() > 0) {
dialog.setFile(lastOpenFilename.replace(".hiero", ".fnt"));
}
dialog.setVisible(true);
if (dialog.getDirectory() != null) {
prefs.put("dir.savebm", dialog.getDirectory());
}
String fileName = dialog.getFile();
if (fileName == null)
return;
lastSaveBMFilename = fileName;
saveBm(new File(dialog.getDirectory(), fileName));
}
});
exitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
dispose();
}
});
sampleNeheButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
sampleTextPane.setText(NEHE_CHARS);
resetCacheButton.doClick();
}
});
sampleAsciiButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
StringBuilder buffer = new StringBuilder();
buffer.append(NEHE_CHARS);
buffer.append('\n');
int count = 0;
for (int i = 33; i <= 255; i++) {
if (buffer.indexOf(Character.toString((char) i)) != -1)
continue;
buffer.append((char) i);
if (++count % 30 == 0)
buffer.append('\n');
}
sampleTextPane.setText(buffer.toString());
resetCacheButton.doClick();
}
});
sampleExtendedButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
sampleTextPane.setText(EXTENDED_CHARS);
resetCacheButton.doClick();
}
});
}
use of java.awt.event.MouseEvent in project libgdx by libgdx.
the class GradientPanel method initializeComponents.
private void initializeComponents() {
JPanel contentPanel = getContentPanel();
{
gradientEditor = new GradientEditor() {
public void handleSelected(Color color) {
GradientPanel.this.setColor(color);
}
};
contentPanel.add(gradientEditor, new GridBagConstraints(0, 1, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 10));
}
{
hueSlider = new ColorSlider(new Color[] { Color.red, Color.yellow, Color.green, Color.cyan, Color.blue, Color.magenta, Color.red }) {
protected void colorPicked() {
saturationSlider.setColors(new Color[] { new Color(Color.HSBtoRGB(getPercentage(), 1, 1)), Color.white });
updateColor();
}
};
contentPanel.add(hueSlider, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
}
{
saturationSlider = new ColorSlider(new Color[] { Color.red, Color.white }) {
protected void colorPicked() {
updateColor();
}
};
contentPanel.add(saturationSlider, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 6), 0, 0));
}
{
lightnessSlider = new ColorSlider(new Color[0]) {
protected void colorPicked() {
updateColor();
}
};
contentPanel.add(lightnessSlider, new GridBagConstraints(2, 3, 1, 1, 1, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
}
{
colorPanel = new JPanel() {
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
size.width = 52;
return size;
}
};
contentPanel.add(colorPanel, new GridBagConstraints(0, 2, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(3, 0, 0, 6), 0, 0));
}
colorPanel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
Color color = JColorChooser.showDialog(colorPanel, "Set Color", colorPanel.getBackground());
if (color != null)
setColor(color);
}
});
colorPanel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.black));
}
use of java.awt.event.MouseEvent in project CoreNLP by stanfordnlp.
the class JarFileChooser method showListSelectionDialog.
public String showListSelectionDialog(List<String> files, Point location) {
Frame frame = new Frame();
//System.out.println(location);
//frame.setLocation(location);
final JDialog dialog = new JDialog(frame, "Jar File Chooser", true);
dialog.setLocation(location);
final JList fileList = new JList(new Vector<>(files));
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
// double clicked
dialog.setVisible(false);
}
}
};
fileList.addMouseListener(mouseListener);
final JScrollPane scroll = new JScrollPane(fileList);
JButton okay = new javax.swing.JButton();
okay.setText("Okay");
okay.setToolTipText("Okay");
okay.addActionListener(evt -> dialog.setVisible(false));
JButton cancel = new javax.swing.JButton();
cancel.setText("Cancel");
cancel.setToolTipText("Cancel");
cancel.addActionListener(evt -> {
fileList.clearSelection();
dialog.setVisible(false);
});
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
dialog.setLayout(gridbag);
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.fill = GridBagConstraints.BOTH;
constraints.weightx = 1.0;
constraints.weighty = 1.0;
gridbag.setConstraints(scroll, constraints);
dialog.add(scroll);
constraints.gridwidth = GridBagConstraints.RELATIVE;
constraints.fill = GridBagConstraints.NONE;
constraints.weighty = 0.0;
gridbag.setConstraints(okay, constraints);
dialog.add(okay);
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(cancel, constraints);
dialog.add(cancel);
dialog.pack();
dialog.setSize(dialog.getPreferredSize());
dialog.setVisible(true);
if (fileList.isSelectionEmpty())
return null;
return files.get(fileList.getSelectedIndex());
}
Aggregations