Im trying to combine thiss class ScrollPaneDemo() with my swingbuilder but this appears by separate exist any way IN that I could combine two for appear as same interface I read about of reflection but i dont know how i could use
please help me with this I cant combine
@Bindable
class Address {
String street, number, city
String toString() { "address[street=$street,number=$number,city=$city]" }
}
class ScrollPaneDemo extends JFrame {
ScrollPaneDemo() {
super("JScrollPane Demo");
ImageIcon ii = new ImageIcon("pokemon.png");
JScrollPane jsp = new JScrollPane(new JLabel(ii));
getContentPane().add(jsp);
setSize(300, 250);
setVisible(true);
jsp.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
System.out.println("Mouse X="+e.getY()+" Mouse Y="+e.getY());
}
});
}}
public static void main(String[] args) {
new ScrollPaneDemo();
}
def address = new Address(street: 'Evergreen Terrace', number: '742', city: 'Springfield')
def swingBuilder = new SwingBuilder()
swingBuilder.edt { // edt method makes sure UI is build on Event Dispatch Thread.
lookAndFeel 'nimbus' // Simple change in look and feel.
frame(title: 'Address', size: [1000, 800],
show: true, locationRelativeTo: null,
defaultCloseOperation: EXIT_ON_CLOSE) {
borderLayout(vgap: 5)
panel(constraints: BorderLayout.CENTER,
border: compoundBorder([emptyBorder(10), titledBorder('Enter your address:')])) {
tableLayout {
tr {
td {
label 'Street:' // text property is default, so it is implicit.
}
td {
textField address.street, id: 'streetField', columns: 20
}
}
tr {
td {
label 'Number:'
}
td {
textField id: 'numberField', columns: 5, text: address.number
}
}
tr {
td {
label 'City:'
}
td {
textField id: 'cityField', columns: 20, address.city
}
td {
textField id: 'cityField', columns: 20, address.city
}
}
}
new ScrollPaneDemo();
}
panel(constraints: BorderLayout.SOUTH) {
button text: 'Save', actionPerformed: {
println address
}
}
// Binding of textfield's to address object.
bean address,
street: bind { streetField.text },
number: bind { numberField.text },
city: bind { cityField.text }
}
}
PLease help me
Aucun commentaire:
Enregistrer un commentaire