List of usage examples for javax.swing JTextField setEditable
@BeanProperty(description = "specifies if the text can be edited") public void setEditable(boolean b)
TextComponent
should be editable. From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java
/** * Helper factory method for creating selectable text labels (for copy & paste support) * * @param text//from w ww .j av a 2 s .c o m * the string that will be selectable * @return the selectable text component */ protected JComponent createTextLabel(String text) { Preconditions.checkNotNull(text); JTextField textLabel = new JTextField(text); textLabel.setEditable(false); textLabel.setBorder(null); textLabel.setOpaque(false); textLabel.setHorizontalAlignment(JTextField.CENTER); addCopyMenu(textLabel); return textLabel; }
From source file:es.emergya.ui.gis.popups.SummaryDialog.java
public SummaryDialog(Recurso r) { super();/*from w w w.ja va2s . co m*/ r = (r == null) ? null : RecursoConsultas.getByIdentificador(r.getIdentificador()); setAlwaysOnTop(true); setResizable(false); setName(r.getIdentificador()); setBackground(Color.WHITE); setSize(600, 400); setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); base.setBackground(Color.WHITE); r = RecursoConsultas.getByIdentificador(r.getIdentificador()); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel labelTitle = new JLabel(i18n.getString("Resources.summary.title") + " " + r.getIdentificador(), LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT); labelTitle.setFont(LogicConstants.deriveBoldFont(12f)); title.setBackground(Color.WHITE); title.add(labelTitle); base.add(title); // Nombre JPanel mid = new JPanel(new SpringLayout()); mid.setBackground(Color.WHITE); mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT)); JTextField name = new JTextField(25); if (r != null) name.setText(r.getIdentificador()); name.setEditable(false); mid.add(name); // Patrulla mid.add(new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT)); // JComboBox squads = new // JComboBox(PatrullaConsultas.getAll().toArray()); JTextField squads = new JTextField(r.getPatrullas() == null ? null : r.getPatrullas().getNombre()); // squads.setSelectedItem(r.getPatrullas()); squads.setEditable(false); squads.setColumns(21); // squads.setEnabled(false); mid.add(squads); // Tipo mid.add(new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT)); JTextField types = new JTextField(r.getTipo()); types.setEditable(false); mid.add(types); // Estado Eurocop mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT)); JTextField status = new JTextField(); if (r.getEstadoEurocop() != null) status.setText(r.getEstadoEurocop().getIdentificador()); status.setEditable(false); mid.add(status); // Subflota mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT)); JTextField subfleets = new JTextField(r.getFlotas() == null ? null : r.getFlotas().getNombre()); subfleets.setEditable(false); mid.add(subfleets); // Referencia Humana mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT)); JTextField rHumana = new JTextField(); // if (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)); JTextField issi = new JTextField(); issi.setEditable(false); mid.add(issi); mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT)); JCheckBox enabled = new JCheckBox("", true); enabled.setEnabled(false); enabled.setOpaque(false); if (r.getDispositivo() != null) { final String valueOf = String.valueOf(r.getDispositivo()); try { issi.setText(String.format(FORMAT, r.getDispositivo())); } catch (Throwable t) { issi.setText(valueOf); } enabled.setSelected(r.getHabilitado()); } 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()); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18); base.add(mid); // informacion adicional JPanel infoPanel = new JPanel(new SpringLayout()); JTextField info = new JTextField(25); info.setText(r.getInfoAdicional()); info.setEditable(false); infoPanel.setOpaque(false); infoPanel.add(new JLabel(i18n.getString("Resources.info"))); infoPanel.add(info); SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18); base.add(infoPanel); JPanel buttons = new JPanel(); buttons.setBackground(Color.WHITE); JButton accept = new JButton(i18n.getString("Buttons.ok"), LogicConstants.getIcon("button_accept")); accept.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); buttons.add(accept); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.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); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } }
From source file:regresiones.RegresionMultiple.java
private void pintar(Double[] Yestimada, JTabbedPane resultados, Double[][] auxiliar) { // mostramos resultados para la pestaa resultados*********************************************************************** JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); JLabel titulo = new JLabel("Resultados");//creamos el titulo panel.add(titulo, BorderLayout.PAGE_START);//lo agregamos al inicio jtable = new JTable();//creamos la tabla a mostrar jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true)); jtable.setFont(new java.awt.Font("Arial", 1, 14)); jtable.setColumnSelectionAllowed(true); jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR)); jtable.setInheritsPopupMenu(true);//w w w . j a v a2 s. c o m jtable.setMinimumSize(new java.awt.Dimension(80, 80)); String[] titulos = { "X1", "X2", "Y", "Y estimada", "X1^2", "X2^2", "X1*Y", "X2*Y", "Y-Y estimada" };//los titulos de la tabla arregloFinal = new String[N][9]; DecimalFormat formato = new DecimalFormat("0.00"); for (int i = 0; i < N; i++) {//armamos el arreglo arregloFinal[i][0] = datos[i][0] + ""; arregloFinal[i][1] = datos[i][1] + ""; arregloFinal[i][2] = datos[i][2] + ""; arregloFinal[i][3] = formato.format(Yestimada[i]); arregloFinal[i][4] = formato.format(auxiliar[i][0]); arregloFinal[i][5] = formato.format(auxiliar[i][1]); arregloFinal[i][6] = formato.format(auxiliar[i][2]); arregloFinal[i][7] = formato.format(auxiliar[i][3]); arregloFinal[i][8] = formato.format(auxiliar[i][4]); } DefaultTableModel TableModel = new DefaultTableModel(arregloFinal, titulos); jtable.setModel(TableModel); JScrollPane jScrollPane1 = new JScrollPane(); jScrollPane1.setViewportView(jtable); jtable.getColumnModel().getSelectionModel() .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION); panel.add(jScrollPane1, BorderLayout.CENTER); JPanel panel2 = new JPanel(new GridLayout(0, 6));//creo un panel con rejilla de 4 columnas JLabel etiquetaN = new JLabel("N"); JTextField cajaN = new JTextField(); cajaN.setText(N + ""); cajaN.setEditable(false); JLabel etiquetaK = new JLabel("K"); JTextField cajaK = new JTextField(); cajaK.setText("2"); cajaK.setEditable(false); JLabel etiquetab0 = new JLabel("b0"); JTextField cajab0 = new JTextField(); cajab0.setText(formato.format(b0) + ""); cajab0.setEditable(false); JLabel etiquetab1 = new JLabel("b1"); JTextField cajab1 = new JTextField(); cajab1.setText(formato.format(b1) + ""); cajab1.setEditable(false); JLabel etiquetab2 = new JLabel("b2"); JTextField cajab2 = new JTextField(); cajab2.setText(formato.format(b2) + ""); cajab2.setEditable(false); JLabel etiquetaSe = new JLabel("Se"); JTextField cajaSe = new JTextField(); cajaSe.setText(Se + ""); cajaSe.setEditable(false); cajaSe.setAutoscrolls(true); JButton botonI = new JButton("Exportar a PDF"); botonI.addActionListener(this); panel2.add(etiquetaN); panel2.add(cajaN); panel2.add(etiquetaK); panel2.add(cajaK); panel2.add(etiquetab2); panel2.add(etiquetab0); panel2.add(cajab0); panel2.add(etiquetab1); panel2.add(cajab1); panel2.add(etiquetab2); panel2.add(cajab2); panel2.add(etiquetaSe); panel2.add(cajaSe); panel2.add(botonI); panel.add(panel2, BorderLayout.SOUTH);//agrego el panel2 con rejilla en el panel principal al sur resultados.addTab("resultado", panel); //************************************************************************************** //intervalos de confianza JPanel intervalos = new JPanel(new BorderLayout()); JPanel variables = new JPanel(new GridLayout(0, 2)); JLabel variableX1 = new JLabel("X1"); cajaVariableX1 = new JTextField(); JLabel variableX2 = new JLabel("X2"); cajaVariableX2 = new JTextField(); boton = new JButton("calcular"); boton.addActionListener(this); JLabel variableEfectividad = new JLabel("Efectividad"); String[] efectividades = { "80", "85", "90", "95", "99" }; combo = new JComboBox(efectividades); variables.add(variableX1); variables.add(cajaVariableX1); variables.add(variableX2); variables.add(cajaVariableX2); variables.add(variableEfectividad); variables.add(combo); variables.add(boton); intervalos.add(variables, BorderLayout.NORTH); jtable2 = new JTable();//creamos la tabla a mostrar jtable2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true)); jtable2.setFont(new java.awt.Font("Arial", 1, 14)); jtable2.setColumnSelectionAllowed(true); jtable2.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR)); jtable2.setInheritsPopupMenu(true); jtable2.setMinimumSize(new java.awt.Dimension(80, 80)); String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla String[][] pruebaIntervalos = { { "", "", "" } }; DefaultTableModel TableModel2 = new DefaultTableModel(pruebaIntervalos, titulos2); jtable2.setModel(TableModel2); JScrollPane jScrollPane2 = new JScrollPane(); jScrollPane2.setViewportView(jtable2); jtable2.getColumnModel().getSelectionModel() .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION); intervalos.add(jScrollPane2, BorderLayout.CENTER); resultados.addTab("intervalos", intervalos); //*************************************************************************** JPanel graficas = new JPanel(new GridLayout(0, 1)); XYDataset dataset = createSampleDataset(Yestimada, 1); JFreeChart chart = ChartFactory.createXYLineChart("Grafica 1 - X1", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, true); plot.setRenderer(renderer); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); graficas.add(chartPanel);//agregamos la primer grafica //********** creamos la segunda grafica XYDataset dataset2 = createSampleDataset(Yestimada, 2); JFreeChart chart2 = ChartFactory.createXYLineChart("Grafica 2 -X2", "X", "Y", dataset2, PlotOrientation.VERTICAL, true, false, false); XYPlot plot2 = (XYPlot) chart2.getPlot(); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, true); renderer2.setSeriesShapesVisible(0, true); renderer2.setSeriesLinesVisible(1, true); renderer2.setSeriesShapesVisible(1, true); plot2.setRenderer(renderer2); final ChartPanel chartPanel2 = new ChartPanel(chart2); chartPanel2.setPreferredSize(new java.awt.Dimension(500, 300)); graficas.add(chartPanel2); resultados.addTab("graficas", graficas); }
From source file:es.emergya.ui.gis.ControlPanel.java
public ControlPanel(final CustomMapView view) { super(new FlowLayout(FlowLayout.LEADING, 12, 0)); this.view = view; // Posicion: panel con un label de icono y un textfield JPanel posPanel = new JPanel(); posPanel.setOpaque(true);/*from w w w.j ava2 s. c o m*/ posPanel.setVisible(true); JLabel mouseLocIcon = new JLabel(LogicConstants.getIcon("map_icon_coordenadas")); posPanel.add(mouseLocIcon); final JTextField posField = new JTextField(15); posField.setEditable(false); posField.setBorder(null); posField.setForeground(UIManager.getColor("Label.foreground")); posField.setFont(UIManager.getFont("Label.font")); posPanel.add(posField); view.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { LatLon ll = ((ICustomMapView) e.getSource()).getLatLon(e.getX(), e.getY()); String position = ""; String format = LogicConstants.get("FORMATO_COORDENADAS_MAPA", "UTM"); if (format.equals(LogicConstants.COORD_UTM)) { UTM u = new UTM(LogicConstants.getInt("ZONA_UTM")); EastNorth en = u.latlon2eastNorth(ll); position = String.format("x: %.1f y: %.1f", en.getX(), en.getY()); } else { position = String.format("Lat: %.4f Lon: %.4f", ll.lat(), ll.lon()); } posField.setText(position); validate(); } @Override public void mouseDragged(MouseEvent e) { } }); posPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); add(posPanel); // Panel de centrado: label, desplegable y parte cambiante JPanel centerPanel = new JPanel(); centerPanel.add(new JLabel(i18n.getString("map.centerIn"))); centerOptions = new JComboBox(new String[] { i18n.getString("map.street"), i18n.getString("map.resource"), i18n.getString("map.incidence"), i18n.getString("map.location") }); centerPanel.add(centerOptions); centerData = new JPanel(new CardLayout()); centerPanel.add(centerData); JPanel centerStreet = new JPanel(); street = new JTextField(30); street.setName(i18n.getString("map.street")); autocompleteKeyListener = new AutocompleteKeyListener(street); street.addKeyListener(autocompleteKeyListener); street.addActionListener(this); centerStreet.add(street); centerData.add(centerStreet, i18n.getString("map.street")); JPanel centerResource = new JPanel(); resources = new JComboBox(avaliableResources); resources.setName(i18n.getString("map.resource")); resources.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); resources.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { isComboResourcesShowing = true; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { isComboResourcesShowing = false; } @Override public void popupMenuCanceled(PopupMenuEvent e) { // view.repaint(); } }); centerResource.add(resources); centerData.add(centerResource, i18n.getString("map.resource")); centerResource = new JPanel(); incidences = new JComboBox(avaliableIncidences); incidences.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); incidences.setName(i18n.getString("map.incidence")); incidences.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { isComboIncidencesShowing = true; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { isComboIncidencesShowing = false; } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); centerResource.add(incidences); centerData.add(centerResource, i18n.getString("map.incidence")); JPanel centerLocation = new JPanel(); cx = new JTextField(10); cx.setName("x"); cx.addActionListener(this); centerLocation.add(cx); cy = new JTextField(10); cy.setName("y"); cy.addActionListener(this); centerLocation.add(cy); centerData.add(centerLocation, i18n.getString("map.location")); centerOptions.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { ((CardLayout) centerData.getLayout()).show(centerData, (String) e.getItem()); } }); JButton centerButton = new JButton(i18n.getString("map.center")); centerButton.addActionListener(this); centerPanel.add(centerButton); add(centerPanel); }
From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java
/** * {@inheritDoc}/* ww w . j a v a 2s.c o m*/ */ @Override public void actionPerformed(final ActionEvent aE) { JPanel newPanel = new JPanel(new GridLayout(2, 2)); newPanel.add(new JLabel("GUID:")); final JTextField disabledIDInput = new JTextField(myAccount.getId()); final JPopupMenu accountIDPopupMenu = createAccountIDPopupMenu(); disabledIDInput.setEditable(false); disabledIDInput.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(final MouseEvent arg0) { if (arg0.isPopupTrigger()) { accountIDPopupMenu.show(disabledIDInput, arg0.getX(), arg0.getY()); } } @Override public void mousePressed(final MouseEvent arg0) { if (arg0.isPopupTrigger()) { accountIDPopupMenu.show(disabledIDInput, arg0.getX(), arg0.getY()); } } }); newPanel.add(disabledIDInput); newPanel.add(new JLabel("name:")); final JTextField nameInput = new JTextField(myAccount.getName()); nameInput.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent aE) { myAccount.setName(nameInput.getText()); } }); newPanel.add(nameInput); myFrame = new JFrame(myAccount.getName()); myFrame.getContentPane().setLayout(new BorderLayout()); myFrame.getContentPane().add(newPanel, BorderLayout.NORTH); myFrame.getContentPane().add(getButtonsPanel(), BorderLayout.SOUTH); myFrame.getContentPane().add(getMySettingsPanel(), BorderLayout.CENTER); myFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); myFrame.pack(); myFrame.setVisible(true); }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Hist2DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);// ww w . j a va 2 s . c o m listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:regresiones.EstadisticaDescriptiva.java
private void pintar(JTabbedPane panel1, Double[][] tabla) { JPanel panel = new JPanel(new BorderLayout()); //tabla/*from www .ja va 2s. c o m*/ jtable = new JTable();//creamos la tabla a mostrar jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true)); jtable.setFont(new java.awt.Font("Arial", 1, 14)); jtable.setColumnSelectionAllowed(true); jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR)); jtable.setInheritsPopupMenu(true); jtable.setMinimumSize(new java.awt.Dimension(80, 80)); String[] titulos = { "i", "Li", "Ls", "Xi", "Fi", "Fa", "Fr", "Fra", "XiFi", "|Xi-X|Fi", "(Xi-X)^2 Fi" };//los titulos de la tabla DefaultTableModel TableModel = new DefaultTableModel(formato(tabla), titulos); jtable.setModel(TableModel); JScrollPane jScrollPane1 = new JScrollPane(); jScrollPane1.setViewportView(jtable); jtable.getColumnModel().getSelectionModel() .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION); panel.add(jScrollPane1, BorderLayout.CENTER); //campos JPanel medidas = new JPanel(new GridLayout(0, 6)); JLabel etiquetaMax = new JLabel("Maximo"); JTextField cajaMax = new JTextField(); cajaMax.setText(MAXIMO + ""); cajaMax.setEditable(false); JLabel etiquetaMin = new JLabel("Minimo"); JTextField cajaMin = new JTextField(); cajaMin.setText(MINIMO + ""); cajaMin.setEditable(false); JLabel etiquetaN = new JLabel("N"); JTextField cajaN = new JTextField(); cajaN.setText(N + ""); cajaN.setEditable(false); JLabel etiquetaRango = new JLabel("Rango"); JTextField cajaRango = new JTextField(); cajaRango.setText(MAXIMO - MINIMO + ""); cajaRango.setEditable(false); JLabel etiquetaIntervalos = new JLabel("Intervalos"); JTextField cajaIntervalos = new JTextField(); cajaIntervalos.setText(INTERVALOS + ""); cajaIntervalos.setEditable(false); JLabel etiquetaAmp = new JLabel("Amplitud"); JTextField cajaAmp = new JTextField(); cajaAmp.setText(AMPLITUD + ""); cajaAmp.setEditable(false); JLabel etiquetaRamp = new JLabel("Rango Ampliado"); JTextField cajaRamp = new JTextField(); cajaRamp.setText(RANGOAMPLIADO + ""); cajaRamp.setEditable(false); JLabel etiquetaDifRam = new JLabel("Dif Rangos"); JTextField cajaDifRam = new JTextField(); cajaDifRam.setText(DIFERENCIARANGOS + ""); cajaDifRam.setEditable(false); JLabel etiquetaLIPI = new JLabel("LIPI"); JTextField cajaLIPI = new JTextField(); cajaLIPI.setText(LIPI + ""); cajaLIPI.setEditable(false); JLabel etiquetaLSUI = new JLabel("LSUI"); JTextField cajaLSUI = new JTextField(); cajaLSUI.setText(LSUI + ""); cajaLSUI.setEditable(false); JLabel etiquetaDM = new JLabel("Desv media"); JTextField cajaDM = new JTextField(); cajaDM.setText(DM + ""); cajaDM.setEditable(false); JLabel etiquetaV = new JLabel("Varianza"); JTextField cajaV = new JTextField(); cajaV.setText(VARIANZA + ""); cajaV.setEditable(false); JLabel etiquetaDE = new JLabel("Desv estandar"); JTextField cajaDE = new JTextField(); cajaDE.setText(DE + ""); cajaDE.setEditable(false); JLabel etiquetaMe = new JLabel("Media"); JTextField cajaMe = new JTextField(); cajaMe.setText(MEDIA + ""); cajaMe.setEditable(false); JLabel etiquetaMEDIANA = new JLabel("Mediana"); JTextField cajaMEDIANA = new JTextField(); cajaMEDIANA.setText(MEDIANA + ""); cajaMEDIANA.setEditable(false); JLabel etiquetaModa = new JLabel("Moda"); JTextField cajaModa = new JTextField(); cajaModa.setText(MODA + ""); cajaModa.setEditable(false); JButton boton = new JButton("Exportar a PDF"); boton.addActionListener(this); medidas.add(etiquetaMax); medidas.add(cajaMax); medidas.add(etiquetaMin); medidas.add(cajaMin); medidas.add(etiquetaN); medidas.add(cajaN); medidas.add(etiquetaRango); medidas.add(cajaRango); //Jhony medidas.add(etiquetaIntervalos); medidas.add(cajaIntervalos); medidas.add(etiquetaAmp); medidas.add(cajaAmp); medidas.add(etiquetaRamp); medidas.add(cajaRamp); medidas.add(etiquetaDifRam); medidas.add(cajaDifRam); medidas.add(etiquetaLIPI); //lipi medidas.add(cajaLIPI); medidas.add(etiquetaLSUI); medidas.add(cajaLSUI); medidas.add(etiquetaDM); //DESVIACION MEDIA medidas.add(cajaDM); medidas.add(etiquetaV); //VARIANZA medidas.add(cajaV); medidas.add(etiquetaDE); //DESVIACION ESTANDAR medidas.add(cajaDE); medidas.add(etiquetaMe); //MEDIA medidas.add(cajaMe); medidas.add(etiquetaMEDIANA); // mediana medidas.add(cajaMEDIANA); medidas.add(etiquetaModa); //moda medidas.add(cajaModa); medidas.add(boton); //SECCION DE GRAFICAS JFreeChart Grafica; DefaultCategoryDataset Datos = new DefaultCategoryDataset(); //Buscar las pociciones de LI LS Fa // 0,1 0,2 0,5 //agregar los valores a la grafica for (int i = 0; i < INTERVALOS; i++) { Datos.addValue(tabla[i][3], "frecuencia", tabla[i][1] + " - " + tabla[i][2]); } Grafica = ChartFactory.createLineChart("Histograma", "Frecuencia", "Li Ls", Datos, PlotOrientation.VERTICAL, true, true, false); ChartPanel p = new ChartPanel(Grafica); // termina seccion de grafica panel.add(medidas, BorderLayout.SOUTH); //panel.add(jScrollPane1, BorderLayout.CENTER); panel1.addTab("Resultados", panel); panel1.addTab("Grafica", p); }
From source file:net.pandoragames.far.ui.swing.dialog.SettingsDialog.java
private void init() { this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); this.setResizable(false); JPanel basePanel = new JPanel(); basePanel.setLayout(new BoxLayout(basePanel, BoxLayout.Y_AXIS)); basePanel.setBorder(//from w w w. j av a2s .c om BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); registerCloseWindowKeyListener(basePanel); // sink for error messages MessageLabel errorField = new MessageLabel(); errorField.setMinimumSize(new Dimension(100, swingConfig.getStandardComponentHight())); errorField.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); TwoComponentsPanel lineError = new TwoComponentsPanel(errorField, Box.createRigidArea(new Dimension(1, swingConfig.getStandardComponentHight()))); lineError.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineError); // character set JLabel labelCharset = new JLabel(swingConfig.getLocalizer().localize("label.default-characterset")); labelCharset.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(labelCharset); JComboBox listCharset = new JComboBox(swingConfig.getCharsetList().toArray()); listCharset.setAlignmentX(Component.LEFT_ALIGNMENT); listCharset.setSelectedItem(swingConfig.getDefaultCharset()); listCharset.setEditable(true); listCharset.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); listCharset.addActionListener(new CharacterSetListener(errorField)); listCharset.setEditor(new CharacterSetEditor(errorField)); basePanel.add(listCharset); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // select the group selector JPanel selectorPanel = new JPanel(); selectorPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); selectorPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // linePattern.setAlignmentX( Component.LEFT_ALIGNMENT ); JLabel labelSelector = new JLabel(swingConfig.getLocalizer().localize("label.group-ref-indicator")); selectorPanel.add(labelSelector); JComboBox selectorBox = new JComboBox(FARConfig.GROUPREFINDICATORLIST); selectorBox.setSelectedItem(Character.toString(groupReference)); selectorBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JComboBox cbox = (JComboBox) event.getSource(); String indicator = (String) cbox.getSelectedItem(); groupReference = indicator.charAt(0); } }); selectorPanel.add(selectorBox); basePanel.add(selectorPanel); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // checkbox DO BACKUP JCheckBox doBackupFlag = new JCheckBox(swingConfig.getLocalizer().localize("label.create-backup")); doBackupFlag.setAlignmentX(Component.LEFT_ALIGNMENT); doBackupFlag.setHorizontalTextPosition(SwingConstants.LEADING); doBackupFlag.setSelected(replaceForm.isDoBackup()); doBackupFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { doBackup = ItemEvent.SELECTED == event.getStateChange(); backupFlagEvent = event; } }); basePanel.add(doBackupFlag); JTextField backupDirPathTextField = new JTextField(); backupDirPathTextField.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH, swingConfig.getStandardComponentHight())); backupDirPathTextField.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); backupDirPathTextField.setText(backupDirectory.getPath()); backupDirPathTextField.setToolTipText(backupDirectory.getPath()); backupDirPathTextField.setEditable(false); JButton openBaseDirFileChooserButton = new JButton(swingConfig.getLocalizer().localize("button.browse")); BrowseButtonListener backupDirButtonListener = new BrowseButtonListener(backupDirPathTextField, new BackUpDirectoryRepository(swingConfig, findForm, replaceForm, errorField), swingConfig.getLocalizer().localize("label.choose-backup-directory")); openBaseDirFileChooserButton.addActionListener(backupDirButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(backupDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineBaseDir); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JPanel fileInfoPanel = new JPanel(); fileInfoPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), swingConfig.getLocalizer().localize("label.default-file-info"))); fileInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.setLayout(new BoxLayout(fileInfoPanel, BoxLayout.Y_AXIS)); JLabel fileInfoLabel = new JLabel(swingConfig.getLocalizer().localize("message.displayed-in-info-column")); fileInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.add(fileInfoLabel); fileInfoPanel.add(Box.createHorizontalGlue()); JRadioButton nothingRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.nothing")); nothingRadio.setAlignmentX(Component.LEFT_ALIGNMENT); nothingRadio.setActionCommand(SwingConfig.DefaultFileInfo.NOTHING.name()); nothingRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.NOTHING); fileInfoOptions.add(nothingRadio); fileInfoPanel.add(nothingRadio); JRadioButton readOnlyRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.read-only-warning")); readOnlyRadio.setAlignmentX(Component.LEFT_ALIGNMENT); readOnlyRadio.setActionCommand(SwingConfig.DefaultFileInfo.READONLY.name()); readOnlyRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.READONLY); fileInfoOptions.add(readOnlyRadio); fileInfoPanel.add(readOnlyRadio); JRadioButton sizeRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.filesize")); sizeRadio.setAlignmentX(Component.LEFT_ALIGNMENT); sizeRadio.setActionCommand(SwingConfig.DefaultFileInfo.SIZE.name()); sizeRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.SIZE); fileInfoOptions.add(sizeRadio); fileInfoPanel.add(sizeRadio); JCheckBox showPlainBytesFlag = new JCheckBox( " " + swingConfig.getLocalizer().localize("label.show-plain-bytes")); showPlainBytesFlag.setAlignmentX(Component.LEFT_ALIGNMENT); showPlainBytesFlag.setHorizontalTextPosition(SwingConstants.LEADING); showPlainBytesFlag.setSelected(swingConfig.isShowPlainBytes()); showPlainBytesFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { showBytes = ItemEvent.SELECTED == event.getStateChange(); } }); fileInfoPanel.add(showPlainBytesFlag); JRadioButton lastModifiedRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.last-modified")); lastModifiedRadio.setAlignmentX(Component.LEFT_ALIGNMENT); lastModifiedRadio.setActionCommand(SwingConfig.DefaultFileInfo.LAST_MODIFIED.name()); lastModifiedRadio .setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.LAST_MODIFIED); fileInfoOptions.add(lastModifiedRadio); fileInfoPanel.add(lastModifiedRadio); basePanel.add(fileInfoPanel); // buttons JPanel buttonPannel = new JPanel(); buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT); buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // cancel JButton cancelButton = new JButton(swingConfig.getLocalizer().localize("button.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SettingsDialog.this.dispose(); } }); buttonPannel.add(cancelButton); // save JButton saveButton = new JButton(swingConfig.getLocalizer().localize("button.save")); saveButton.addActionListener(new SaveButtonListener()); buttonPannel.add(saveButton); this.getRootPane().setDefaultButton(saveButton); this.add(basePanel); this.add(buttonPannel); placeOnScreen(swingConfig.getScreenCenter()); }
From source file:es.emergya.ui.plugins.admin.aux1.RecursoDialog.java
public RecursoDialog(final Recurso rec, final AdminResources adminResources) { super();//from w w w .ja v a 2s. 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:org.gumtree.vis.plot1d.Plot1DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Plot1DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);/*from w ww . j a va 2 s. com*/ listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }