| /* |
| * To change this template, choose Tools | Templates |
| * and open the template in the editor. |
| */ |
| |
| /* |
| * GooglePanel.java |
| * |
| * Created on 11-mrt-2011, 12:04:17 |
| */ |
| package org.myorg.googletoolbar; |
| |
| import java.awt.event.KeyEvent; |
| import java.net.URL; |
| import org.openide.awt.HtmlBrowser.URLDisplayer; |
| |
| /** |
| * |
| * @author gwielenga |
| */ |
| public class GooglePanel extends javax.swing.JPanel { |
| |
| /** Creates new form GooglePanel */ |
| public GooglePanel() { |
| initComponents(); |
| } |
| |
| /** This method is called from within the constructor to |
| * initialize the form. |
| * WARNING: Do NOT modify this code. The content of this method is |
| * always regenerated by the Form Editor. |
| */ |
| @SuppressWarnings("unchecked") |
| // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
| private void initComponents() { |
| |
| jLabel1 = new javax.swing.JLabel(); |
| jTextField1 = new javax.swing.JTextField(); |
| |
| jLabel1.setText(org.openide.util.NbBundle.getMessage(GooglePanel.class, "GooglePanel.jLabel1.text")); // NOI18N |
| |
| jTextField1.setText(org.openide.util.NbBundle.getMessage(GooglePanel.class, "GooglePanel.jTextField1.text")); // NOI18N |
| jTextField1.addKeyListener(new java.awt.event.KeyAdapter() { |
| public void keyTyped(java.awt.event.KeyEvent evt) { |
| jTextField1KeyTyped(evt); |
| } |
| }); |
| |
| javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
| this.setLayout(layout); |
| layout.setHorizontalGroup( |
| layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| .addGroup(layout.createSequentialGroup() |
| .addGap(10, 10, 10) |
| .addComponent(jLabel1) |
| .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
| .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)) |
| ); |
| layout.setVerticalGroup( |
| layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
| .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
| .addComponent(jLabel1)) |
| ); |
| }// </editor-fold>//GEN-END:initComponents |
| |
| private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyTyped |
| int i = evt.getKeyChar(); |
| if (i == KeyEvent.VK_ENTER) {//The ENTER KEY |
| // we display the google url. |
| try { |
| URLDisplayer.getDefault().showURL(new URL("http://www.google.com/search?hl=en&q=" + jTextField1.getText() + "&btnG=Google+Search")); |
| } catch (Exception eee) { |
| return;//nothing much to do |
| } |
| } |
| }//GEN-LAST:event_jTextField1KeyTyped |
| // Variables declaration - do not modify//GEN-BEGIN:variables |
| private javax.swing.JLabel jLabel1; |
| private javax.swing.JTextField jTextField1; |
| // End of variables declaration//GEN-END:variables |
| } |