public void setSpinnerSemester(JSpinner spinnerSemester) { this.spinnerSemester = spinnerSemester; java.util.List<Semester> semesterList = svmContext.getSvmModel().getSemestersAll(); if (semesterList.isEmpty()) { // keine Semester erfasst SpinnerModel spinnerModel = new SpinnerListModel(new String[] {""}); spinnerSemester.setModel(spinnerModel); spinnerSemester.setEnabled(false); return; } Semester[] semesters = semesterList.toArray(new Semester[semesterList.size()]); SpinnerModel spinnerModelSemester = new SpinnerListModel(semesters); spinnerSemester.setModel(spinnerModelSemester); spinnerSemester.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { onSemesterSelected(); } }); // Model initialisieren kurseSemesterwahlModel.setSemester( kurseSemesterwahlModel.getInitSemester(svmContext.getSvmModel())); }
public ScalaProjectSettingsPanel(Project project) { myProject = project; outputSpinner.setModel(new SpinnerNumberModel(35, 1, null, 1)); ScalaUiWithDependency[] deps = DependencyAwareInjectionSettings.EP_NAME.getExtensions(); for (ScalaUiWithDependency uiWithDependency : deps) { if (INJECTION_SETTINGS_NAME.equals(uiWithDependency.getName())) { injectionPrefixTable = uiWithDependency.createComponent(injectionJPanel); break; } } if (injectionPrefixTable == null) injectionPrefixTable = new ScalaUiWithDependency.NullComponentWithSettings(); setSettings(); }
public JPanel getAdditionalCharacteristicsPanel(final DisplayObjectType displayObjectType) { JLabel translationFactorLabel = new JLabel("Verschiebungsfaktor: "); SpinnerModel spinnerModel = new SpinnerNumberModel(100, 0, 5000, 1); _translationFactorSpinner.setModel(spinnerModel); _translationFactorSpinner.setMaximumSize(new Dimension(60, 30)); _translationFactorSpinner.setEnabled(_dotDefinitionDialogFrame.isEditable()); JPanel translationPanel = new JPanel(); translationPanel.setLayout(new BoxLayout(translationPanel, BoxLayout.X_AXIS)); translationPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 10)); translationPanel.add(translationFactorLabel); translationPanel.add(_translationFactorSpinner); JLabel joinByLineLabel = new JLabel("Verbindungslinie: "); _joinByLineCheckBox.setSelected(false); _joinByLineCheckBox.setEnabled(_dotDefinitionDialogFrame.isEditable()); JPanel joinByLinePanel = new JPanel(); joinByLinePanel.setLayout(new BoxLayout(joinByLinePanel, BoxLayout.X_AXIS)); joinByLinePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); joinByLinePanel.add(joinByLineLabel); joinByLinePanel.add(_joinByLineCheckBox); JPanel invisiblePanel = new JPanel(); invisiblePanel.add(new JTextField()); invisiblePanel.setVisible(false); JPanel thePanel = new JPanel(); thePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); thePanel.setLayout(new SpringLayout()); thePanel.add(translationPanel); thePanel.add(joinByLinePanel); thePanel.add(invisiblePanel); SpringUtilities.makeCompactGrid(thePanel, 3, 5, 5); if (displayObjectType != null) { DOTPoint dotPoint = (DOTPoint) displayObjectType; _translationFactorSpinner.setValue(dotPoint.getTranslationFactor()); _joinByLineCheckBox.setSelected(dotPoint.isJoinByLine()); } addChangeListeners(); // Erst jetzt, denn sonst werden die Setzungen von // _translationFactorSpinner und _joinByLineCheckBox schon verarbeitet! return thePanel; }
public LingDisplay(final Ling.StoredGraphs storedGraphs) { this.storedGraphs = storedGraphs; if (storedGraphs.getNumGraphs() == 0) { workbench = new GraphWorkbench(); } else { workbench = new GraphWorkbench(storedGraphs.getGraph(0)); } subsetIndices = getStableIndices(storedGraphs); final SpinnerNumberModel model = new SpinnerNumberModel(subsetIndices.size() == 0 ? 0 : 1, 0, subsetIndices.size(), 1); model.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { int index = model.getNumber().intValue(); workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1))); } }); spinner = new JSpinner(); subsetCombo = new JComboBox(new String[] {"Show Stable", "Show Unstable", "Show All"}); subsetCombo.setSelectedItem("Show Stable"); spinner.setModel(model); totalLabel = new JLabel(" of " + subsetIndices.size()); subsetCombo.setMaximumSize(subsetCombo.getPreferredSize()); subsetCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { resetDisplay(); } }); spinner.setPreferredSize(new Dimension(50, 20)); spinner.setMaximumSize(spinner.getPreferredSize()); Box b = Box.createVerticalBox(); Box b1 = Box.createHorizontalBox(); // b1.add(Box.createHorizontalGlue()); // b1.add(Box.createHorizontalStrut(10)); b1.add(subsetCombo); b1.add(Box.createHorizontalGlue()); b1.add(new JLabel("DAG ")); b1.add(spinner); b1.add(totalLabel); b.add(b1); Box b2 = Box.createHorizontalBox(); JPanel graphPanel = new JPanel(); graphPanel.setLayout(new BorderLayout()); JScrollPane jScrollPane = new JScrollPane(workbench); // jScrollPane.setPreferredSize(new Dimension(400, 400)); graphPanel.add(jScrollPane); // graphPanel.setBorder(new TitledBorder("DAG")); b2.add(graphPanel); b.add(b2); setLayout(new BorderLayout()); // add(menuBar(), BorderLayout.NORTH); add(b, BorderLayout.CENTER); }
private void resetDisplay() { String option = (String) subsetCombo.getSelectedItem(); if ("Show All".equals(option)) { final List<Integer> _subsetIndices = getAllIndices(getStoredGraphs()); subsetIndices.clear(); subsetIndices.addAll(_subsetIndices); int min = subsetIndices.size() == 0 ? 0 : 1; final SpinnerNumberModel model = new SpinnerNumberModel(min, min, subsetIndices.size(), 1); model.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { int index = model.getNumber().intValue(); workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1))); } }); spinner.setModel(model); totalLabel.setText(" of " + _subsetIndices.size()); if (subsetIndices.isEmpty()) { workbench.setGraph(new EdgeListGraph()); } else { workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0))); } } else if ("Show Stable".equals(option)) { final List<Integer> _subsetIndices = getStableIndices(getStoredGraphs()); subsetIndices.clear(); subsetIndices.addAll(_subsetIndices); int min = subsetIndices.size() == 0 ? 0 : 1; final SpinnerNumberModel model = new SpinnerNumberModel(min, min, subsetIndices.size(), 1); model.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { int index = model.getNumber().intValue(); workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1))); } }); spinner.setModel(model); totalLabel.setText(" of " + _subsetIndices.size()); if (subsetIndices.isEmpty()) { workbench.setGraph(new EdgeListGraph()); } else { workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0))); } } else if ("Show Unstable".equals(option)) { final List<Integer> _subsetIndices = getUnstableIndices(getStoredGraphs()); subsetIndices.clear(); subsetIndices.addAll(_subsetIndices); int min = subsetIndices.size() == 0 ? 0 : 1; final SpinnerNumberModel model = new SpinnerNumberModel(min, min, subsetIndices.size(), 1); model.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { int index = model.getNumber().intValue(); workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1))); } }); spinner.setModel(model); totalLabel.setText(" of " + _subsetIndices.size()); if (subsetIndices.isEmpty()) { workbench.setGraph(new EdgeListGraph()); } else { workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0))); } } }
private void initComponents() { setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setTitle(I18n.getLocaleString("SETTINGS")); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { formWindowClosing(evt); } }); maxParallelDownloadsLabel = new JLabel(I18n.getLocaleString("MAX_PARALLEL_DOWNLOADS")); maxParallelDownloadsLabel.setFont( new Font(maxParallelDownloadsLabel.getFont().getName(), Font.BOLD, 11)); downloadDirectoryLabel = new JLabel(I18n.getLocaleString("DOWNLOAD_DIRECTORY")); downloadDirectoryLabel.setFont( new Font(downloadDirectoryLabel.getFont().getName(), Font.BOLD, 11)); downloadDirectoryTextField = new JTextField(); downloadDirectoryTextField.setRequestFocusEnabled(false); maxParallelDownloadsSpinner = new JSpinner(); maxParallelDownloadsSpinner.setModel(new SpinnerNumberModel(10, 1, null, 1)); maxParallelDownloadsSpinner.setValue(10); saveSettingsButton = new JButton(I18n.getLocaleString("SAVE_AND_CLOSE")); saveSettingsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { saveSettingsButtonActionPerformed(evt); } }); downloadDirectoryButton = new JButton("..."); downloadDirectoryButton.setFocusable(false); downloadDirectoryButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { downloadDirectoryButtonActionPerformed(evt); } }); fileNameSchemeTextField = new JTextField(); fileNameSchemeTextField.setFont(new Font(Font.MONOSPACED, 0, 12)); filenameSchemeLabel = new JLabel(I18n.getLocaleString("FILENAME_SCHEME")); filenameSchemeLabel.setFont(new Font(filenameSchemeLabel.getFont().getName(), Font.BOLD, 11)); filenameSchemeDescriptionLabel = new JLabel(); filenameSchemeDescriptionLabel.setFont( new Font(filenameSchemeDescriptionLabel.getFont().getName(), Font.PLAIN, 11)); filenameSchemeDescriptionLabel.setLabelFor(fileNameSchemeTextField); String tagStyle = "font-family: Monospaced; font-weight: bold;"; filenameSchemeDescriptionLabel.setText( "<html><body>" + I18n.getLocaleString("FILENAME_SCHEME_DESCRIPTION") .replace("<", "<span style=\"" + tagStyle + "\"><") .replace(">", "></span>") .replaceFirst("/", "<span style=\"" + tagStyle + "\">/</span>") + "</body></html>"); /*searchAutocompleteLabel = new JLabel(I18n.getLocaleString("SEARCH_AUTOCOMPLETE")); searchAutocompleteLabel.setFont(new Font(searchAutocompleteLabel.getFont().getName(), Font.BOLD, 11)); searchAutocompleteCheckBox = new JCheckBox(I18n.getLocaleString("ENABLED")); searchAutocompleteCheckBox.setFont(new Font(searchAutocompleteCheckBox.getFont().getName(), Font.BOLD, 11));*/ startTabLabel = new JLabel(I18n.getLocaleString("START_TAB")); startTabLabel.setFont(new Font(startTabLabel.getFont().getName(), Font.BOLD, 11)); startTabComboBox = new JComboBox(); downloadCompletedLabel = new JLabel(I18n.getLocaleString("DOWNLOAD_COMPLETED")); downloadCompletedLabel.setFont( new Font(downloadCompletedLabel.getFont().getName(), Font.BOLD, 11)); downloadCompletedComboBox = new JComboBox(); languageLabel = new JLabel(I18n.getLocaleString("LANGUAGE")); languageLabel.setFont(new Font(languageLabel.getFont().getName(), Font.BOLD, 11)); languageComboBox = new JComboBox(); DefaultComboBoxModel languageComboBoxModel = new DefaultComboBoxModel(); languageComboBox.setModel(languageComboBoxModel); for (Locale locale : I18n.getLocales()) { languageComboBoxModel.addElement(locale); if (locale.equals(I18n.getCurrentLocale())) { languageComboBox.setSelectedItem(locale); } } languageComboBox.setRenderer( new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); JLabel label = new JLabel(); label.setOpaque(false); if (isSelected) { label.setOpaque(true); label.setForeground(comp.getForeground()); label.setBackground(comp.getBackground()); } else { label.setBackground(comp.getBackground()); } label.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 6)); list.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); list.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); Locale locale = (Locale) value; String languageNameForeign = WordUtils.capitalize(locale.getDisplayName(locale)); String languageNameOwn = WordUtils.capitalize(locale.getDisplayName(I18n.getCurrentLocale())); String languageCode = locale.toString().replace("_", "-"); // fix not existent language names if (locale.toString().equals("en_PT")) { languageNameForeign = "Pirate English"; languageNameOwn = languageNameForeign; } if (locale.toString().equals("lol")) { languageNameForeign = "LOLCAT"; languageNameOwn = languageNameForeign; } // fix ISO3 codes if (locale.toString().equals("iw")) { languageCode = "he"; } URL url = getClass().getResource("/gui/flags/" + languageCode + ".png"); if (url != null) { ImageIcon icon = new ImageIcon(url); icon = GuiUtils.stretchImage(icon, 18, 18, this); label.setIcon(icon); } label.setText( "<html>" + "\u202A" + languageNameForeign + (!isSelected ? "<font color=gray>" : "") + " — " + languageNameOwn + (!isSelected ? "</font>" : "") + "</html>"); return label; } }); resetOriginalSettingsButton = new JButton(I18n.getLocaleString("RESET_ORIGINAL_SETTINGS")); resetOriginalSettingsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { resetOriginalSettingsButtonActionPerformed(evt); } }); fileExistsLabel = new JLabel(); fileExistsLabel.setFont(new Font(fileExistsLabel.getFont().getName(), Font.BOLD, 11)); fileExistsLabel.setText(I18n.getLocaleString("FILE_EXISTS")); fileExistsComboBox = new JComboBox(); proxyHostLabel = new JLabel(I18n.getLocaleString("PROXY_HOST")); proxyHostLabel.setFont(new Font(proxyHostLabel.getFont().getName(), Font.BOLD, 11)); proxyHostTextField = new JTextField(); proxyPortLabel = new JLabel(I18n.getLocaleString("PROXY_PORT")); proxyPortLabel.setFont(new Font(proxyPortLabel.getFont().getName(), Font.BOLD, 11)); proxyPortTextField = new JTextField(); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(GroupLayout.LEADING) .add( layout .createSequentialGroup() .addContainerGap() .add( layout .createParallelGroup(GroupLayout.LEADING) .add( layout .createSequentialGroup() .add( resetOriginalSettingsButton, GroupLayout.PREFERRED_SIZE, 227, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.RELATED) .add( saveSettingsButton, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE)) .add( layout .createSequentialGroup() .add( layout .createParallelGroup(GroupLayout.TRAILING, false) .add( languageLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( fileExistsLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( maxParallelDownloadsLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( filenameSchemeLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( downloadDirectoryLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( startTabLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( downloadCompletedLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( proxyHostLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( proxyPortLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.RELATED) .add( layout .createParallelGroup(GroupLayout.LEADING) .add( layout .createSequentialGroup() .add(downloadDirectoryTextField) .addPreferredGap(LayoutStyle.RELATED) .add( downloadDirectoryButton, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)) .add( GroupLayout.TRAILING, filenameSchemeDescriptionLabel, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .add(GroupLayout.TRAILING, fileNameSchemeTextField) .add( layout .createSequentialGroup() .add( layout .createParallelGroup( GroupLayout.LEADING, false) .add( downloadCompletedComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(startTabComboBox) .add( maxParallelDownloadsSpinner, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE) .add( fileExistsComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( languageComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(proxyHostTextField) .add(proxyPortTextField)) .add(0, 0, Short.MAX_VALUE))))) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(GroupLayout.LEADING) .add( layout .createSequentialGroup() .addContainerGap() .add( layout .createParallelGroup(GroupLayout.BASELINE) .add( downloadDirectoryTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .add(downloadDirectoryButton) .add( downloadDirectoryLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.UNRELATED) .add( layout .createParallelGroup(GroupLayout.LEADING, false) .add(maxParallelDownloadsSpinner) .add( maxParallelDownloadsLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add( layout .createParallelGroup(GroupLayout.BASELINE) .add( filenameSchemeLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add( fileNameSchemeTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.RELATED) .add( filenameSchemeDescriptionLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.UNRELATED) .add( layout .createParallelGroup(GroupLayout.BASELINE) .add( startTabLabel, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE) .add(startTabComboBox)) .add(18, 18, 18) .add( layout .createParallelGroup(GroupLayout.BASELINE) .add(downloadCompletedLabel) .add( downloadCompletedComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .add(15, 15, 15) .add( layout .createParallelGroup(GroupLayout.BASELINE) .add(fileExistsLabel) .add( fileExistsComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add( layout .createParallelGroup(GroupLayout.BASELINE) .add(languageLabel) .add( languageComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add( layout .createParallelGroup(GroupLayout.BASELINE) .add(proxyHostLabel) .add( proxyHostTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add( layout .createParallelGroup(GroupLayout.BASELINE) .add(proxyPortLabel) .add( proxyPortTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .add(50, 50, 50) .add( layout .createParallelGroup(GroupLayout.BASELINE) .add(saveSettingsButton) .add(resetOriginalSettingsButton)) .addContainerGap())); setMinimumSize(new Dimension(700, 620)); pack(); }