Eclipse GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE))) .addGap(20,20,20)) ); layout.setVerticalGroup( 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\u SIZE,160,Short.MAX\u值) .addComponent(jScrollPane2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(jDBXExploreCurrentPathTextField、javax.swing.GroupLayout.PREFERRED\u SIZE、javax.swing.GroupLayout.DEFAULT\u SIZE、javax.swing.GroupLayout.PREFERRED\u 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\u SIZE,Short.MAX\u VALUE)) ); 包装(); }////GEN-END:initComponents 公共静态void main(字符串参数[]){ /*设置Nimbus的外观和感觉*/ // /*如果Nimbus(在JavaSE6中引入)不可用,请使用默认的外观。 *详情请参阅http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ // /*创建并显示表单*/ invokeLater(new Runnable()){ 公开募捐{ 新ExploreDBX().setVisible(true); } }); } //变量声明-不修改//GEN-BEGIN:变量 私有javax.swing.JButton jButton4; 私有javax.swing.JButton jDBXCreateNewDir; 私有javax.swing.JButton jDBXDeleteFolder; 私有javax.swing.JList jDBXDirList; 私有javax.swing.JButton jDBXDownloadFiles; 私有javax.swing.JLabel jdbxexplorerecurrentPathLabel; 私有java.awt.TextField jdbxexplorerecurrentpathtextfield; 私有javax.swing.JLabel jDBXExploreDirFileLabel; 私有javax.swing.JList jDBXExploreDirFileList; 私有javax.swing.JLabel jDBXExploreDirLabel; 私有javax.swing.JButton jDBXUploadFiles; 私有javax.swing.JScrollPane-jScrollPane1; 私有javax.swing.JScrollPane-jScrollPane2; //变量结束声明//GEN-End:变量 }
稍后编辑#1Eclipse GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE))) .addGap(20,20,20)) ); layout.setVerticalGroup( 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\u SIZE,160,Short.MAX\u值) .addComponent(jScrollPane2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(jDBXExploreCurrentPathTextField、javax.swing.GroupLayout.PREFERRED\u SIZE、javax.swing.GroupLayout.DEFAULT\u SIZE、javax.swing.GroupLayout.PREFERRED\u 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\u SIZE,Short.MAX\u VALUE)) ); 包装(); }////GEN-END:initComponents 公共静态void main(字符串参数[]){ /*设置Nimbus的外观和感觉*/ // /*如果Nimbus(在JavaSE6中引入)不可用,请使用默认的外观。 *详情请参阅http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ // /*创建并显示表单*/ invokeLater(new Runnable()){ 公开募捐{ 新ExploreDBX().setVisible(true); } }); } //变量声明-不修改//GEN-BEGIN:变量 私有javax.swing.JButton jButton4; 私有javax.swing.JButton jDBXCreateNewDir; 私有javax.swing.JButton jDBXDeleteFolder; 私有javax.swing.JList jDBXDirList; 私有javax.swing.JButton jDBXDownloadFiles; 私有javax.swing.JLabel jdbxexplorerecurrentPathLabel; 私有java.awt.TextField jdbxexplorerecurrentpathtextfield; 私有javax.swing.JLabel jDBXExploreDirFileLabel; 私有javax.swing.JList jDBXExploreDirFileList; 私有javax.swing.JLabel jDBXExploreDirLabel; 私有javax.swing.JButton jDBXUploadFiles; 私有javax.swing.JScrollPane-jScrollPane1; 私有javax.swing.JScrollPane-jScrollPane2; //变量结束声明//GEN-End:变量 },eclipse,swing,windowbuilder,Eclipse,Swing,Windowbuilder,稍后编辑#1 创建一个新文件,测试并调整大小,我需要找出导致此问题的原因,并决定是否应该重做整个界面,或许可以稍微整理一下它在initComponents方法中调用setResizeable(false)。去掉它,它就会工作 WindowsBuilder根本不使用.form文件。Eclipse和Netbeans有不同的GUI构建器实现。这个问题是由pack()引起的在构造函数末尾调用。删除它,调整大小将按预期工作。已删除设置大小可调整。。。GUI的行为与此相同,如果Resizeable设置为tr
创建一个新文件,测试并调整大小,我需要找出导致此问题的原因,并决定是否应该重做整个界面,或许可以稍微整理一下它在initComponents方法中调用setResizeable(false)。去掉它,它就会工作
WindowsBuilder根本不使用.form文件。Eclipse和Netbeans有不同的GUI构建器实现。这个问题是由
pack()引起的代码>在构造函数末尾调用。删除它,调整大小将按预期工作。已删除设置大小可调整。。。GUI的行为与此相同,如果Resizeable设置为true,也可以从框架属性中进行检查。如果Resizeable设置为true,则重新启动IDE,它的行为与此相同,我需要指出的是,我可以调整其他组件(JTextField等)的大小,而不会出现任何问题另外,旁注#我不确定Netbeans自动生成的核心是否与Eclipse WindowBuilder的功能兼容,因此应该以旧的方式手动定义整个结构,或者从头开始重做整个界面?@cristi_b当我删除setResizeable()时,框架会按预期重新调整大小,这是在eclipse中。您是否试图使框架内的组件与框架一起重新调整尺寸?如果是这样,您需要使用允许组件重新调整大小的布局。组布局将使组件保持静态,除非您专门将其设置为增长。尝试将它们设置为垂直和水平增长|我会将这两个jlist放在它们自己的面板中,并将按钮和文本字段放在另一个面板中。按钮和字段仍然可以使用组布局,但使内容窗格具有边框布局。将面板放置在中间,按钮位于南部。BorderLayout中的任何额外空间都会流向中心组件。对于WindowsBuilder,它将忽略.form文件。它将对netbeans生成的代码进行反向工程,然后您可以使用GUIBuilder根据需要对其进行修改。但是,由于Netbeans依赖于.form文件,因此生成的代码不能与Netbeans GUI生成器一起使用。
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
}