public static JPanel initComponents() {
JButton button_ok = new JButton("Übernehmen");
JButton button_reject = new JButton("Abbrechen");
JTextField w_wrapper = new JTextField();
JTextField h_wrapper = new JTextField();
JTextField w_header = new JTextField();
JTextField h_header = new JTextField();
JTextField w_content = new JTextField();
JTextField h_content = new JTextField();
JTextField w_footer = new JTextField();
JTextField h_footer = new JTextField();
JTextField w_tile1 = new JTextField();
JTextField w_tile2 = new JTextField();
JTextField w_tile3 = new JTextField();
JTextField w_tile4 = new JTextField();
JTextField w_tile5 = new JTextField();
JTextField w_tile6 = new JTextField();
JTextField w_tile7 = new JTextField();
JTextField w_tile8 = new JTextField();
JTextField w_tile9 = new JTextField();
JTextField w_tile10 = new JTextField();
JTextField w_tile11 = new JTextField();
JTextField w_tile12 = new JTextField();
JTextField w_tile13 = new JTextField();
JTextField w_tile14 = new JTextField();
JTextField w_tile15 = new JTextField();
JTextField w_tile16 = new JTextField();
JTextField h_tile1 = new JTextField();
JTextField h_tile2 = new JTextField();
JTextField h_tile3 = new JTextField();
JTextField h_tile4 = new JTextField();
JTextField h_tile5 = new JTextField();
JTextField h_tile6 = new JTextField();
JTextField h_tile7 = new JTextField();
JTextField h_tile8 = new JTextField();
JTextField h_tile9 = new JTextField();
JTextField h_tile10 = new JTextField();
JTextField h_tile11 = new JTextField();
JTextField h_tile12 = new JTextField();
JTextField h_tile13 = new JTextField();
JTextField h_tile14 = new JTextField();
JTextField h_tile15 = new JTextField();
JTextField h_tile16 = new JTextField();
..........
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
JPanel jPanel4 = new JPanel();
JPanel panel = new JPanel();
..................
GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
..................
GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
..................
GroupLayout jPanel3Layout = new GroupLayout(jPanel3);
..................
GroupLayout jPanel4Layout = new GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4.setBackground(color_lightgray);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGap(0, 600, Short.MAX_VALUE)
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
panel.setBackground(color_darkgray);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel4)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, GroupLayout.Alignment.TRAILING, 210, 210, 210)
.addComponent(jPanel2, GroupLayout.Alignment.TRAILING, 210, 210, 210)
.addComponent(jPanel3, GroupLayout.Alignment.TRAILING, 210, 210, 210))
.addGap(0, 0, 5))
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
.addComponent(jPanel4)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1)
.addComponent(jPanel2)
.addComponent(jPanel3)))
.addGap(0, 0, 5))
);
return panel;
}
}
public class Panel {
public static JPanel initComponents() {
JButton button_ok = new JButton("Übernehmen");
button_ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String text = w_wrapper.getText();
}
});
JTextField h_wrapper = new JTextField();
JTextField w_header = new JTextField();
JTextField h_header = new JTextField();
JTextField w_content = new JTextField();
............
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JTextField;
public class JPanel {
public JTextField w_wrapper = new JTextField();
public void initComponents() {
JButton button_ok = new JButton("Übernehmen");
button_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String text = w_wrapper.getText();
}
});
JTextField h_wrapper = new JTextField();
JTextField w_header = new JTextField();
JTextField h_header = new JTextField();
JTextField w_content = new JTextField();
}
}
Code ist ja schon schön und gut, aber der ist quasi der Normalweg,immer konkret schreiben was genau nicht funktioniert
package layouttool;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
public class Panel {
public static JPanel initComponents() {
Color color_orange = new Color(211,111,53);
Color color_darkgray = new Color(41,38,38);
Color color_lightgray = new Color(123,107,99);
JButton button_ok = new JButton("Übernehmen");
button_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String text = w_wrapper.getText();
}
});
JButton button_reject = new JButton("Abbrechen");
/* ********************* Panel 1 Layout ************************************ */
JLabel wrapper = new JLabel("wrapper");
JLabel header = new JLabel("header");
JLabel content = new JLabel("content");
JLabel footer = new JLabel("footer");
JTextField w_wrapper = new JTextField();
JTextField h_wrapper = new JTextField();
JTextField w_header = new JTextField();
JTextField h_header = new JTextField();
JTextField w_content = new JTextField();
JTextField h_content = new JTextField();
JTextField w_footer = new JTextField();
JTextField h_footer = new JTextField();
wrapper.setForeground(color_lightgray);
header.setForeground(color_lightgray);
content.setForeground(color_lightgray);
footer.setForeground(color_lightgray);
w_wrapper.setDocument(new IntegerField(4));
h_wrapper.setDocument(new IntegerField(4));
w_header.setDocument(new IntegerField(4));
h_header.setDocument(new IntegerField(4));
w_content.setDocument(new IntegerField(4));
h_content.setDocument(new IntegerField(4));
w_footer.setDocument(new IntegerField(4));
h_footer.setDocument(new IntegerField(4));
/* ********************* Ende Panel 1 ************************************** */
/* ********************* Panel 2 Werbeformen ******************************* */
JLabel tile1 = new JLabel("tile 1");
JLabel tile2 = new JLabel("tile 2");
JLabel tile3 = new JLabel("tile 3");
JLabel tile4 = new JLabel("tile 4");
JLabel tile5 = new JLabel("tile 5");
JLabel tile6 = new JLabel("tile 6");
JLabel tile7 = new JLabel("tile 7");
JLabel tile8 = new JLabel("tile 8");
JLabel tile9 = new JLabel("tile 9");
JLabel tile10 = new JLabel("tile 10");
JLabel tile11 = new JLabel("tile 11");
JLabel tile12 = new JLabel("tile 12");
JLabel tile13 = new JLabel("tile 13");
JLabel tile14 = new JLabel("tile 14");
JLabel tile15 = new JLabel("tile 15");
JLabel tile16 = new JLabel("tile 16");
JTextField w_tile1 = new JTextField();
JTextField w_tile2 = new JTextField();
JTextField w_tile3 = new JTextField();
JTextField w_tile4 = new JTextField();
JTextField w_tile5 = new JTextField();
JTextField w_tile6 = new JTextField();
JTextField w_tile7 = new JTextField();
JTextField w_tile8 = new JTextField();
JTextField w_tile9 = new JTextField();
JTextField w_tile10 = new JTextField();
JTextField w_tile11 = new JTextField();
JTextField w_tile12 = new JTextField();
JTextField w_tile13 = new JTextField();
JTextField w_tile14 = new JTextField();
JTextField w_tile15 = new JTextField();
JTextField w_tile16 = new JTextField();
JTextField h_tile1 = new JTextField();
JTextField h_tile2 = new JTextField();
JTextField h_tile3 = new JTextField();
JTextField h_tile4 = new JTextField();
JTextField h_tile5 = new JTextField();
JTextField h_tile6 = new JTextField();
JTextField h_tile7 = new JTextField();
JTextField h_tile8 = new JTextField();
JTextField h_tile9 = new JTextField();
JTextField h_tile10 = new JTextField();
JTextField h_tile11 = new JTextField();
JTextField h_tile12 = new JTextField();
JTextField h_tile13 = new JTextField();
JTextField h_tile14 = new JTextField();
JTextField h_tile15 = new JTextField();
JTextField h_tile16 = new JTextField();
tile1.setForeground(color_lightgray);
tile2.setForeground(color_lightgray);
tile3.setForeground(color_lightgray);
tile4.setForeground(color_lightgray);
tile5.setForeground(color_lightgray);
tile6.setForeground(color_lightgray);
tile7.setForeground(color_lightgray);
tile8.setForeground(color_lightgray);
tile9.setForeground(color_lightgray);
tile10.setForeground(color_lightgray);
tile11.setForeground(color_lightgray);
tile12.setForeground(color_lightgray);
tile13.setForeground(color_lightgray);
tile14.setForeground(color_lightgray);
tile15.setForeground(color_lightgray);
tile16.setForeground(color_lightgray);
w_tile1.setDocument(new IntegerField(4));
h_tile1.setDocument(new IntegerField(4));
w_tile2.setDocument(new IntegerField(4));
h_tile2.setDocument(new IntegerField(4));
w_tile3.setDocument(new IntegerField(4));
h_tile3.setDocument(new IntegerField(4));
w_tile4.setDocument(new IntegerField(4));
h_tile4.setDocument(new IntegerField(4));
w_tile5.setDocument(new IntegerField(4));
h_tile5.setDocument(new IntegerField(4));
w_tile6.setDocument(new IntegerField(4));
h_tile6.setDocument(new IntegerField(4));
w_tile7.setDocument(new IntegerField(4));
h_tile7.setDocument(new IntegerField(4));
w_tile8.setDocument(new IntegerField(4));
h_tile8.setDocument(new IntegerField(4));
w_tile9.setDocument(new IntegerField(4));
h_tile9.setDocument(new IntegerField(4));
w_tile10.setDocument(new IntegerField(4));
h_tile10.setDocument(new IntegerField(4));
w_tile11.setDocument(new IntegerField(4));
h_tile11.setDocument(new IntegerField(4));
w_tile12.setDocument(new IntegerField(4));
h_tile12.setDocument(new IntegerField(4));
w_tile13.setDocument(new IntegerField(4));
h_tile13.setDocument(new IntegerField(4));
w_tile14.setDocument(new IntegerField(4));
h_tile14.setDocument(new IntegerField(4));
w_tile15.setDocument(new IntegerField(4));
h_tile15.setDocument(new IntegerField(4));
w_tile16.setDocument(new IntegerField(4));
h_tile16.setDocument(new IntegerField(4));
/* ********************* Ende Panel 2 ************************************** */
}
}
public void actionPerformed(ActionEvent arg0) {
String text1 = w_wrapper.getText();
String text2 = w_wrapper.getText();
String text3 = w_wrapper.getText();
String text4 = w_wrapper.getText();
....................
}
final ArrayList<JTextField> tFields = new ArrayList<JTextField>();
for (int i=0; i<40; i++){
JTextField tF = new JTextField(5);
// tF.setForeground(.................);
tFields.add(tF);
}
JButton b = new JButton("Save");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (JTextField tfs : tFields){
tfs.getText();
}
}
});
public void actionPerformed(ActionEvent arg0) {
String text1 = w_wrapper.getText();
String text2 = h_wrapper.getText();
String text3 = h_header.getText();
String text4 = klaus_meier.getText();
....................
}
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
JPanel jPanel4 = new JPanel();
JPanel panel = new JPanel();
GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1.setBackground(color_darkgray);
Border titled_border = BorderFactory.createMatteBorder(2, 2, 2, 2, color_orange);
Border tb_layout = BorderFactory.createTitledBorder(titled_border, "Layout", TitledBorder.LEFT, TitledBorder.TOP,font_border, color_orange);
jPanel1.setBorder(tb_layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(wrapper,60,60,60)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(w_wrapper,40,40,40)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(h_wrapper,40,40,40))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(header,60,60,60)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(w_header,40,40,40)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(h_header,40,40,40))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(content,60,60,60)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(w_content,40,40,40)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(h_content,40,40,40))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(footer,60,60,60)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(w_footer,40,40,40)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(h_footer,40,40,40)))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
........................................