Is there a way to create Netbeans Matisse Vertical Flow Layout like :
But Netbeans Matisse Flow Layout create like this :
Is there a way to create Netbeans Matisse Vertical Flow Layout like :
But Netbeans Matisse Flow Layout create like this :
FlowLayout
will automatically "wrap" components whose width extends past the boundary of the container they're in. So, to accomplish what I think you're trying to accomplish, all you need to do is set the FlowLayout
like you've done, and resize the JTextField
s to the appropriate width.
Note: "what I think" was a pointed criticism of the fact that your question doesn't really help us know exactly what you're trying to accomplish.
Five JTextField
s:
Notice if you resize one, it will "wrap" the others:
You can select and resize multiple components simultaneously:
I changed the widths to 250:
Viola:
Code:
public class NewJFrame2 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame2
*/
public NewJFrame2() {
initComponents();
setSize(287,200);
}
/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new java.awt.FlowLayout());
jTextField1.setText("jTextField1");
jTextField1.setPreferredSize(new java.awt.Dimension(250, 20));
getContentPane().add(jTextField1);
jTextField2.setText("jTextField2");
jTextField2.setPreferredSize(new java.awt.Dimension(250, 20));
getContentPane().add(jTextField2);
jTextField3.setText("jTextField3");
jTextField3.setPreferredSize(new java.awt.Dimension(250, 20));
getContentPane().add(jTextField3);
jTextField4.setText("jTextField4");
jTextField4.setPreferredSize(new java.awt.Dimension(250, 20));
getContentPane().add(jTextField4);
jTextField5.setText("jTextField5");
jTextField5.setPreferredSize(new java.awt.Dimension(250, 20));
getContentPane().add(jTextField5);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame2().setVisible(true);
}
});
}
// Variables declaration - do not modify
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;
// End of variables declaration
}