这是从Netbeans迁移到Eclipse 4.3和WindowBuilder的代码
我无法从GUI调整Frame的大小,我不明白为什么不可能,当我选择根帧并拖动边缘时,帧根本不会更新。
是否与正确使用LayoutManager有关?据我所知,WindowBuilder没有访问或编辑Netbeans生成的.form文件
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
}
稍后编辑#1
创建了一个新文件,测试并调整了大小的工作,我需要找出导致这个问题的原因并决定是否应该重做整个界面并且可能整理一下
答案 0 :(得分:1)
您在initComponents方法中调用了setResizable(false)。删除它,它会工作。
WindowsBuilder根本不使用.form文件。 Eclipse和Netbeans具有不同的GUI构建器实现。
答案 1 :(得分:1)
此问题是由构造函数末尾的id
调用引起的。删除它,调整大小将按预期工作。