这是从 Netbeans 迁移到 Eclipse 4.3 和 WindowBuilder 的代码
我无法从 GUI 调整框架的大小,我也不明白为什么它不可能,当我选择根框架并拖动边缘时,框架根本不会更新。
它与正确使用 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
创建了一个新文件,测试并调整大小工作,我需要找出导致此问题的原因并决定是否应该重做整个界面并可能整理一下