use of javax.swing.JSpinner in project jadx by skylot.
the class JadxSettingsWindow method makeDecompilationGroup.
private SettingsGroup makeDecompilationGroup() {
JCheckBox fallback = new JCheckBox();
fallback.setSelected(settings.isFallbackMode());
fallback.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setFallbackMode(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
JCheckBox showInconsistentCode = new JCheckBox();
showInconsistentCode.setSelected(settings.isShowInconsistentCode());
showInconsistentCode.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setShowInconsistentCode(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
JCheckBox resourceDecode = new JCheckBox();
resourceDecode.setSelected(settings.isSkipResources());
resourceDecode.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setSkipResources(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
final JSpinner threadsCount = new JSpinner();
threadsCount.setValue(settings.getThreadsCount());
threadsCount.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
settings.setThreadsCount((Integer) threadsCount.getValue());
}
});
JCheckBox autoStartJobs = new JCheckBox();
autoStartJobs.setSelected(settings.isAutoStartJobs());
autoStartJobs.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setAutoStartJobs(e.getStateChange() == ItemEvent.SELECTED);
}
});
JCheckBox escapeUnicode = new JCheckBox();
escapeUnicode.setSelected(settings.escapeUnicode());
escapeUnicode.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setEscapeUnicode(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
JCheckBox replaceConsts = new JCheckBox();
replaceConsts.setSelected(settings.isReplaceConsts());
replaceConsts.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setReplaceConsts(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
SettingsGroup other = new SettingsGroup(NLS.str("preferences.decompile"));
other.addRow(NLS.str("preferences.threads"), threadsCount);
other.addRow(NLS.str("preferences.start_jobs"), autoStartJobs);
other.addRow(NLS.str("preferences.showInconsistentCode"), showInconsistentCode);
other.addRow(NLS.str("preferences.escapeUnicode"), escapeUnicode);
other.addRow(NLS.str("preferences.replaceConsts"), replaceConsts);
other.addRow(NLS.str("preferences.fallback"), fallback);
other.addRow(NLS.str("preferences.skipResourcesDecode"), resourceDecode);
return other;
}
use of javax.swing.JSpinner 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 javax.swing.JSpinner in project libgdx by libgdx.
the class Hiero method initializeComponents.
private void initializeComponents() {
getContentPane().setLayout(new GridBagLayout());
JPanel leftSidePanel = new JPanel();
leftSidePanel.setLayout(new GridBagLayout());
getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
{
JPanel fontPanel = new JPanel();
leftSidePanel.add(fontPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
fontPanel.setLayout(new GridBagLayout());
fontPanel.setBorder(BorderFactory.createTitledBorder("Font"));
{
fontSizeSpinner = new JSpinner(new SpinnerNumberModel(32, 0, 256, 1));
fontPanel.add(fontSizeSpinner, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
((JSpinner.DefaultEditor) fontSizeSpinner.getEditor()).getTextField().setColumns(2);
}
{
JScrollPane fontScroll = new JScrollPane();
fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
{
fontListModel = new DefaultComboBoxModel(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
fontList = new JList();
fontScroll.setViewportView(fontList);
fontList.setModel(fontListModel);
fontList.setVisibleRowCount(6);
fontList.setSelectedIndex(0);
fontScroll.setMinimumSize(new Dimension(220, fontList.getPreferredScrollableViewportSize().height));
}
}
{
systemFontRadio = new JRadioButton("System:", true);
fontPanel.add(systemFontRadio, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
systemFontRadio.setMargin(new Insets(0, 0, 0, 0));
}
{
fontFileRadio = new JRadioButton("File:");
fontPanel.add(fontFileRadio, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
fontFileRadio.setMargin(new Insets(0, 0, 0, 0));
}
{
fontFileText = new JTextField();
fontPanel.add(fontFileText, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
}
{
fontPanel.add(new JLabel("Size:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
unicodePanel = new JPanel(new GridBagLayout());
fontPanel.add(unicodePanel, new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
{
boldCheckBox = new JCheckBox("Bold");
unicodePanel.add(boldCheckBox, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
italicCheckBox = new JCheckBox("Italic");
unicodePanel.add(italicCheckBox, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
}
{
bitmapPanel = new JPanel(new GridBagLayout());
fontPanel.add(bitmapPanel, new GridBagConstraints(2, 3, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
{
bitmapPanel.add(new JLabel("Gamma:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
gammaSpinner = new JSpinner(new SpinnerNumberModel(1.8f, 0, 30, 0.01));
((JSpinner.DefaultEditor) gammaSpinner.getEditor()).getTextField().setColumns(2);
bitmapPanel.add(gammaSpinner, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
}
{
monoCheckBox = new JCheckBox("Mono");
bitmapPanel.add(monoCheckBox, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
}
{
browseButton = new JButton("...");
fontPanel.add(browseButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
browseButton.setMargin(new Insets(0, 0, 0, 0));
}
{
fontPanel.add(new JLabel("Rendering:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
JPanel renderingPanel = new JPanel(new GridBagLayout());
fontPanel.add(renderingPanel, new GridBagConstraints(1, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
{
freeTypeRadio = new JRadioButton("FreeType");
renderingPanel.add(freeTypeRadio, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
javaRadio = new JRadioButton("Java");
renderingPanel.add(javaRadio, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
nativeRadio = new JRadioButton("Native");
renderingPanel.add(nativeRadio, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
}
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(systemFontRadio);
buttonGroup.add(fontFileRadio);
buttonGroup = new ButtonGroup();
buttonGroup.add(freeTypeRadio);
buttonGroup.add(javaRadio);
buttonGroup.add(nativeRadio);
freeTypeRadio.setSelected(true);
}
{
JPanel samplePanel = new JPanel();
leftSidePanel.add(samplePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 5), 0, 0));
samplePanel.setLayout(new GridBagLayout());
samplePanel.setBorder(BorderFactory.createTitledBorder("Sample Text"));
{
JScrollPane textScroll = new JScrollPane();
samplePanel.add(textScroll, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
{
sampleTextPane = new JTextPane();
textScroll.setViewportView(sampleTextPane);
}
}
{
sampleNeheButton = new JButton();
sampleNeheButton.setText("NEHE");
samplePanel.add(sampleNeheButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
sampleAsciiButton = new JButton();
sampleAsciiButton.setText("ASCII");
samplePanel.add(sampleAsciiButton, new GridBagConstraints(3, 1, 1, 1, 0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
sampleExtendedButton = new JButton();
sampleExtendedButton.setText("Extended");
samplePanel.add(sampleExtendedButton, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
}
{
JPanel renderingPanel = new JPanel();
leftSidePanel.add(renderingPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
renderingPanel.setBorder(BorderFactory.createTitledBorder("Rendering"));
renderingPanel.setLayout(new GridBagLayout());
{
JPanel wrapperPanel = new JPanel();
renderingPanel.add(wrapperPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
wrapperPanel.setLayout(new BorderLayout());
wrapperPanel.setBackground(java.awt.Color.white);
{
gamePanel = new JPanel();
wrapperPanel.add(gamePanel);
gamePanel.setLayout(new BorderLayout());
gamePanel.setBackground(java.awt.Color.white);
}
}
{
glyphCachePanel = new JPanel() {
private int maxWidth;
public Dimension getPreferredSize() {
// Keep glyphCachePanel width from ever going down so the CanvasGameContainer doesn't change sizes and flicker.
Dimension size = super.getPreferredSize();
maxWidth = Math.max(maxWidth, size.width);
size.width = maxWidth;
return size;
}
};
glyphCachePanel.setVisible(false);
renderingPanel.add(glyphCachePanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
glyphCachePanel.setLayout(new GridBagLayout());
{
glyphCachePanel.add(new JLabel("Glyphs:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphCachePanel.add(new JLabel("Pages:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphCachePanel.add(new JLabel("Page width:"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphCachePanel.add(new JLabel("Page height:"), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphPageWidthCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] { new Integer(32), new Integer(64), new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048) }));
glyphCachePanel.add(glyphPageWidthCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
glyphPageWidthCombo.setSelectedIndex(4);
}
{
glyphPageHeightCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] { new Integer(32), new Integer(64), new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048) }));
glyphCachePanel.add(glyphPageHeightCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
glyphPageHeightCombo.setSelectedIndex(4);
}
{
resetCacheButton = new JButton("Reset Cache");
glyphCachePanel.add(resetCacheButton, new GridBagConstraints(0, 6, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphPagesTotalLabel = new JLabel("1");
glyphCachePanel.add(glyphPagesTotalLabel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
glyphsTotalLabel = new JLabel("0");
glyphCachePanel.add(glyphsTotalLabel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
glyphPageComboModel = new DefaultComboBoxModel();
glyphPageCombo = new JComboBox();
glyphCachePanel.add(glyphPageCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
glyphPageCombo.setModel(glyphPageComboModel);
}
{
glyphCachePanel.add(new JLabel("View:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
}
{
JPanel radioButtonsPanel = new JPanel();
renderingPanel.add(radioButtonsPanel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
radioButtonsPanel.setLayout(new GridBagLayout());
{
sampleTextRadio = new JRadioButton("Sample text");
radioButtonsPanel.add(sampleTextRadio, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
sampleTextRadio.setSelected(true);
}
{
glyphCacheRadio = new JRadioButton("Glyph cache");
radioButtonsPanel.add(glyphCacheRadio, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
radioButtonsPanel.add(new JLabel("Background:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
backgroundColorLabel = new JLabel();
radioButtonsPanel.add(backgroundColorLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(glyphCacheRadio);
buttonGroup.add(sampleTextRadio);
}
}
JPanel rightSidePanel = new JPanel();
rightSidePanel.setLayout(new GridBagLayout());
getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
{
JPanel paddingPanel = new JPanel();
paddingPanel.setLayout(new GridBagLayout());
rightSidePanel.add(paddingPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
paddingPanel.setBorder(BorderFactory.createTitledBorder("Padding"));
{
padTopSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
paddingPanel.add(padTopSpinner, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
((JSpinner.DefaultEditor) padTopSpinner.getEditor()).getTextField().setColumns(2);
}
{
padRightSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
paddingPanel.add(padRightSpinner, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
((JSpinner.DefaultEditor) padRightSpinner.getEditor()).getTextField().setColumns(2);
}
{
padLeftSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
paddingPanel.add(padLeftSpinner, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));
((JSpinner.DefaultEditor) padLeftSpinner.getEditor()).getTextField().setColumns(2);
}
{
padBottomSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
paddingPanel.add(padBottomSpinner, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
((JSpinner.DefaultEditor) padBottomSpinner.getEditor()).getTextField().setColumns(2);
}
{
JPanel advancePanel = new JPanel();
FlowLayout advancePanelLayout = new FlowLayout();
advancePanel.setLayout(advancePanelLayout);
paddingPanel.add(advancePanel, new GridBagConstraints(0, 4, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
{
advancePanel.add(new JLabel("X:"));
}
{
padAdvanceXSpinner = new JSpinner(new SpinnerNumberModel(-2, -999, 999, 1));
advancePanel.add(padAdvanceXSpinner);
((JSpinner.DefaultEditor) padAdvanceXSpinner.getEditor()).getTextField().setColumns(2);
}
{
advancePanel.add(new JLabel("Y:"));
}
{
padAdvanceYSpinner = new JSpinner(new SpinnerNumberModel(-2, -999, 999, 1));
advancePanel.add(padAdvanceYSpinner);
((JSpinner.DefaultEditor) padAdvanceYSpinner.getEditor()).getTextField().setColumns(2);
}
}
}
{
effectsPanel = new JPanel();
effectsPanel.setLayout(new GridBagLayout());
rightSidePanel.add(effectsPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 5), 0, 0));
effectsPanel.setBorder(BorderFactory.createTitledBorder("Effects"));
effectsPanel.setMinimumSize(new Dimension(210, 1));
{
effectsScroll = new JScrollPane();
effectsPanel.add(effectsScroll, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
{
effectsListModel = new DefaultComboBoxModel();
effectsList = new JList();
effectsScroll.setViewportView(effectsList);
effectsList.setModel(effectsListModel);
effectsList.setVisibleRowCount(7);
effectsScroll.setMinimumSize(effectsList.getPreferredScrollableViewportSize());
}
}
{
addEffectButton = new JButton("Add");
effectsPanel.add(addEffectButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 6, 5), 0, 0));
addEffectButton.setEnabled(false);
}
{
appliedEffectsScroll = new JScrollPane();
effectsPanel.add(appliedEffectsScroll, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
appliedEffectsScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
appliedEffectsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
{
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
appliedEffectsScroll.setViewportView(panel);
{
appliedEffectsPanel = new JPanel();
appliedEffectsPanel.setLayout(new GridBagLayout());
panel.add(appliedEffectsPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
appliedEffectsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, java.awt.Color.black));
}
}
}
}
}
use of javax.swing.JSpinner 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 javax.swing.JSpinner in project jdk8u_jdk by JetBrains.
the class DimensionEncapsulation method run.
@Override
public void run() {
runTest(new Panel());
runTest(new Button());
runTest(new Checkbox());
runTest(new Canvas());
runTest(new Choice());
runTest(new Label());
runTest(new Scrollbar());
runTest(new TextArea());
runTest(new TextField());
runTest(new Dialog(new JFrame()));
runTest(new Frame());
runTest(new Window(new JFrame()));
runTest(new FileDialog(new JFrame()));
runTest(new List());
runTest(new ScrollPane());
runTest(new JFrame());
runTest(new JDialog(new JFrame()));
runTest(new JWindow(new JFrame()));
runTest(new JLabel("hi"));
runTest(new JMenu());
runTest(new JTree());
runTest(new JTable());
runTest(new JMenuItem());
runTest(new JCheckBoxMenuItem());
runTest(new JToggleButton());
runTest(new JSpinner());
runTest(new JSlider());
runTest(Box.createVerticalBox());
runTest(Box.createHorizontalBox());
runTest(new JTextField());
runTest(new JTextArea());
runTest(new JTextPane());
runTest(new JPasswordField());
runTest(new JFormattedTextField());
runTest(new JEditorPane());
runTest(new JButton());
runTest(new JColorChooser());
runTest(new JFileChooser());
runTest(new JCheckBox());
runTest(new JInternalFrame());
runTest(new JDesktopPane());
runTest(new JTableHeader());
runTest(new JLayeredPane());
runTest(new JRootPane());
runTest(new JMenuBar());
runTest(new JOptionPane());
runTest(new JRadioButton());
runTest(new JRadioButtonMenuItem());
runTest(new JPopupMenu());
//runTest(new JScrollBar()); --> don't test defines max and min in
// terms of preferred
runTest(new JScrollPane());
runTest(new JViewport());
runTest(new JSplitPane());
runTest(new JTabbedPane());
runTest(new JToolBar());
runTest(new JSeparator());
runTest(new JProgressBar());
if (!failures.isEmpty()) {
System.out.println("These classes failed");
for (final Component failure : failures) {
System.out.println(failure.getClass());
}
throw new RuntimeException("Test failed");
}
}
Aggregations