Netbeans 6M9, rote Kreuzchen und Databinding in Matisse

Das ist ja lustig. Gestern habe ich mir Netbeans 6M9 installiert und festgestellt, dass Sie die Kreuzchen eingebaut haben, die ich mir gewünscht habe. DANKE! Nun sieht man auch, wenn die Folder in einem Projekt eingeklappt sind, dass es noch Fehler gibt.

Ausserdem habe mir noch schnell das Databinding angeschaut, welches jetzt von Matisse unterstützt wird. Nun ja, innerhalb eines NB-Modules habe ich es nicht zum laufen gebracht. Im GUIFormExample ging es dann aber.

Ich habe dazu eine Variable in die Klasse Antenna angelegt:

public class Antenna extends javax.swing.JFrame {

private double direction = 111.111;

public double getDirection() {
return direction;
}

public void setDirection(double direction) {
this.direction = direction;
}

Dann die Verbindung gemacht. Rechte Maustaste auf das Textfeld von Direction und dort –> bind –> text –> (und siehe bild)

Noch schnell ein Converter für Doubles in Antenna implementiert:

private BindingConverter DOUBLE_TO_STRING_CONVERTER = new BindingConverter(){

public Object sourceToTarget(Object value) {
return ((Double) value).toString();
}

@Override
public Object targetToSource(Object value) {
return Double.parseDouble((String)value);
}
};

Und diesen ins Binding eingetragen:

Fertig… Beim Öffnen des Dialoges wird jetzt magischer Weise 111.111 angzeigt.

Hier noch der vollständige Code:

package examples;

import javax.beans.binding.BindingConverter;

public class Antenna extends javax.swing.JFrame {

private double direction = 111.111;

public double getDirection() {
return direction;
}

public void setDirection(double direction) {
this.direction = direction;
}

private BindingConverter DOUBLE_TO_STRING_CONVERTER = new BindingConverter(){

public Object sourceToTarget(Object value) {
return ((Double) value).toString();
}

@Override
public Object targetToSource(Object value) {
return Double.parseDouble((String)value);
}
};

/** Creates new form Antenna */
public Antenna() {
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.
*/
//
private void initComponents() {
bindingContext = new javax.beans.binding.BindingContext();

jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jCheckBox1 = new javax.swing.JCheckBox();
jPanel2 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
jTextField4 = new javax.swing.JTextField();
jComboBox1 = new javax.swing.JComboBox();
jTextField5 = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jTextField6 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jTextField8 = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jTextField9 = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jComboBox2 = new javax.swing.JComboBox();
jButton5 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(“Antenna”);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(” Position/Direction “));

jLabel1.setText(“Direction [u00b0]:”);

jLabel2.setText(“Height [m]:”);

javax.beans.binding.Binding binding = new javax.beans.binding.Binding(this, “${direction}”, jTextField1, “text”);
binding.setConverter(DOUBLE_TO_STRING_CONVERTER);
bindingContext.addBinding(binding);

jTextField2.setText(“110.000”);

jCheckBox1.setText(“Height is Lower Edge (Not Center)”);
jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));

org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel2)
.add(jLabel1))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jCheckBox1)
.add(jTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
.add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox1)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(” System “));

jLabel3.setText(“Channels:”);

jLabel4.setText(“Antenna Type:”);

jLabel5.setText(“Electrical Downtilt From [u00b0]:”);

jLabel6.setText(“Polarization:”);

jLabel7.setText(“Frequency From [MHz]:”);

jTextField3.setText(“2”);

jLabel8.setText(“Watts:”);

jTextField4.setText(“12.000”);

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { “Kathrein 742151” }));

jTextField5.setText(“0.000”);

jLabel9.setText(“To:”);

jTextField6.setText(“10.000”);

jButton1.setText(“Adjust”);

jTextField8.setText(“943.000”);

jLabel10.setText(“To:”);

jTextField9.setText(“951.000”);

jButton2.setText(“Adjust”);

jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { “X +45u00b0” }));

jButton5.setText(“Adjust”);

org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel7)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel6)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jComboBox1, 0, 338, Short.MAX_VALUE)
.add(jPanel2Layout.createSequentialGroup()
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jTextField8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
.add(jTextField5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
.add(jTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel8)
.add(jLabel9)
.add(jLabel10))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jButton5)
.add(jButton1)
.add(jButton2)))
.add(jComboBox2, 0, 338, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel8)
.add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jButton5))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel5)
.add(jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jButton1)
.add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel9))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel6)
.add(jComboBox2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel7)
.add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jButton2)
.add(jTextField9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel10))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

jButton3.setText(“Cancel”);

jButton4.setText(“OK”);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(jButton4)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton3)))
.addContainerGap())
);

layout.linkSize(new java.awt.Component[] {jButton3, jButton4}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 12, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton3)
.add(jButton4))
.addContainerGap())
);

bindingContext.bind();

pack();
}//

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Antenna a = new Antenna();
a.setVisible(true);
}
});
}

// Variables declaration – do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextField jTextField9;
private javax.beans.binding.BindingContext bindingContext;
// End of variables declaration

}

2 thoughts on “Netbeans 6M9, rote Kreuzchen und Databinding in Matisse

  1. Auch sonst macht Netbeans 6 (M9) einen sehr guten Eindruck, wie ich finde. Die ganze grafische Überarbeitung, verbesserte Assistenten etc. So langsam wird Eclipse überholt. 🙂

    Like

  2. Mir gefällt das sematische Highlighting im Editor. Macht den Code wirklich übersichtlicher und man findet eher Fehler. Damit Eclipse überholt werden kann, braucht es aber noch eine so grosse Community wie sie Eclipse hat. Aber wenn die bei Netbeans so weitermachen, dann habe ich keine Sorge, dass sich immer mehr Leute (wieder) Netbeans zuwenden.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s