I'm coding on Java with visualswing4eclipse. My environmentis Eclipse IDE Version: Luna Service Release 2 (4.4.2). I'm trying to write a function, which auto resize all components inside frame when user change size of window. Here's code:
private void componentComponentResized(ComponentEvent event) {
int a=getContentPane().getWidth();
int b=getContentPane().getHeight();
Font font1 = new Font(Font.SANS_SERIF, 2, (int) (b*0.05));
jTextField0.setBounds((int) (a*0.3), (int) (b*0.1), (int) (0.68*a), (int) (0.1*b));
jLabel0.setBounds((int) (a*0.02), (int) (b*0.1), (int) (a*0.27), (int) (0.1*b));
// jLabel0.setFont(font1);
// jTextField0.setFont(font1);
}
for now, setBounds work properly, but if I uncomment setFont, setBounds stop working, it's like I wasn't write lines with setBound. How can I solve this problem?
edit: I created new GroupLayout to set position of components in this way:
private void initComponents() {
setLayout(new GroupLayout());
Could I use this layout in auto resize function? If not, which layout is good choice for me? Here's frame's view in basic size