Question

Here's the code migrated from Netbeans to Eclipse 4.3 and WindowBuilder

I can't resize the Frame from GUI and I don't really understand why it isn't possible, when I select the root Frame and drag the edges, the frame won't update at all.

Does it have anything to do with using a LayoutManager properly? As far as I could tell, WindowBuilder isn't accessing or editing the .form file generated by Netbeans

public class ExploreDBX extends javax.swing.JFrame {

    /**
     * Creates new form ExploreDBX and runs the alteration function
     */
    public ExploreDBX() {
        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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton4 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jDBXDirList = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        jDBXExploreDirFileList = new javax.swing.JList();
        jDBXExploreDirLabel = new javax.swing.JLabel();
        jDBXExploreDirFileLabel = new javax.swing.JLabel();
        jDBXExploreCurrentPathLabel = new javax.swing.JLabel();
        jDBXExploreCurrentPathTextField = new java.awt.TextField();
        jDBXUploadFiles = new javax.swing.JButton();
        jDBXDownloadFiles = new javax.swing.JButton();
        jDBXCreateNewDir = new javax.swing.JButton();
        jDBXDeleteFolder = new javax.swing.JButton();

        jButton4.setText("jButton4");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Explore DBX");
        setResizable(false);

        jDBXDirList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jDBXDirListMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jDBXDirList);

        jScrollPane2.setViewportView(jDBXExploreDirFileList);

        jDBXExploreDirLabel.setText("Directories");

        jDBXExploreDirFileLabel.setText("Files");

        jDBXExploreCurrentPathLabel.setText("Current Path");

        jDBXExploreCurrentPathTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jDBXExploreCurrentPathTextFieldActionPerformed(evt);
            }
        });

        jDBXUploadFiles.setText("Upload");
        jDBXUploadFiles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jDBXUploadFilesActionPerformed(evt);
            }
        });

        jDBXDownloadFiles.setText("Download");
        jDBXDownloadFiles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jDBXDownloadFilesActionPerformed(evt);
            }
        });

        jDBXCreateNewDir.setText("New Folder");
        jDBXCreateNewDir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jDBXCreateNewDirActionPerformed(evt);
            }
        });

        jDBXDeleteFolder.setText("Delete");
        jDBXDeleteFolder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jDBXDeleteFolderActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jDBXUploadFiles)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jDBXDownloadFiles)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jDBXCreateNewDir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jDBXDeleteFolder)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jDBXExploreDirLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jDBXExploreDirFileLabel)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jDBXExploreCurrentPathLabel)
                        .addGap(6, 6, 6)
                        .addComponent(jDBXExploreCurrentPathTextField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(20, 20, 20))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jDBXExploreDirLabel)
                    .addComponent(jDBXExploreDirFileLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(jScrollPane2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jDBXExploreCurrentPathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jDBXExploreCurrentPathLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jDBXUploadFiles)
                    .addComponent(jDBXDownloadFiles)
                    .addComponent(jDBXCreateNewDir)
                    .addComponent(jDBXDeleteFolder))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    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 
         */
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ExploreDBX().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jDBXCreateNewDir;
    private javax.swing.JButton jDBXDeleteFolder;
    private javax.swing.JList jDBXDirList;
    private javax.swing.JButton jDBXDownloadFiles;
    private javax.swing.JLabel jDBXExploreCurrentPathLabel;
    private java.awt.TextField jDBXExploreCurrentPathTextField;
    private javax.swing.JLabel jDBXExploreDirFileLabel;
    private javax.swing.JList jDBXExploreDirFileList;
    private javax.swing.JLabel jDBXExploreDirLabel;
    private javax.swing.JButton jDBXUploadFiles;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables
}

later edit # 1

created a new file, tested and resize works, i need to figure out what causes this problem and decide if I should redo the whole interface and maybe tidy it up a bit

Was it helpful?

Solution 2

You have a call to setResizable(false) inside your initComponents Method. Remove that and it will work.

WindowsBuilder does not use .form files at all. Eclipse and Netbeans have different implementations of a GUI builder.

OTHER TIPS

This issue is caused by the pack(); call at the end of the constructor. Remove it and resizing will work as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top