List of usage examples for javax.swing JLabel setIcon
@BeanProperty(preferred = true, visualUpdate = true, description = "The icon this component will display.") public void setIcon(Icon icon)
From source file:se.trixon.almond.GraphicsHelper.java
public static void setImageIcon(JLabel label, URL url) { if (url != null) { label.setIcon(new ImageIcon(url)); } else {/*from www . jav a 2 s. c o m*/ label.setIcon(null); } }
From source file:taximetro.main.java
private void jTextFielddestinoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFielddestinoActionPerformed //Generar el mapa a partir de la direccin en formato texto introducida. //al darle a Enter. String origen = jTextFieldlatitud.getText() + "," + jTextFieldlongitud.getText(); String destino = jTextFielddestino.getText(); //Hay que sustituir los espacios por el carcter %20 para que se // interprete bien la URL que se generar destino = destino.replaceAll(" ", "%20"); //Cambia el nombre [etiqueta] por el nombre de un objeto JLabel (etiqueta) que // has debido colocar antes en el formulario y que ser donde se muestre el mapa. // Deja la etiqueta del formulario sin ningn texto en el diseo. javax.swing.JLabel jLabelMapa = jLabelmapa; //Indica aqu el tamao que desees para el mapa int tamHorizontal = 200; int tamVertical = 200; //Puedes encontrar ms informacin sobre el uso de mapas estticos de Google Maps aqu: // http://code.google.com/intl/es-ES/apis/maps/documentation/staticmaps/ //A partir de aqu no hace falta cambiar nada try {/*www . j av a 2 s . c o m*/ String txtDireccionImagenMapa = "http://maps.google.com/maps/api/staticmap?path=" + origen + "|" + destino + "&size=" + tamHorizontal + "x" + tamVertical + "&language=ES&sensor=false"; System.out.println(txtDireccionImagenMapa); java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); java.awt.Image imagenMapa = toolkit.getImage(new java.net.URL(txtDireccionImagenMapa)); jLabelMapa.setIcon(new javax.swing.ImageIcon(imagenMapa)); } catch (java.net.MalformedURLException e) { javax.swing.JOptionPane.showMessageDialog(this, "La direccin de imagen indicada no es correcta"); } }
From source file:taximetro.Taximetro.java
private void direccionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_direccionFocusLost //Cambia los siguientes valores por las direciones de origen y destino deseadas String origen = latitudFormato.getText() + "," + longitudFormato.getText(); String destino = direccion.getText(); //Hay que sustituir los espacios por el carcter %20 para que se // interprete bien la URL que se generar destino = destino.replaceAll(" ", "%20"); //Cambia el nombre [etiqueta] por el nombre de un objeto JLabel (etiqueta) que // has debido colocar antes en el formulario y que ser donde se muestre el mapa. // Deja la etiqueta del formulario sin ningn texto en el diseo. javax.swing.JLabel jLabelMapa = mapa; //Indica aqu el tamao que desees para el mapa int tamHorizontal = 256; int tamVertical = 256; //Puedes encontrar ms informacin sobre el uso de mapas estticos de Google Maps aqu: // http://code.google.com/intl/es-ES/apis/maps/documentation/staticmaps/ //A partir de aqu no hace falta cambiar nada try {/*from w w w. ja v a 2 s. c o m*/ String txtDireccionImagenMapa = "http://maps.google.com/maps/api/staticmap?path=" + origen + "|" + destino + "&size=" + tamHorizontal + "x" + tamVertical + "&language=ES&sensor=false"; System.out.println(txtDireccionImagenMapa); java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); java.awt.Image imagenMapa = toolkit.getImage(new java.net.URL(txtDireccionImagenMapa)); jLabelMapa.setIcon(new javax.swing.ImageIcon(imagenMapa)); } catch (java.net.MalformedURLException e) { javax.swing.JOptionPane.showMessageDialog(this, "La direccin de imagen indicada no es correcta"); } }
From source file:taximetrotema2.Main.java
private void jToggleButtonBanderaVerdeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonBanderaVerdeActionPerformed jToggleButtonStop.setEnabled(true);/*from w ww .j a v a2 s .c o m*/ fechaHoraSalida = Calendar.getInstance(); formatoHora.format(fechaHoraSalida.getTime()); double latitud = Double.valueOf(jTextFieldLatitud.getText()); double longitud = Double.valueOf(jTextFieldLongitud.getText()); CoordinatesConverter conversorCoordenadas = new CoordinatesConverter(); jLabel4.setText(conversorCoordenadas.decimalToDMS(latitud)); jLabel5.setText(conversorCoordenadas.decimalToDMS(longitud)); //Cambia los siguientes valores por las direciones de origen y destino deseadas String origen = jTextFieldLatitud.getText() + "," + jTextFieldLongitud.getText(); String destino = jTextFieldDestino.getText(); //Hay que sustituir los espacios por el carcter %20 para que se // interprete bien la URL que se generar destino = destino.replaceAll(" ", "%20"); //Cambia el nombre [etiqueta] por el nombre de un objeto JLabel (etiqueta) que // has debido colocar antes en el formulario y que ser donde se muestre el mapa. // Deja la etiqueta del formulario sin ningn texto en el diseo. javax.swing.JLabel jLabelMapa = jLabelMapaRuta; //Indica aqu el tamao que desees para el mapa int tamHorizontal = 300; int tamVertical = 270; //Puedes encontrar ms informacin sobre el uso de mapas estticos de Google Maps aqu: // http://code.google.com/intl/es-ES/apis/maps/documentation/staticmaps/ //A partir de aqu no hace falta cambiar nada try { String txtDireccionImagenMapa = "http://maps.google.com/maps/api/staticmap?path=" + origen + "|" + destino + "&size=" + tamHorizontal + "x" + tamVertical + "&language=ES&sensor=false"; System.out.println(txtDireccionImagenMapa); java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); java.awt.Image imagenMapa = toolkit.getImage(new java.net.URL(txtDireccionImagenMapa)); jLabelMapa.setIcon(new javax.swing.ImageIcon(imagenMapa)); } catch (java.net.MalformedURLException e) { javax.swing.JOptionPane.showMessageDialog(this, "La direccin de imagen indicada no es correcta"); } jToggleButtonBanderaVerde.setEnabled(false); }
From source file:theofilin.CameraApps.java
public static void StartCamera(JLabel tampil, int width, int height) throws IOException { ActionListener actionlistener; actionlistener = new ActionListener() { @Override//w w w . ja v a2 s .c om public void actionPerformed(ActionEvent ae) { try { Runtime rt = Runtime.getRuntime(); String command = "raspistill -n -t 1 -drc high -ISO 200 " + "-w " + width + " -h " + height + " -o -"; Process p = rt.exec(command); InputStream is = p.getInputStream(); byte[] curr = IOUtils.toByteArray(is); ImageIcon disp = new ImageIcon(curr); tampil.setIcon(disp); } catch (IOException ex) { Logger.getLogger(CameraApps.class.getName()).log(Level.SEVERE, null, ex); } } }; timer = new Timer(100, actionlistener); timer.start(); }
From source file:theofilin.CameraApps.java
public static void GrabCamera(JLabel tampil, int width, int height) { try {/*w ww .j a va 2s . c o m*/ Runtime rt = Runtime.getRuntime(); String command = "raspistill -n -t 1 -drc high -ISO 200 " + "-w " + width + " -h " + height + " -o -"; Process p = rt.exec(command); //tampilin di label dulu InputStream is = p.getInputStream(); byte[] curr = IOUtils.toByteArray(is); ImageIcon disp = new ImageIcon(curr); tampil.setIcon(disp); //reset InputStream is = null; //tulis difile kemudian is = new ByteArrayInputStream(curr); img = ImageIO.read(is); impl = new ImagePlus(null, img); ip = impl.getProcessor(); } catch (IOException ex) { Logger.getLogger(CameraApps.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:theofilin.CameraApps.java
public static void BurstNow(JLabel tampil, double r_gain, double b_gain, int width, int height, int num) throws IOException { try {/*from www .j a v a 2s. c o m*/ Runtime rt = Runtime.getRuntime(); String command = "raspistill -n --raw -t 1 -sa 0 -co 0 -br 40 -sh 0 -awb off -awbg " + r_gain + "," + b_gain + " -ISO 200 -ss 45000 " + "-w " + width + " -h " + height + " -o -"; Process p = rt.exec(command); InputStream is = p.getInputStream(); byte[] curr = IOUtils.toByteArray(is); ImageIcon disp = new ImageIcon(curr); tampil.setIcon(disp); is = new ByteArrayInputStream(curr); img = ImageIO.read(is); ImageIO.write(img, "jpg", new File("/home/pi/" + num + ".jpg")); } catch (IOException ex) { Logger.getLogger(CameraApps.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:tkwatch.Utilities.java
/** * Returns a standard panel for the bottom (SOUTH) of all windows. *///from w w w . ja va 2s . c om public static final JPanel getStatusPanel() { ImageIcon poweredByT4j = new ImageIcon("poweredByT4j.gif"); // TODO Messageline currently used for Twitter4J banner. Could be used // for expected status messages, currently implemented as dialog boxes. final JLabel messageLine = new JLabel(); messageLine.setIcon(poweredByT4j); final JPanel buttonPanel = new JPanel(new GridLayout(Constants.ONE_ROW, Constants.THREE_COLUMNS)); buttonPanel.add(getQuitButton()); final JPanel statusPanel = new JPanel(new BorderLayout()); statusPanel.add(messageLine, BorderLayout.WEST); statusPanel.add(buttonPanel, BorderLayout.EAST); statusPanel.updateUI(); return statusPanel; }
From source file:uk.ac.soton.mib104.t2.activities.json.ui.config.JSONPathConfigurationPanel.java
protected void initGui() { this.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); this.setLayout(new GridBagLayout()); jsonPathAsTextField.setMinimumSize(new Dimension(240, jsonPathAsTextField.getMinimumSize().height)); jsonPathAsTextField.setPreferredSize(jsonPathAsTextField.getMinimumSize()); jsonPathAsTextField.setText(""); jsonPathButton.addActionListener(new ActionListener() { @Override/*from www . ja v a 2 s.c o m*/ public void actionPerformed(final ActionEvent e) { final JSONPathInputDialog jsonPathInputDialog = new JSONPathInputDialog( SwingUtilities.getWindowAncestor(JSONPathConfigurationPanel.this)); final JSONPathInputPanel jsonPathInputPane = jsonPathInputDialog.getJSONPathInputPane(); jsonPathInputPane.getJSONDocumentEditorPane().setText(jsonPathInputDialog_jsonPathEditorPane_text); jsonPathInputPane.getJsonPathEditorPane() .setJSONValue(jsonPathInputDialog_jsonPathEditorPane_value); jsonPathInputPane.getJsonPathEditorPane() .setTreeVisible(jsonPathInputDialog_jsonPathEditorPane_treeVisible); jsonPathInputPane.getJsonPathEditorPane().setText(jsonPathAsTextField.getText()); jsonPathInputDialog.setVisible(true); switch (jsonPathInputDialog.getOption()) { case JOptionPane.OK_OPTION: break; default: return; } jsonPathInputDialog_jsonPathEditorPane_text = jsonPathInputPane.getJSONDocumentEditorPane() .getText(); jsonPathInputDialog_jsonPathEditorPane_treeVisible = jsonPathInputPane.getJsonPathEditorPane() .isTreeVisible(); jsonPathInputDialog_jsonPathEditorPane_value = jsonPathInputPane.getJsonPathEditorPane() .getJSONValue(); jsonPathAsTextField.setText(jsonPathInputPane.getJsonPathEditorPane().getText()); } }); jsonPathButton.setFont(jsonPathButton.getFont().deriveFont(11f)); jsonPathButton.setIcon(JSONPathServiceIcon.getIcon()); jsonPathButton.setText(jsonPathButtonText); jsonPathButton.setToolTipText(jsonPathButtonTip); final JLabel portDepthLabel = new JLabel(); portDepthLabel.setFont(portDepthLabel.getFont().deriveFont(11f)); portDepthLabel.setHorizontalAlignment(JLabel.LEFT); portDepthLabel.setIcon(Silk.getHelpIcon()); portDepthLabel.setText(portDepthInputPaneText); portDepthLabel.setToolTipText(portDepthInputPaneTip); final GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.gridy = 0; constraints.anchor = GridBagConstraints.WEST; this.add(JSONPathTextField.createLabelForDocument(jsonPathAsTextField.getDocument()), constraints); constraints.gridx++; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 1d; this.add(jsonPathAsTextField, constraints); constraints.weightx = 0; constraints.gridx++; constraints.fill = GridBagConstraints.NONE; this.add(jsonPathButton, constraints); constraints.gridx--; constraints.gridy++; constraints.anchor = GridBagConstraints.CENTER; this.add(JSONPathTextField.createLabelForDocumentationURI(), constraints); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.gridy++; constraints.gridwidth = 3; this.add(new JSeparator(JSeparator.HORIZONTAL), constraints); constraints.gridwidth = 1; constraints.gridx = 0; constraints.gridy++; constraints.anchor = GridBagConstraints.WEST; this.add(portDepthLabel, constraints); constraints.gridx++; constraints.anchor = GridBagConstraints.EAST; constraints.gridwidth = 2; this.add(portDepthInputPane, constraints); constraints.gridwidth = 1; }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.renderer.ReportingQueryStatementTreeCellRenderer.java
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { final JLabel label = new JLabel(); if (value instanceof QueryExpression) { QueryExpression expression = (QueryExpression) value; if (expression instanceof QueryStatement) { label.setText("Get patients who have"); } else if (expression instanceof QueryIntersectionExpression) { QueryIntersectionExpression intersectionObject = (QueryIntersectionExpression) expression; QueryExpression.QueryOperatorType operatorType = intersectionObject.getOperator(); if (operatorType != QueryExpression.QueryOperatorType.AND) { label.setText("ALL of the following (" + operatorType.toString() + ")"); } else { label.setText("ALL of the following"); }/*from w w w .ja v a 2s .c om*/ } else if (expression instanceof QueryUnionExpression) { label.setText("ANY of the following"); } else if (expression instanceof QueryComponentExpression) { QueryComponentExpression componentExpression = (QueryComponentExpression) value; TerminologyConstraint includedConstraint = componentExpression.getIncludedConstraint(); if (includedConstraint != null) { String text = humanReadableRender .getHumanReadableLabel((CloseToUserExpression) includedConstraint.getExpression()); label.setText(text); } final Collection<TerminologyConstraint> excludedTerms = componentExpression .getExcludedConstraints(); if (excludedTerms.size() > 0) { label.setIcon(icon); } SwingUtilities.updateComponentTreeUI(label); } // set label text color based on run time status setFontColor(expression, label); } if (hasFocus) { Color lineColor = UIManager.getColor("Tree.selectionBorderColor"); label.setBorder(BorderFactory.createLineBorder(lineColor)); label.setBackground(UIManager.getColor("Tree.selectionBackground")); } else { label.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); label.setBackground(UIManager.getColor("Tree.background")); } return label; }