List of usage examples for javax.swing JDialog dispose
public void dispose()
From source file:com.marginallyclever.makelangelo.MainGUI.java
protected void AdjustGraphics() { final Preferences graphics_prefs = Preferences.userRoot().node("DrawBot").node("Graphics"); final JDialog driver = new JDialog(mainframe, translator.get("MenuGraphicsTitle"), true); driver.setLayout(new GridBagLayout()); //final JCheckBox allow_metrics = new JCheckBox(String.valueOf("I want to add the distance drawn to the // total")); //allow_metrics.setSelected(allowMetrics); final JCheckBox show_pen_up = new JCheckBox(translator.get("MenuGraphicsPenUp")); final JCheckBox antialias_on = new JCheckBox(translator.get("MenuGraphicsAntialias")); final JCheckBox speed_over_quality = new JCheckBox(translator.get("MenuGraphicsSpeedVSQuality")); final JCheckBox draw_all_while_running = new JCheckBox(translator.get("MenuGraphicsDrawWhileRunning")); show_pen_up.setSelected(graphics_prefs.getBoolean("show pen up", false)); antialias_on.setSelected(graphics_prefs.getBoolean("antialias", true)); speed_over_quality.setSelected(graphics_prefs.getBoolean("speed over quality", true)); draw_all_while_running.setSelected(graphics_prefs.getBoolean("Draw all while running", true)); final JButton cancel = new JButton(translator.get("Cancel")); final JButton save = new JButton(translator.get("Save")); GridBagConstraints c = new GridBagConstraints(); //c.gridwidth=4; c.gridx=0; c.gridy=0; driver.add(allow_metrics,c); int y = 0;/*from w w w. j a v a 2 s. c o m*/ c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y; driver.add(show_pen_up, c); y++; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y; driver.add(draw_all_while_running, c); y++; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y; driver.add(antialias_on, c); y++; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y; driver.add(speed_over_quality, c); y++; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 2; c.gridy = y; driver.add(save, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 3; c.gridy = y; driver.add(cancel, c); ActionListener driveButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { Object subject = e.getSource(); if (subject == save) { //allowMetrics = allow_metrics.isSelected(); graphics_prefs.putBoolean("show pen up", show_pen_up.isSelected()); graphics_prefs.putBoolean("antialias", antialias_on.isSelected()); graphics_prefs.putBoolean("speed over quality", speed_over_quality.isSelected()); graphics_prefs.putBoolean("Draw all while running", draw_all_while_running.isSelected()); previewPane.setShowPenUp(show_pen_up.isSelected()); driver.dispose(); } if (subject == cancel) { driver.dispose(); } } }; save.addActionListener(driveButtons); cancel.addActionListener(driveButtons); driver.getRootPane().setDefaultButton(save); driver.pack(); driver.setVisible(true); }
From source file:net.sf.jabref.util.Util.java
/** * Automatically add links for this set of entries, based on the globally stored list of external file types. The * entries are modified, and corresponding UndoEdit elements added to the NamedCompound given as argument. * Furthermore, all entries which are modified are added to the Set of entries given as an argument. * <p>//from w ww. j ava 2s .c o m * The entries' bibtex keys must have been set - entries lacking key are ignored. The operation is done in a new * thread, which is returned for the caller to wait for if needed. * * @param entries A collection of BibEntry objects to find links for. * @param ce A NamedCompound to add UndoEdit elements to. * @param changedEntries MODIFIED, optional. A Set of BibEntry objects to which all modified entries is added. * This is used for status output and debugging * @param singleTableModel UGLY HACK. The table model to insert links into. Already existing links are not * duplicated or removed. This parameter has to be null if entries.count() != 1. The hack has been * introduced as a bibtexentry does not (yet) support the function getListTableModel() and the * FileListEntryEditor editor holds an instance of that table model and does not reconstruct it after the * search has succeeded. * @param metaData The MetaData providing the relevant file directory, if any. * @param callback An ActionListener that is notified (on the event dispatch thread) when the search is finished. * The ActionEvent has id=0 if no new links were added, and id=1 if one or more links were added. This * parameter can be null, which means that no callback will be notified. * @param diag An instantiated modal JDialog which will be used to display the progress of the autosetting. This * parameter can be null, which means that no progress update will be shown. * @return the thread performing the autosetting */ public static Runnable autoSetLinks(final Collection<BibEntry> entries, final NamedCompound ce, final Set<BibEntry> changedEntries, final FileListTableModel singleTableModel, final MetaData metaData, final ActionListener callback, final JDialog diag) { final Collection<ExternalFileType> types = ExternalFileTypes.getInstance().getExternalFileTypeSelection(); if (diag != null) { final JProgressBar prog = new JProgressBar(JProgressBar.HORIZONTAL, 0, types.size() - 1); final JLabel label = new JLabel(Localization.lang("Searching for files")); prog.setIndeterminate(true); prog.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diag.setTitle(Localization.lang("Autosetting links")); diag.getContentPane().add(prog, BorderLayout.CENTER); diag.getContentPane().add(label, BorderLayout.SOUTH); diag.pack(); diag.setLocationRelativeTo(diag.getParent()); } Runnable r = new Runnable() { @Override public void run() { // determine directories to search in List<File> dirs = new ArrayList<>(); List<String> dirsS = metaData.getFileDirectory(Globals.FILE_FIELD); for (String dirs1 : dirsS) { dirs.add(new File(dirs1)); } // determine extensions Collection<String> extensions = new ArrayList<>(); for (final ExternalFileType type : types) { extensions.add(type.getExtension()); } // Run the search operation: Map<BibEntry, List<File>> result; if (Globals.prefs.getBoolean(JabRefPreferences.AUTOLINK_USE_REG_EXP_SEARCH_KEY)) { String regExp = Globals.prefs.get(JabRefPreferences.REG_EXP_SEARCH_EXPRESSION_KEY); result = RegExpFileSearch.findFilesForSet(entries, extensions, dirs, regExp); } else { result = FileUtil.findAssociatedFiles(entries, extensions, dirs); } boolean foundAny = false; // Iterate over the entries: for (Entry<BibEntry, List<File>> entryFilePair : result.entrySet()) { FileListTableModel tableModel; String oldVal = entryFilePair.getKey().getField(Globals.FILE_FIELD); if (singleTableModel == null) { tableModel = new FileListTableModel(); if (oldVal != null) { tableModel.setContent(oldVal); } } else { assert entries.size() == 1; tableModel = singleTableModel; } List<File> files = entryFilePair.getValue(); for (File f : files) { f = FileUtil.shortenFileName(f, dirsS); boolean alreadyHas = false; //System.out.println("File: "+f.getPath()); for (int j = 0; j < tableModel.getRowCount(); j++) { FileListEntry existingEntry = tableModel.getEntry(j); //System.out.println("Comp: "+existingEntry.getLink()); if (new File(existingEntry.link).equals(f)) { alreadyHas = true; break; } } if (!alreadyHas) { foundAny = true; ExternalFileType type; Optional<String> extension = FileUtil.getFileExtension(f); if (extension.isPresent()) { type = ExternalFileTypes.getInstance().getExternalFileTypeByExt(extension.get()); } else { type = new UnknownExternalFileType(""); } FileListEntry flEntry = new FileListEntry(f.getName(), f.getPath(), type); tableModel.addEntry(tableModel.getRowCount(), flEntry); String newVal = tableModel.getStringRepresentation(); if (newVal.isEmpty()) { newVal = null; } if (ce != null) { // store undo information UndoableFieldChange change = new UndoableFieldChange(entryFilePair.getKey(), Globals.FILE_FIELD, oldVal, newVal); ce.addEdit(change); } // hack: if table model is given, do NOT modify entry if (singleTableModel == null) { entryFilePair.getKey().setField(Globals.FILE_FIELD, newVal); } if (changedEntries != null) { changedEntries.add(entryFilePair.getKey()); } } } } // handle callbacks and dialog // FIXME: The ID signals if action was successful :/ final int id = foundAny ? 1 : 0; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (diag != null) { diag.dispose(); } if (callback != null) { callback.actionPerformed(new ActionEvent(this, id, "")); } } }); } }; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // show dialog which will be hidden when the task is done if (diag != null) { diag.setVisible(true); } } }); return r; }
From source file:lcmc.gui.resources.ServiceInfo.java
/** Adds resource agent RA menu item. It is called in swing thread. */ private void addResourceAgentMenu(final ResourceAgent ra, final MyListModel<MyMenuItem> dlm, final Point2D pos, final List<JDialog> popups, final JCheckBox colocationWi, final JCheckBox orderWi, final boolean testOnly) { final MyMenuItem mmi = new MyMenuItem(ra.getMenuName(), null, null, new AccessMode(ConfigData.AccessType.ADMIN, false), new AccessMode(ConfigData.AccessType.OP, false)) { private static final long serialVersionUID = 1L; @Override/*from w ww . jav a 2 s. c om*/ public void action() { hidePopup(); for (final JDialog otherP : popups) { otherP.dispose(); } if (ra.isLinbitDrbd() && !getBrowser().linbitDrbdConfirmDialog()) { return; } else if (ra.isHbDrbd() && !getBrowser().hbDrbdConfirmDialog()) { return; } addServicePanel(ra, getPos(), colocationWi.isSelected(), orderWi.isSelected(), true, false, testOnly); getBrowser().getCRMGraph().repaint(); } }; mmi.setPos(pos); dlm.addElement(mmi); }
From source file:lcmc.gui.resources.ServiceInfo.java
/** Adds existing service menu item. */ protected void addExistingServiceMenuItem(final String name, final ServiceInfo asi, final MyListModel<MyMenuItem> dlm, final Map<MyMenuItem, ButtonCallback> callbackHash, final MyList<MyMenuItem> list, final JCheckBox colocationWi, final JCheckBox orderWi, final List<JDialog> popups, final boolean testOnly) { final MyMenuItem mmi = new MyMenuItem(name, null, null, new AccessMode(ConfigData.AccessType.ADMIN, false), new AccessMode(ConfigData.AccessType.OP, false)) { private static final long serialVersionUID = 1L; @Override/*from w ww . j av a 2s. c om*/ public void action() { final Thread thread = new Thread(new Runnable() { @Override public void run() { hidePopup(); for (final JDialog otherP : popups) { otherP.dispose(); } addServicePanel(asi, null, colocationWi.isSelected(), orderWi.isSelected(), true, getBrowser().getDCHost(), testOnly); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { repaint(); } }); } }); thread.start(); } }; dlm.addElement(mmi); final ClusterBrowser.ClMenuItemCallback mmiCallback = getBrowser().new ClMenuItemCallback(list, null) { @Override public void action(final Host dcHost) { addServicePanel(asi, null, colocationWi.isSelected(), orderWi.isSelected(), true, dcHost, true); /* test only */ } }; callbackHash.put(mmi, mmiCallback); }
From source file:com.marginallyclever.makelangelo.MainGUI.java
protected void AdjustSounds() { final JDialog driver = new JDialog(mainframe, translator.get("MenuSoundsTitle"), true); driver.setLayout(new GridBagLayout()); final JTextField sound_connect = new JTextField(prefs.get("sound_connect", ""), 32); final JTextField sound_disconnect = new JTextField(prefs.get("sound_disconnect", ""), 32); final JTextField sound_conversion_finished = new JTextField(prefs.get("sound_conversion_finished", ""), 32); final JTextField sound_drawing_finished = new JTextField(prefs.get("sound_drawing_finished", ""), 32); final JButton change_sound_connect = new JButton(translator.get("MenuSoundsConnect")); final JButton change_sound_disconnect = new JButton(translator.get("MenuSoundsDisconnect")); final JButton change_sound_conversion_finished = new JButton(translator.get("MenuSoundsFinishConvert")); final JButton change_sound_drawing_finished = new JButton(translator.get("MenuSoundsFinishDraw")); //final JCheckBox allow_metrics = new JCheckBox(String.valueOf("I want to add the distance drawn to the // total")); //allow_metrics.setSelected(allowMetrics); final JButton cancel = new JButton(translator.get("Cancel")); final JButton save = new JButton(translator.get("Save")); GridBagConstraints c = new GridBagConstraints(); //c.gridwidth=4; c.gridx=0; c.gridy=0; driver.add(allow_metrics,c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1;//from w w w .j a v a 2 s .c o m c.gridx = 0; c.gridy = 3; driver.add(change_sound_connect, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = 3; driver.add(sound_connect, c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = 4; driver.add(change_sound_disconnect, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = 4; driver.add(sound_disconnect, c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = 5; driver.add(change_sound_conversion_finished, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = 5; driver.add(sound_conversion_finished, c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = 6; driver.add(change_sound_drawing_finished, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = 6; driver.add(sound_drawing_finished, c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 2; c.gridy = 12; driver.add(save, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 3; c.gridy = 12; driver.add(cancel, c); ActionListener driveButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { Object subject = e.getSource(); if (subject == change_sound_connect) sound_connect.setText(SelectFile()); if (subject == change_sound_disconnect) sound_disconnect.setText(SelectFile()); if (subject == change_sound_conversion_finished) sound_conversion_finished.setText(SelectFile()); if (subject == change_sound_drawing_finished) sound_drawing_finished.setText(SelectFile()); if (subject == save) { //allowMetrics = allow_metrics.isSelected(); prefs.put("sound_connect", sound_connect.getText()); prefs.put("sound_disconnect", sound_disconnect.getText()); prefs.put("sound_conversion_finished", sound_conversion_finished.getText()); prefs.put("sound_drawing_finished", sound_drawing_finished.getText()); machineConfiguration.SaveConfig(); driver.dispose(); } if (subject == cancel) { driver.dispose(); } } }; change_sound_connect.addActionListener(driveButtons); change_sound_disconnect.addActionListener(driveButtons); change_sound_conversion_finished.addActionListener(driveButtons); change_sound_drawing_finished.addActionListener(driveButtons); save.addActionListener(driveButtons); cancel.addActionListener(driveButtons); driver.getRootPane().setDefaultButton(save); driver.pack(); driver.setVisible(true); }
From source file:userinterface.graph.Histogram.java
/** * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram * to plot data on/* ww w .ja va 2s . c o m*/ * * @param defaultSeriesName * @param handler instance of {@link GUIGraphHandler} * @param minVal the min value in data cache * @param maxVal the max value in data cache * @return Either a new instance of a Histogram or an old one depending on what the user selects */ public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler, double minVal, double maxVal) { // make sure that the probabilities are valid if (maxVal > 1.0) maxVal = 1.0; if (minVal < 0.0) minVal = 0.0; // set properties for the dialog JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true); dialog.setLayout(new BorderLayout()); JPanel p1 = new JPanel(new FlowLayout()); p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Number of buckets")); JPanel p2 = new JPanel(new FlowLayout()); p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1)); buckets.setToolTipText("Select the number of buckets for this Histogram"); // provides the ability to select a new or an old histogram to plot the series on JTextField seriesName = new JTextField(defaultSeriesName); JRadioButton newSeries = new JRadioButton("New Histogram"); JRadioButton existing = new JRadioButton("Existing Histogram"); newSeries.setSelected(true); JPanel seriesSelectPanel = new JPanel(); seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS)); JPanel seriesTypeSelect = new JPanel(new FlowLayout()); JPanel seriesOptionsPanel = new JPanel(new FlowLayout()); seriesTypeSelect.add(newSeries); seriesTypeSelect.add(existing); JComboBox<String> seriesOptions = new JComboBox<>(); seriesOptionsPanel.add(seriesOptions); seriesSelectPanel.add(seriesTypeSelect); seriesSelectPanel.add(seriesOptionsPanel); seriesSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to")); // provides ability to select the min/max range of the plot JLabel minValsLabel = new JLabel("Min range:"); JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01)); minVals.setToolTipText("Does not allow value more than the min value in the probabilities"); JLabel maxValsLabel = new JLabel("Max range:"); JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01)); maxVals.setToolTipText("Does not allow value less than the max value in the probabilities"); JPanel minMaxPanel = new JPanel(); minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS)); JPanel leftValsPanel = new JPanel(new BorderLayout()); JPanel rightValsPanel = new JPanel(new BorderLayout()); minMaxPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range")); leftValsPanel.add(minValsLabel, BorderLayout.WEST); leftValsPanel.add(minVals, BorderLayout.CENTER); rightValsPanel.add(maxValsLabel, BorderLayout.WEST); rightValsPanel.add(maxVals, BorderLayout.CENTER); minMaxPanel.add(leftValsPanel); minMaxPanel.add(rightValsPanel); // fill the old histograms in the property dialog boolean found = false; for (int i = 0; i < handler.getNumModels(); i++) { if (handler.getModel(i) instanceof Histogram) { seriesOptions.addItem(handler.getGraphName(i)); found = true; } } existing.setEnabled(found); seriesOptions.setEnabled(false); // the bottom panel JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton ok = new JButton("Plot"); JButton cancel = new JButton("Cancel"); // bind keyboard keys to plot and cancel buttons to improve usability ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = -7324877661936685228L; @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ok"); cancel.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = 2642213543774356676L; @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); //Action listener for the new series radio button newSeries.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newSeries.isSelected()) { existing.setSelected(false); seriesOptions.setEnabled(false); buckets.setEnabled(true); buckets.setToolTipText("Select the number of buckets for this Histogram"); minVals.setEnabled(true); maxVals.setEnabled(true); } } }); //Action listener for the existing series radio button existing.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existing.isSelected()) { newSeries.setSelected(false); seriesOptions.setEnabled(true); buckets.setEnabled(false); minVals.setEnabled(false); maxVals.setEnabled(false); buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram"); } } }); //Action listener for the plot button ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); if (newSeries.isSelected()) { hist = new Histogram(); hist.setNumOfBuckets((int) buckets.getValue()); hist.setIsNew(true); } else if (existing.isSelected()) { String HistName = (String) seriesOptions.getSelectedItem(); hist = (Histogram) handler.getModel(HistName); hist.setIsNew(false); } key = hist.addSeries(seriesName.getText()); if (minVals.isEnabled() && maxVals.isEnabled()) { hist.setMinProb((double) minVals.getValue()); hist.setMaxProb((double) maxVals.getValue()); } } }); //Action listener for the cancel button cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); hist = null; } }); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { hist = null; } }); p1.add(buckets, BorderLayout.CENTER); p2.add(seriesName, BorderLayout.CENTER); options.add(ok); options.add(cancel); // add everything to the main panel of the dialog JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(seriesSelectPanel); mainPanel.add(p1); mainPanel.add(p2); mainPanel.add(minMaxPanel); // add main panel to the dialog dialog.add(mainPanel, BorderLayout.CENTER); dialog.add(options, BorderLayout.SOUTH); // set dialog properties dialog.setSize(320, 290); dialog.setLocationRelativeTo(GUIPrism.getGUI()); dialog.setVisible(true); // return the user selected Histogram with the properties set return new Pair<Histogram, SeriesKey>(hist, key); }
From source file:com.marginallyclever.makelangelo.MainGUI.java
protected boolean ChooseImageConversionOptions(boolean isDXF) { final JDialog driver = new JDialog(mainframe, translator.get("ConversionOptions"), true); driver.setLayout(new GridBagLayout()); final String[] choices = machineConfiguration.getKnownMachineNames(); final JComboBox<String> machine_choice = new JComboBox<String>(choices); machine_choice.setSelectedIndex(machineConfiguration.getCurrentMachineIndex()); final JSlider input_paper_margin = new JSlider(JSlider.HORIZONTAL, 0, 50, 100 - (int) (machineConfiguration.paper_margin * 100)); input_paper_margin.setMajorTickSpacing(10); input_paper_margin.setMinorTickSpacing(5); input_paper_margin.setPaintTicks(false); input_paper_margin.setPaintLabels(true); //final JCheckBox allow_metrics = new JCheckBox(String.valueOf("I want to add the distance drawn to the // total")); //allow_metrics.setSelected(allowMetrics); final JCheckBox reverse_h = new JCheckBox(translator.get("FlipForGlass")); reverse_h.setSelected(machineConfiguration.reverseForGlass); final JButton cancel = new JButton(translator.get("Cancel")); final JButton save = new JButton(translator.get("Start")); String[] filter_names = new String[image_converters.size()]; Iterator<Filter> fit = image_converters.iterator(); int i = 0;//from w ww. j a v a2s. c om while (fit.hasNext()) { Filter f = fit.next(); filter_names[i++] = f.GetName(); } final JComboBox<String> input_draw_style = new JComboBox<String>(filter_names); input_draw_style.setSelectedIndex(GetDrawStyle()); GridBagConstraints c = new GridBagConstraints(); //c.gridwidth=4; c.gridx=0; c.gridy=0; driver.add(allow_metrics,c); int y = 0; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("MenuLoadMachineConfig")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 2; c.gridx = 1; c.gridy = y++; driver.add(machine_choice, c); if (!isDXF) { c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("ConversionStyle")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = y++; driver.add(input_draw_style, c); } c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("PaperMargin")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = y++; driver.add(input_paper_margin, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y++; driver.add(reverse_h, c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 2; c.gridy = y; driver.add(save, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 3; c.gridy = y++; driver.add(cancel, c); startConvertingNow = false; ActionListener driveButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { Object subject = e.getSource(); if (subject == save) { long new_uid = Long.parseLong(choices[machine_choice.getSelectedIndex()]); machineConfiguration.LoadConfig(new_uid); SetDrawStyle(input_draw_style.getSelectedIndex()); machineConfiguration.paper_margin = (100 - input_paper_margin.getValue()) * 0.01; machineConfiguration.reverseForGlass = reverse_h.isSelected(); machineConfiguration.SaveConfig(); // if we aren't connected, don't show the new if (connectionToRobot != null && !connectionToRobot.isRobotConfirmed()) { // Force update of graphics layout. previewPane.updateMachineConfig(); // update window title mainframe.setTitle( translator.get("TitlePrefix") + Long.toString(machineConfiguration.robot_uid) + translator.get("TitleNotConnected")); } startConvertingNow = true; driver.dispose(); } if (subject == cancel) { driver.dispose(); } } }; save.addActionListener(driveButtons); cancel.addActionListener(driveButtons); driver.getRootPane().setDefaultButton(save); driver.pack(); driver.setVisible(true); return startConvertingNow; }
From source file:ffx.ui.MainPanel.java
/** * <p>/* w ww . j a va 2s .c om*/ * initialize</p> */ public void initialize() { if (init) { return; } init = true; String dir = System.getProperty("user.dir", FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath()); setCWD(new File(dir)); locale = new FFXLocale("en", "US"); JDialog splashScreen = null; ClassLoader loader = getClass().getClassLoader(); if (!GraphicsEnvironment.isHeadless()) { // Splash Screen JFrame.setDefaultLookAndFeelDecorated(true); splashScreen = new JDialog(frame, false); ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png")); JLabel ffxLabel = new JLabel(logo); ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); Container contentpane = splashScreen.getContentPane(); contentpane.setLayout(new BorderLayout()); contentpane.add(ffxLabel, BorderLayout.CENTER); splashScreen.setUndecorated(true); splashScreen.pack(); Dimension screenDimension = getToolkit().getScreenSize(); Dimension splashDimension = splashScreen.getSize(); splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2, (screenDimension.height - splashDimension.height) / 2); splashScreen.setResizable(false); splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); splashScreen.setVisible(true); // Make all pop-up Menus Heavyweight so they play nicely with Java3D JPopupMenu.setDefaultLightWeightPopupEnabled(false); } // Create the Root Node dataRoot = new MSRoot(); Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); statusLabel = new JLabel(" "); JLabel stepLabel = new JLabel(" "); stepLabel.setHorizontalAlignment(JLabel.RIGHT); JLabel energyLabel = new JLabel(" "); energyLabel.setHorizontalAlignment(JLabel.RIGHT); JPanel statusPanel = new JPanel(new GridLayout(1, 3)); statusPanel.setBorder(bb); statusPanel.add(statusLabel); statusPanel.add(stepLabel); statusPanel.add(energyLabel); if (!GraphicsEnvironment.isHeadless()) { GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D(); template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED); GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getBestConfiguration(template3D); graphicsCanvas = new GraphicsCanvas(gc, this); graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel); } // Initialize various Panels hierarchy = new Hierarchy(this); hierarchy.setStatus(statusLabel, stepLabel, energyLabel); keywordPanel = new KeywordPanel(this); modelingPanel = new ModelingPanel(this); JPanel treePane = new JPanel(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); treePane.add(scrollPane, BorderLayout.CENTER); tabbedPane = new JTabbedPane(); ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png")); ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png")); ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png")); tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel); tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel); tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel); tabbedPane.addChangeListener(this); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane); /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, graphicsPanel); */ splitPane.setResizeWeight(0.25); splitPane.setOneTouchExpandable(true); setLayout(new BorderLayout()); add(splitPane, BorderLayout.CENTER); if (!GraphicsEnvironment.isHeadless()) { mainMenu = new MainMenu(this); add(mainMenu.getToolBar(), BorderLayout.NORTH); getModelingShell(); loadPrefs(); SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this)); splashScreen.dispose(); } }
From source file:interfaces.InterfazPrincipal.java
private void TablaDeFacturaProductoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TablaDeFacturaProductoMouseClicked final int fila = TablaDeFacturaProducto.getSelectedRow(); final DefaultTableModel modeloTabla = (DefaultTableModel) TablaDeFacturaProducto.getModel(); //int identificacion = (int) TablaDeFacturaProducto.getValueAt(fila, 0); // TODO add your handling code here: final JDialog dialogoEdicionProducto = new JDialog(this); dialogoEdicionProducto.setTitle("Editar producto"); dialogoEdicionProducto.setSize(250, 150); dialogoEdicionProducto.setResizable(false); JPanel panelDialogo = new JPanel(); panelDialogo.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; JLabel editarTextoPrincipalDialogo = new JLabel("Editar producto"); c.gridx = 0;// ww w .j a va 2 s. c o m c.gridy = 0; c.gridwidth = 3; c.insets = new Insets(15, 40, 10, 0); Font textoGrande = new Font("Arial", 1, 18); editarTextoPrincipalDialogo.setFont(textoGrande); panelDialogo.add(editarTextoPrincipalDialogo, c); c.insets = new Insets(0, 0, 0, 0); c.gridwidth = 0; c.gridy = 1; c.gridx = 0; JLabel textoUnidades = new JLabel("Unidades"); panelDialogo.add(textoUnidades, c); c.gridy = 1; c.gridx = 1; c.gridwidth = 2; final JTextField valorUnidades = new JTextField(); valorUnidades.setText(String.valueOf(modeloTabla.getValueAt(fila, 4))); panelDialogo.add(valorUnidades, c); c.gridwidth = 1; c.gridy = 2; c.gridx = 0; JButton guardarCambios = new JButton("Guardar"); panelDialogo.add(guardarCambios, c); c.gridy = 2; c.gridx = 1; JButton eliminarProducto = new JButton("Eliminar"); panelDialogo.add(eliminarProducto, c); c.gridy = 2; c.gridx = 2; JButton botonCancelar = new JButton("Cerrar"); panelDialogo.add(botonCancelar, c); botonCancelar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialogoEdicionProducto.dispose(); } }); eliminarProducto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double precio = (double) modeloTabla.getValueAt(fila, 6); double precioActual = Double.parseDouble(valorActualFactura.getText()); precioActual -= precio; valorActualFactura.setText(String.valueOf(precioActual)); modeloTabla.removeRow(fila); dialogoEdicionProducto.dispose(); } }); guardarCambios.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int numeroUnidades = Integer.parseInt(valorUnidades.getText()); modeloTabla.setValueAt(numeroUnidades, fila, 4); double precioARestar = (double) modeloTabla.getValueAt(fila, 6); double valorUnitario = Double.parseDouble((String) modeloTabla.getValueAt(fila, 5)); double precioNuevo = valorUnitario * numeroUnidades; modeloTabla.setValueAt(precioNuevo, fila, 6); double precioActual = Double.parseDouble(valorActualFactura.getText()); precioActual -= precioARestar; precioActual += precioNuevo; valorActualFactura.setText(String.valueOf(precioActual)); dialogoEdicionProducto.dispose(); } catch (Exception eve) { JOptionPane.showMessageDialog(dialogoEdicionProducto, "Por favor ingrese un valor numrico"); } } }); dialogoEdicionProducto.add(panelDialogo); dialogoEdicionProducto.setVisible(true); }
From source file:interfaces.InterfazPrincipal.java
private void BotonBuscarClienteSaldoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonBuscarClienteSaldoActionPerformed String nombreCliente = nombreClienteBusquedaSaldo.getText(); //08-11-2014 listar clientes por nombre ControladorCliente controladorCliente = new ControladorCliente(); ArrayList<Cliente> listaClientes = new ArrayList<>(); if (nombreCliente.equals("")) { listaClientes = controladorCliente.obtenerClientes(); } else {//ww w . j a v a2 s . c om listaClientes = controladorCliente.obtenerClientes(nombreCliente, 0); } //08-11-2014 Crear dialogo de bsqueda final JDialog dialogoEditar = new JDialog(this); dialogoEditar.setTitle("Buscar clientes"); dialogoEditar.setSize(300, 300); dialogoEditar.setResizable(false); JPanel panelDialogo = new JPanel(); panelDialogo.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; JLabel ediitarTextoPrincipalDialogo = new JLabel("Buscar cliente"); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.insets = new Insets(10, 60, 10, 10); Font textoGrande = new Font("Arial", 1, 16); ediitarTextoPrincipalDialogo.setFont(textoGrande); panelDialogo.add(ediitarTextoPrincipalDialogo, c); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.insets = new Insets(10, 10, 10, 10); final JTable tablaDialogo = new JTable(); DefaultTableModel modeloTabla = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //all cells false return false; } }; ; modeloTabla.addColumn("Identificacin"); modeloTabla.addColumn("Nombre"); //LLenar tabla for (int i = 0; i < listaClientes.size(); i++) { Object[] data = { "1", "2" }; data[0] = listaClientes.get(i).getCliente_id(); data[1] = listaClientes.get(i).getNombre(); modeloTabla.addRow(data); } tablaDialogo.setModel(modeloTabla); tablaDialogo.getColumn("Identificacin").setMinWidth(110); tablaDialogo.getColumn("Nombre").setMinWidth(110); tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroll = new JScrollPane(tablaDialogo); scroll.setPreferredSize(new Dimension(220, 150)); panelDialogo.add(scroll, c); c.insets = new Insets(0, 0, 0, 10); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; JButton botonGuardarClienteDialogo = new JButton("Elegir"); panelDialogo.add(botonGuardarClienteDialogo, c); c.gridx = 1; c.gridy = 2; c.gridwidth = 1; JButton botonCerrarClienteDialogo = new JButton("Cancelar"); panelDialogo.add(botonCerrarClienteDialogo, c); dialogoEditar.add(panelDialogo); dialogoEditar.setVisible(true); botonCerrarClienteDialogo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialogoEditar.dispose(); } }); botonGuardarClienteDialogo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = tablaDialogo.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(dialogoEditar, "Por favor seleccione una fila"); } else { Object identificacionCliente = tablaDialogo.getValueAt(row, 0); mostrarIdentificacionCliente.setText(String.valueOf(identificacionCliente)); String nombreClientePago = String.valueOf(tablaDialogo.getValueAt(row, 1)); //Limitar a 15 caracteres if (nombreClientePago.length() >= 15) { nombreClientePago = nombreClientePago.substring(0, 12); } textoPersonaSaldo.setText(nombreClientePago); DefaultTableModel modeloClientes = (DefaultTableModel) TablaDeSaldoClientes.getModel(); for (int i = 0; i < modeloClientes.getRowCount(); i++) { modeloClientes.removeRow(i); } modeloClientes.setRowCount(0); ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura(); //SELECT * FROM Flujo_Factura where factura_id in (select factura_id from Factura where cliente_id = 1130614506); ArrayList<String[]> flujosCliente = controladorFlujoFactura.getTodosFlujo_Factura( " where factura_id in (select factura_id from Factura where cliente_id = " + String.valueOf(identificacionCliente) + " and estado=\"fiado\") order by factura_id"); double pago = 0.0; for (int i = 0; i < flujosCliente.size(); i++) { String[] datos = flujosCliente.get(i); TablaDeSaldoClientes.setModel(modeloClientes); NumberFormat formatter = new DecimalFormat("#0"); String valorMovimiento = String.valueOf(formatter.format(Double.parseDouble(datos[4]))); Object[] rowData = { datos[1], datos[2], datos[3], valorMovimiento }; if (datos[2].equals("deuda")) { pago += Double.parseDouble(datos[4]); } else { pago -= Double.parseDouble(datos[4]); } modeloClientes.addRow(rowData); } TablaDeSaldoClientes.setModel(modeloClientes); NumberFormat formatter = new DecimalFormat("#0"); textoTotalDebe.setText(String.valueOf(formatter.format(pago))); dialogoEditar.dispose(); //Mostrar en table de clientes los datos botonRegistrarAbono.setEnabled(true); } } }); }