Sunday, February 28, 2010

NetBeans Java IDE

I've been using Netbeans IDE to write C/C++ code now for several years. All that time I have never written a graphical interface with it. I program mostly for Unix shell.

I decided this weekend since I had the time I was going to learn how to do it.

I wanted to code something simple yet useful to amateur radio as I want to start writing applications for the Blackberry smartphones.

This version of the dipole calculator is not written for the Blackberry however as it uses a different JDK and you have to pay $20 to get a certificate key so you can use the locked portions of the JDK. I'm not quite ready to shell out the $20 if I can't even get the JDK to work with Netbeans.

Anyway, the link to the free software is to the left in the sidebar.

Here is the source code:
(Netbeans IDE creates most of the code, I wrote only a few lines which are highlighted in bold text)


import java.text.NumberFormat;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/*
 * DiPoleGUI.java
 *
 * Created on Feb 28, 2010, 6:41:19 AM
 */
/**
 *
 * @author Tim
 */
public class DiPoleGUI extends javax.swing.JFrame {


    double frequency = 0, wire_length = 0;


    /** Creates new form DiPoleGUI */
    public DiPoleGUI() {
        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")
    //                          
    private void initComponents() {

        ButtonCalculate = new javax.swing.JButton();
        Reset = new javax.swing.JButton();
        DataInputMHz = new javax.swing.JFormattedTextField();
        DataInputLength = new javax.swing.JFormattedTextField();
        Frequency1 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        ResultHalfLength = new javax.swing.JFormattedTextField();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        ResultHalfLength1 = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Dipole Calculator");

        ButtonCalculate.setText("Calculate");
        ButtonCalculate.setPreferredSize(new java.awt.Dimension(77, 23));
        ButtonCalculate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonCalculateActionPerformed(evt);
            }
        });

        Reset.setText("Reset");
        Reset.setPreferredSize(new java.awt.Dimension(61, 23));
        Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetActionPerformed(evt);
            }
        });

        DataInputMHz.setText("0");
        DataInputMHz.setPreferredSize(new java.awt.Dimension(12, 20));
        DataInputMHz.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                DataInputMHzFocusGained(evt);
            }
        });

        DataInputLength.setText("0");
        DataInputLength.setPreferredSize(new java.awt.Dimension(12, 20));
        DataInputLength.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DataInputLengthActionPerformed(evt);
            }
        });
        DataInputLength.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                DataInputLengthFocusGained(evt);
            }
        });

        Frequency1.setText("Frequency");

        jLabel1.setText("Overall Length");

        ResultHalfLength.setBackground(new java.awt.Color(153, 153, 153));
        ResultHalfLength.setEditable(false);
        ResultHalfLength.setPreferredSize(new java.awt.Dimension(109, 20));

        jSeparator1.setForeground(new java.awt.Color(0, 0, 204));

        jSeparator2.setForeground(new java.awt.Color(0, 0, 204));

        ResultHalfLength1.setBackground(new java.awt.Color(153, 153, 153));
        ResultHalfLength1.setEditable(false);
        ResultHalfLength1.setPreferredSize(new java.awt.Dimension(109, 20));
        ResultHalfLength1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResultHalfLength1ActionPerformed(evt);
            }
        });

        jLabel2.setText("Feet");

        jLabel3.setText("MHz");

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setFont(new java.awt.Font("Arial Black", 0, 13)); // NOI18N
        jTextArea1.setLineWrap(true);
        jTextArea1.setRows(5);
        jTextArea1.setText("Enter the resonant frequency in MHz or the overall antenna wire length and press the calculate button to calculate the missing value.");
        jScrollPane1.setViewportView(jTextArea1);

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel4.setText("DIPOLE CALCULATOR By AJ4UU");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(194, 194, 194)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Reset, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ButtonCalculate, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ResultHalfLength1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(95, 95, 95)
                                .addComponent(ResultHalfLength, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel4)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 441, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(161, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Frequency1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(DataInputMHz, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(DataInputLength, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(123, 123, 123))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {ButtonCalculate, Reset});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(DataInputLength, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(Frequency1)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(DataInputMHz, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ButtonCalculate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Reset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ResultHalfLength1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ResultHalfLength, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );

        pack();
    }//
                       



    private void ButtonCalculateActionPerformed(java.awt.event.ActionEvent evt) {                                               
        // TODO add your handling code here:
        //double frequency, wire_length;
        frequency = Double.parseDouble(DataInputMHz.getText());
        wire_length = Double.parseDouble(DataInputLength.getText());
        if (wire_length == 0) {
            wire_length = 468 / frequency;
            DataInputLength.setValue(wire_length);
        } else if (frequency == 0) {
            frequency = 468 / wire_length;
            DataInputMHz.setValue(frequency);
        }
        ResultHalfLength.setValue(wire_length / 2);
        ResultHalfLength1.setValue(wire_length / 2);


    }                                              


    private void ResetActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        DataInputMHz.setText("0");
        DataInputLength.setText("0");
        ResultHalfLength.setText(null);
        ResultHalfLength1.setText(null);
        wire_length = frequency = 0;
    }                                    


    private void DataInputMHzFocusGained(java.awt.event.FocusEvent evt) {                                        
        // TODO add your handling code here:
        DataInputMHz.setText(null);
        DataInputLength.setText("0");
    }                                       


    private void DataInputLengthFocusGained(java.awt.event.FocusEvent evt) {                                           
        // TODO add your handling code here:
        DataInputLength.setText(null);
        DataInputMHz.setText("0");
    }                                          


    private void ResultHalfLength1ActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        // TODO add your handling code here:
    }                                                


    private void DataInputLengthActionPerformed(java.awt.event.ActionEvent evt) {                                               
        // TODO add your handling code here:
    }                                              


    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {


            public void run() {
                new DiPoleGUI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                    
    private javax.swing.JButton ButtonCalculate;
    private javax.swing.JFormattedTextField DataInputLength;
    private javax.swing.JFormattedTextField DataInputMHz;
    private javax.swing.JLabel Frequency1;
    private javax.swing.JButton Reset;
    private javax.swing.JFormattedTextField ResultHalfLength;
    private javax.swing.JFormattedTextField ResultHalfLength1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration                  
}

Monday, February 15, 2010

15m DiPole

Saturday, February 6, 2010

RadioWavz DX40 and BPSK31 Video

It's Alive.. It's Alive

That large sunspot area that I was talking about last week has finally rotated around to the front side. There are quite a lot of very small surface disturbances but only a couple of actual sunspots. Hopefully more will emerge over the next few days as the actual count and solar flux is still quite low.

Tuesday, February 2, 2010

RadioWavz DX40 OCF Dipole


Got the RadioWavz 40m OCF (DX40) up yesterday afternoon and the band was busy during the evening and I couldn't make any contacts. This morning however I did make a contact to Topeka, KS so I know it gets out.

The installed height of 20 feet is horrible for 40m as the takeoff angle is straight up in the air. So it will be only local stations for now until I move to a place where I can hang it at 66 feet.

Also the long leg is mostly across the oak tree and that has some serious signal degradation I'm sure. Some day I'll have a better area for a small antenna farm.



Here is the opposite angle showing a closer view of the short leg.