List of usage examples for java.awt FlowLayout LEADING
int LEADING
To view the source code for java.awt FlowLayout LEADING.
Click Source Link
From source file:es.emergya.ui.plugins.admin.aux1.RecursoDialog.java
public RecursoDialog(final Recurso rec, final AdminResources adminResources) { super();/* ww w . j a v a 2 s . c o m*/ setAlwaysOnTop(true); setSize(600, 400); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); if (cambios) { int res = JOptionPane.showConfirmDialog(RecursoDialog.this, "Existen cambios sin guardar. Seguro que desea cerrar la ventana?", "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION); if (res != JOptionPane.CANCEL_OPTION) { e.getWindow().dispose(); } } else { e.getWindow().dispose(); } } }); final Recurso r = (rec == null) ? null : RecursoConsultas.get(rec.getId()); if (r != null) { setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador()); } else { setTitle(i18n.getString("Resources.summary.titleWindow.new")); } setIconImage(getBasicWindow().getFrame().getIconImage()); JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); title.setOpaque(false); JLabel labelTitulo = null; if (r != null) { labelTitulo = new JLabel(i18n.getString("Resources.summary"), LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT); } else { labelTitulo = new JLabel(i18n.getString("Resources.cabecera.nuevo"), LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT); } labelTitulo.setFont(LogicConstants.deriveBoldFont(12f)); title.add(labelTitulo); base.add(title); // Nombre JPanel mid = new JPanel(new SpringLayout()); mid.setOpaque(false); mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT)); final JTextField name = new JTextField(25); if (r != null) { name.setText(r.getNombre()); } name.getDocument().addDocumentListener(changeListener); name.setEditable(r == null); mid.add(name); // patrullas final JLabel labelSquads = new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT); mid.add(labelSquads); List<Patrulla> pl = PatrullaConsultas.getAll(); pl.add(0, null); final JComboBox squads = new JComboBox(pl.toArray()); squads.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXX"); squads.addActionListener(changeSelectionListener); squads.setOpaque(false); labelSquads.setLabelFor(squads); if (r != null) { squads.setSelectedItem(r.getPatrullas()); } else { squads.setSelectedItem(null); } squads.setEnabled((r != null && r.getHabilitado() != null) ? r.getHabilitado() : true); mid.add(squads); // // Identificador // mid.setOpaque(false); // mid.add(new JLabel(i18n.getString("Resources.identificador"), // JLabel.RIGHT)); // final JTextField identificador = new JTextField(""); // if (r != null) { // identificador.setText(r.getIdentificador()); // } // identificador.getDocument().addDocumentListener(changeListener); // identificador.setEditable(r == null); // mid.add(identificador); // Espacio en blanco // mid.add(Box.createHorizontalGlue()); // mid.add(Box.createHorizontalGlue()); // Tipo final JLabel labelTipoRecursos = new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT); mid.add(labelTipoRecursos); final JComboBox types = new JComboBox(RecursoConsultas.getTipos()); labelTipoRecursos.setLabelFor(types); types.addActionListener(changeSelectionListener); if (r != null) { types.setSelectedItem(r.getTipo()); } else { types.setSelectedItem(0); } // types.setEditable(true); types.setEnabled(true); mid.add(types); // Estado Eurocop mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT)); final JTextField status = new JTextField(); if (r != null && r.getEstadoEurocop() != null) { status.setText(r.getEstadoEurocop().getIdentificador()); } status.setEditable(false); mid.add(status); // Subflota y patrulla mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT)); final JComboBox subfleets = new JComboBox(FlotaConsultas.getAllHabilitadas()); subfleets.addActionListener(changeSelectionListener); if (r != null) { subfleets.setSelectedItem(r.getFlotas()); } else { subfleets.setSelectedIndex(0); } subfleets.setEnabled(true); subfleets.setOpaque(false); mid.add(subfleets); // Referencia humana mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT)); final JTextField rhumana = new JTextField(); // if (r != null && r.getIncidencias() != null) { // rhumana.setText(r.getIncidencias().getReferenciaHumana()); // } rhumana.setEditable(false); mid.add(rhumana); // dispositivo mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT)); final PlainDocument plainDocument = new PlainDocument() { private static final long serialVersionUID = 4929271093724956016L; @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (this.getLength() + str.length() <= LogicConstants.LONGITUD_ISSI) { super.insertString(offs, str, a); } } }; final JTextField issi = new JTextField(plainDocument, "", LogicConstants.LONGITUD_ISSI); plainDocument.addDocumentListener(changeListener); issi.setEditable(true); mid.add(issi); mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT)); final JCheckBox enabled = new JCheckBox("", true); enabled.addActionListener(changeSelectionListener); enabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (enabled.isSelected()) { squads.setSelectedIndex(0); } squads.setEnabled(enabled.isSelected()); } }); enabled.setEnabled(true); enabled.setOpaque(false); if (r != null) { enabled.setSelected(r.getHabilitado()); } else { enabled.setSelected(true); } if (r != null && r.getDispositivo() != null) { issi.setText( StringUtils.leftPad(String.valueOf(r.getDispositivo()), LogicConstants.LONGITUD_ISSI, '0')); } mid.add(enabled); // Fecha ultimo gps mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT)); JTextField lastGPS = new JTextField(); final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r); if (lastGPSDateForRecurso != null) { lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso)); } lastGPS.setEditable(false); mid.add(lastGPS); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); // informacion adicional JPanel infoPanel = new JPanel(new SpringLayout()); final JTextField info = new JTextField(25); info.getDocument().addDocumentListener(changeListener); infoPanel.add(new JLabel(i18n.getString("Resources.info"))); infoPanel.add(info); infoPanel.setOpaque(false); info.setOpaque(false); SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18); if (r != null) { info.setText(r.getInfoAdicional()); } else { info.setText(""); } info.setEditable(true); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18); base.add(mid); base.add(infoPanel); JPanel buttons = new JPanel(); buttons.setOpaque(false); JButton accept = null; if (r == null) { accept = new JButton("Crear", LogicConstants.getIcon("button_crear")); } else { accept = new JButton("Guardar", LogicConstants.getIcon("button_save")); } accept.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { if (cambios || r == null || r.getId() == null) { boolean shithappens = true; if ((r == null || r.getId() == null)) { // Estamos // creando // uno nuevo if (RecursoConsultas.alreadyExists(name.getText())) { shithappens = false; JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.nombreUnico")); } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT, "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI)); shithappens = false; } else if (issi.getText() != null && issi.getText().length() > 0 && LogicConstants.isNumeric(issi.getText()) && RecursoConsultas.alreadyExists(new Integer(issi.getText()))) { shithappens = false; JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.dispositivoUnico")); } } if (shithappens) { if (name.getText().isEmpty()) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.nombreNulo")); } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT, "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI)); } else if (issi.getText() != null && issi.getText().length() > 0 && LogicConstants.isNumeric(issi.getText()) && r != null && r.getId() != null && RecursoConsultas.alreadyExists(new Integer(issi.getText()), r.getId())) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.issiUnico")); } else if (issi.getText() != null && issi.getText().length() > 0 && !LogicConstants.isNumeric(issi.getText())) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.noNumerico")); // } else if (identificador.getText().isEmpty()) // { // JOptionPane // .showMessageDialog( // RecursoDialog.this, // i18n.getString("admin.recursos.popup.error.identificadorNulo")); } else if (subfleets.getSelectedIndex() == -1) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.noSubflota")); } else if (types.getSelectedItem() == null || types.getSelectedItem().toString().trim().isEmpty()) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.noTipo")); } else { int i = JOptionPane.showConfirmDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.dialogo.guardar.titulo"), i18n.getString("admin.recursos.popup.dialogo.guardar.guardar"), JOptionPane.YES_NO_CANCEL_OPTION); if (i == JOptionPane.YES_OPTION) { Recurso recurso = r; if (r == null) { recurso = new Recurso(); } recurso.setInfoAdicional(info.getText()); if (issi.getText() != null && issi.getText().length() > 0) { recurso.setDispositivo(new Integer(issi.getText())); } else { recurso.setDispositivo(null); } recurso.setFlotas(FlotaConsultas.find(subfleets.getSelectedItem().toString())); if (squads.getSelectedItem() != null && enabled.isSelected()) { recurso.setPatrullas( PatrullaConsultas.find(squads.getSelectedItem().toString())); } else { recurso.setPatrullas(null); } recurso.setNombre(name.getText()); recurso.setHabilitado(enabled.isSelected()); // recurso.setIdentificador(identificador // .getText()); recurso.setTipo(types.getSelectedItem().toString()); dispose(); RecursoAdmin.saveOrUpdate(recurso); adminResources.refresh(null); PluginEventHandler.fireChange(adminResources); } else if (i == JOptionPane.NO_OPTION) { dispose(); } } } } else { log.debug("No hay cambios"); dispose(); } } catch (Throwable t) { log.error("Error guardando un recurso", t); } } }); buttons.add(accept); JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel")); cancelar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (cambios) { if (JOptionPane.showConfirmDialog(RecursoDialog.this, "Existen cambios sin guardar. Seguro que desea cerrar la ventana?", "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION) { dispose(); } } else { dispose(); } } }); buttons.add(cancelar); base.add(buttons); getContentPane().add(base); setLocationRelativeTo(null); cambios = false; if (r == null) { cambios = true; } pack(); int x; int y; Container myParent = getBasicWindow().getPluginContainer().getDetachedTab(0); Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) { x = ((parentSize.width - mySize.width) / 2) + topLeft.x; } else { x = topLeft.x; } if (parentSize.height > mySize.height) { y = ((parentSize.height - mySize.height) / 2) + topLeft.y; } else { y = topLeft.y; } setLocation(x, y); cambios = false; }
From source file:es.emergya.ui.plugins.AdminPanel.java
public AdminPanel(String t, Icon icon, Option myself, boolean canCreateNew, boolean canDelete) { super();// ww w. ja v a2s . com setCanCreateNew(canCreateNew); setCanDelete(canDelete); setLayout(new SpringLayout()); this.father = myself; setBackground(Color.WHITE); // Titulo con icono JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); title = new JLabel(t); title.setIcon(icon); title.setFont(LogicConstants.deriveBoldFont(12f)); title.setBorder(new EmptyBorder(0, 10, 0, 10)); titlePanel.add(title); titlePanel.setOpaque(false); add(titlePanel); Dimension d = titlePanel.getSize(); if (icon != null) d.height = icon.getIconHeight(); titlePanel.setMaximumSize(d); // Controles de "nuevo" "seleccionar todos" etc... JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEADING)); controls.setOpaque(false); final boolean femenino = t.indexOf("atrulla") != -1 || t.indexOf("apa") != -1 || t.indexOf("lota") != -1 || t.indexOf("encia") != -1; if (getCanCreateNew()) { if (femenino) { newButton = new JButton("Nueva", getIcon("button_nuevo")); } else { newButton = new JButton("Nuevo", getIcon("button_nuevo")); } controls.add(newButton); } if (getCanDelete()) { JButton selectAll = new JButton(((femenino) ? "Seleccionar Todas" : "Seleccionar Todos"), getIcon("button_selectall")); selectAll.addActionListener(this); controls.add(selectAll); deselectAll = new JButton(((femenino) ? "Deseleccionar Todas" : "Deseleccionar Todos"), getIcon("button_unselectall")); deselectAll.addActionListener(this); controls.add(deselectAll); JButton deleteAll = new JButton(((femenino) ? "Eliminar Seleccionadas" : "Eliminar Seleccionados"), getIcon("button_delall")); deleteAll.addActionListener(this); controls.add(deleteAll); } d = controls.getSize(); controls.setMaximumSize(d); add(controls); // Tabla tablePanel = new JPanel(new BorderLayout()); tablePanel.setOpaque(false); add(tablePanel); SpringUtilities.makeCompactGrid(this, 3, 1, 0, 0, 0, 0); }
From source file:org.n52.ifgicopter.spf.input.LastDataPostgisInputPlugin.java
@Override protected JPanel makeControlPanel() { if (this.controlPanel == null) { this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); JButton startButton = new JButton("Start"); startButton.addActionListener(new ActionListener() { @Override/*from w ww.j ava 2s.c o m*/ public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { start(); } }); } }); this.controlPanel.add(startButton); JButton stopButton = new JButton("Stop"); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { stop(); } }); } }); this.controlPanel.add(stopButton); JLabel minTimeLabel = new JLabel("Mimium time database queries in milliseconds:"); this.controlPanel.add(minTimeLabel); SpinnerModel model = new SpinnerNumberModel(this.minimumMillisBetweenRequests, 10d, 3600000d, 10d); JSpinner sleepTimeSpinner = new JSpinner(model); sleepTimeSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Object source = e.getSource(); if (source instanceof JSpinner) { final JSpinner spinner = (JSpinner) source; EventQueue.invokeLater(new Runnable() { @Override public void run() { Double value = (Double) spinner.getValue(); value = Double.valueOf(value.doubleValue() * 1000d); setMinimumMillisBetweenRequests(value.longValue()); } }); } else log.warn("Unsupported ChangeEvent, need JSpinner as source: " + e); } }); // catch text change events without loosing the focus // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor(); // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text // field the keystroke was etc. --> too complicated. this.controlPanel.add(sleepTimeSpinner); } return this.controlPanel; }
From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java
private JComponent createToolBars() { final JPanel panel = new JPanel(new BorderLayout()); final JPanel toolbarPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); toolbarPanel.add(createDefinitionToolbar()); toolbarPanel.add(instancesToolbar);/* ww w . j ava2s . co m*/ toolbarPanel.add(animationToolbar); panel.add(toolbarPanel, BorderLayout.CENTER); messagesButton.setContentAreaFilled(false); messagesButton.setFocusable(false); messagesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { showFrame(logFrame); } }); panel.add(messagesButton, BorderLayout.LINE_END); updateMessagesInfo(); return panel; }
From source file:org.n52.ifgicopter.spf.input.HistoryPostgisInputPlugin.java
/** * @return/*from w w w . ja va 2s .c om*/ * */ @Override protected JPanel makeControlPanel() { if (this.controlPanel == null) { this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); JButton startButton = new JButton("Start"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { start(); } }); } }); this.controlPanel.add(startButton); JButton stopButton = new JButton("Stop"); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { stop(); } }); } }); this.controlPanel.add(stopButton); JLabel sleepTimeLabel = new JLabel("Time between points in seconds:"); this.controlPanel.add(sleepTimeLabel); double spinnerMin = 0.1d; double spinnerMax = 10000.0d; SpinnerModel model = new SpinnerNumberModel(2.0d, spinnerMin, spinnerMax, 0.1d); JSpinner sleepTimeSpinner = new JSpinner(model); sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of " + spinnerMin + " to " + spinnerMax + "."); sleepTimeSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Object source = e.getSource(); if (source instanceof JSpinner) { final JSpinner spinner = (JSpinner) source; EventQueue.invokeLater(new Runnable() { @Override public void run() { Double value = (Double) spinner.getValue(); value = Double.valueOf(value.doubleValue() * 1000d); setSleepTimeMillis(value.longValue()); } }); } else log.warn("Unsupported ChangeEvent, need JSpinner as source: " + e); } }); // catch text change events without loosing the focus // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor(); // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text // field the keystroke was etc. --> too complicated. this.controlPanel.add(sleepTimeSpinner); JLabel whereLabel = new JLabel("Where clause: "); this.whereField = new JTextField(this.where); this.whereField.setPreferredSize(new Dimension(200, 20)); this.whereField.setToolTipText("Insert a valid SQL 'WHERE' clause here."); this.whereButton = new JButton("Load data"); this.whereButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { updateWhere(); loadAllData(); } }); } }); this.controlPanel.add(whereLabel); this.controlPanel.add(this.whereField); this.controlPanel.add(this.whereButton); } return this.controlPanel; }
From source file:org.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.java
private JPanel createServerStatus() { JPanel serverStatusPanel = new JPanel(new GridBagLayout()); JLabel serverStatusLabel = new JLabel("Local update: "); updateServerButton = new JButton(); serverStatus = new JLabel(); final HyperlinkLabel link = new HyperlinkLabel(""); link.setIcon(AllIcons.General.Help_small); link.setUseIconAsLink(true);/*from ww w .j a v a 2s. c om*/ link.addHyperlinkListener(new HyperlinkAdapter() { @Override protected void hyperlinkActivated(HyperlinkEvent e) { final JLabel label = new JLabel( "<html>Click to fetch data from the selected SonarQube server, such as the list of projects,<br>" + " rules, quality profiles, etc. This needs to be done before being able to select a project."); label.setBorder(HintUtil.createHintBorder()); label.setBackground(HintUtil.INFORMATION_COLOR); label.setOpaque(true); HintManager.getInstance().showHint(label, RelativePoint.getSouthWestOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1); } }); JPanel flow1 = new JPanel(new FlowLayout(FlowLayout.LEADING)); flow1.add(serverStatusLabel); flow1.add(serverStatus); JPanel flow2 = new JPanel(new FlowLayout(FlowLayout.LEADING)); flow2.add(updateServerButton); flow2.add(link); serverStatusPanel.add(flow1, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.LINE_START, 0, new Insets(0, 0, 0, 0), 0, 0)); serverStatusPanel.add(flow2, new GridBagConstraints(1, 0, 1, 1, 0.5, 1, GridBagConstraints.LINE_START, 0, new Insets(0, 0, 0, 0), 0, 0)); updateServerButton.setAction(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { actionUpdateServerTask(false); } }); updateServerButton.setText("Update binding"); updateServerButton.setToolTipText("Update local data: quality profile, settings, ..."); JPanel alignedPanel = new JPanel(new BorderLayout()); alignedPanel.add(serverStatusPanel, BorderLayout.NORTH); return alignedPanel; }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * @return/*from w ww . j a va 2 s .c om*/ */ private Component createTopPanel() { JPanel topPanel = new JPanel(new GridBagLayout()); List<ConfiguredLanguage> configuredLanguages = ConfiguredLanguage.getConfiguredLanguages(); languageSelector = new JComboBox(configuredLanguages.toArray()); languageSelector.setSelectedIndex(0); languageSelector.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setSyntaxStyle(); } }); currentFileLabel = new JLabel(); final JFileChooser jFileChooser = new JFileChooser(); jFileChooser.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Tank XML Files"; } @Override public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith("_ts.xml"); } }); JButton button = new JButton("Select File..."); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int showOpenDialog = jFileChooser.showOpenDialog(ScriptFilterRunner.this); if (showOpenDialog == JFileChooser.APPROVE_OPTION) { loadTSXml(jFileChooser.getSelectedFile()); } } }); xmlViewDialog = new XMlViewDialog(this); xmlViewDialog.setSize(new Dimension(800, 500)); showXmlBT = new JButton("Show XML"); showXmlBT.setEnabled(false); showXmlBT.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayXml(); } }); saveBT = new JButton("Save XML"); saveBT.setEnabled(false); saveBT.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveXml(); } }); JPanel xmlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 20)); xmlPanel.add(button); xmlPanel.add(showXmlBT); xmlPanel.add(saveBT); int y = 0; topPanel.add(new JLabel("Current Tank XML: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(currentFileLabel, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); topPanel.add(new JLabel("Select Script Language: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(languageSelector, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); topPanel.add(new JLabel("Select Tank XML: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(xmlPanel, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); return topPanel; }
From source file:org.n52.ifgicopter.spf.input.GpxInputPlugin.java
/** * @return/*from w w w.j av a 2 s . c om*/ * */ private JPanel makeControlPanel() { if (this.controlPanel == null) { this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); JButton startButton = new JButton("Start"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { start(); } }); } }); this.controlPanel.add(startButton); JButton stopButton = new JButton("Stop"); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { stop(); } }); } }); this.controlPanel.add(stopButton); JButton selectFileButton = new JButton("Select GPX File"); selectFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectGpxFileAction(); } }); this.controlPanel.add(selectFileButton); JLabel sleepTimeLabel = new JLabel("Time between points in seconds:"); this.controlPanel.add(sleepTimeLabel); double spinnerMin = 0.5d; double spinnerMax = 10000.0d; SpinnerModel model = new SpinnerNumberModel(2.0d, spinnerMin, spinnerMax, 0.1d); JSpinner sleepTimeSpinner = new JSpinner(model); sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of " + spinnerMin + " to " + spinnerMax + "."); sleepTimeSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Object source = e.getSource(); if (source instanceof JSpinner) { final JSpinner spinner = (JSpinner) source; EventQueue.invokeLater(new Runnable() { @Override public void run() { Double value = (Double) spinner.getValue(); value = Double.valueOf(value.doubleValue() * SECONDS_TO_MILLISECONDS); setSleepTimeMillis(value.longValue()); } }); } else getLog().warn("Unsupported ChangeEvent, need JSpinner as source: " + e); } }); // catch text change events without loosing the focus // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor(); // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text // field the keystroke was etc. --> too complicated. this.controlPanel.add(sleepTimeSpinner); } return this.controlPanel; }
From source file:bio.gcat.gui.BDATool.java
public BDATool() { super("BDA Tool - " + AnalysisTool.NAME); setIconImage(getImage("bda")); setMinimumSize(new Dimension(660, 400)); setPreferredSize(new Dimension(1020, 400)); setSize(getPreferredSize());// w w w.ja v a2 s . c o m setLocationByPlatform(true); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); menubar = new JMenuBar(); menu = new JMenu[4]; menubar.add(menu[0] = new JMenu("File")); menubar.add(menu[1] = new JMenu("Edit")); menubar.add(menu[2] = new JMenu("Window")); menubar.add(menu[3] = new JMenu("Help")); setJMenuBar(menubar); menu[0].add(createMenuItem("Open...", "folder-horizontal-open", KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK), ACTION_OPEN, this)); menu[0].add(createMenuItem("Save As...", "disk--arrow", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), ACTION_SAVE_AS, this)); menu[0].add(createSeparator()); menu[0].add(createMenuItem("Close Window", "cross", ACTION_CLOSE, this)); menu[1].add(createMenuText("Binary Dichotomic Algorithm:")); menu[1].add(createMenuItem("Add", KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_ADD, this)); menu[1].add(createMenuItem("Edit...", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_EDIT, this)); menu[1].add( createMenuItem("Remove", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), ACTION_BDA_REMOVE, this)); menu[1].add(createMenuItem("Clear", ACTION_BDAS_CLEAR, this)); menu[1].add(seperateMenuItem(createMenuItem("Move Up", KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_UP, this))); menu[1].add(createMenuItem("Move Down", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_DOWN, this)); menu[2].add(createMenuItem("Preferences", ACTION_PREFERENCES, this)); menu[3].add(createMenuItem("About BDA Tool", "bda", ACTION_ABOUT, this)); for (String action : new String[] { ACTION_BDA_EDIT, ACTION_BDA_REMOVE, ACTION_BDAS_CLEAR, ACTION_BDA_MOVE_UP, ACTION_BDA_MOVE_DOWN }) getMenuItem(menubar, action).setEnabled(false); getMenuItem(menubar, ACTION_PREFERENCES).setEnabled(false); registerKeyStroke(getRootPane(), KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "remove", new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (bdaPanel.table.hasFocus()) removeBinaryDichotomicAlgorithm(); } }); toolbar = new JToolBar[1]; toolbar[0] = new JToolBar("File"); toolbar[0].add(createToolbarButton("Open File", "folder-horizontal-open", ACTION_OPEN, this)); toolbar[0].add(createToolbarButton("Save As File", "disk--arrow", ACTION_SAVE_AS, this)); toolbars = new JPanel(new FlowLayout(FlowLayout.LEADING)); for (JToolBar toolbar : toolbar) toolbars.add(toolbar); add(toolbars, BorderLayout.NORTH); add(createSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, true, 360, 0.195, new JScrollPane(bdaPanel = new BinaryDichotomicAlgorithmPanel()), new JScrollPane(tablePanel = new JPanel(new BorderLayout()))), BorderLayout.CENTER); add(bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)), BorderLayout.SOUTH); status = new JLabel(); status.setBorder(new EmptyBorder(0, 5, 0, 5)); status.setHorizontalAlignment(JLabel.RIGHT); bottom.add(status); ((ListTableModel<?>) bdaPanel.table.getModel()).addListDataListener(this); bdaPanel.table.getSelectionModel().addListSelectionListener(this); revalidateGeneticCodeTable(); }
From source file:org.n52.ifgicopter.spf.input.FakeInputPlugin.java
/** * /* w w w . j a v a 2 s .c o m*/ * @return */ private JPanel makeControlPanel() { if (this.controlPanel == null) { this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); JButton startButton = new JButton("Start"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { start(); } }); } }); this.controlPanel.add(startButton); JButton stopButton = new JButton("Stop"); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { stop(); } }); } }); this.controlPanel.add(stopButton); JLabel sleepTimeLabel = new JLabel("Time between points in seconds:"); this.controlPanel.add(sleepTimeLabel); double spinnerMin = 0.1d; double spinnerMax = 10000.0d; SpinnerModel model = new SpinnerNumberModel(DEFAULT_INTERVAL_MILLIS / SECONDS_TO_MILLISECONDS, spinnerMin, spinnerMax, 0.1d); JSpinner sleepTimeSpinner = new JSpinner(model); sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of " + spinnerMin + " to " + spinnerMax + "."); sleepTimeSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Object source = e.getSource(); if (source instanceof JSpinner) { final JSpinner spinner = (JSpinner) source; EventQueue.invokeLater(new Runnable() { @Override public void run() { Double value = (Double) spinner.getValue(); value = Double.valueOf(value.doubleValue() * SECONDS_TO_MILLISECONDS); FakeInputPlugin.this.sleepTimeMillis = value.longValue(); } }); } else log.warn("Unsupported ChangeEvent, need JSpinner as source: " + e); } }); // catch text change events without loosing the focus // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor(); // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text // field the keystroke was etc. --> too complicated. this.controlPanel.add(sleepTimeSpinner); } return this.controlPanel; }