只有一個選項可以將JFrame和JPanel添加到項目中。我嘗試編輯JFrame類來擴展JWindow,但是它留下了NetBeans的自動生成的代碼,並且出現錯誤,並且無法編輯此代碼。如何將JWindow添加到NetBeans項目並使用GUI編輯器進行編輯?
0
A
回答
3
您可以創建自己的模板......
地將這兩個文件夾...\NetBeans\7.2.1\config\Templates\GUIForms
。
在Windows 7這是C:\Users\{your user name}\AppData\Roaming\NetBeans\7.2.1\config\Templates\GUIForms
JWindow.java
<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">
<#if package?? && package != "">
package ${package};
</#if>
/**
*
* @author ${user}
*/
public class ${name} extends javax.swing.JWindow {
/** Creates new form ${name} */
public ${name}() {
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() {
pack();
}
// </editor-fold>//GEN-END:initComponents
/**
* @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(${name}.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(${name}.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(${name}.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(${name}.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 ${name}().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}
JWindow.form
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
</Form>
+0
........我的帽子向下 – mKorbel 2013-02-25 08:51:47
相關問題
- 1. Netbeans GUI編輯器問題
- 2. 使用netbeans和eclipse編輯netbeans項目
- 3. 如何將編輯器添加到Eclipse?
- 4. 如何在Netbeans項目中編輯Makefile?
- 5. Eclipse - 編輯web.xml像Netbeans(GUI)
- 6. 編輯/添加項目到Resources.resx
- 7. 的NetBeans GUI編輯器皮膚/主題
- 8. Netbeans GUI編輯器不支持ASCII - Java
- 9. Netbeans Java GUI編輯器預覽問題
- 10. Netbeans .form而不是GUI編輯器
- 11. 使用Komodo將當前項目添加到python路徑編輯
- 12. 如何將當前編輯的文件添加到項目
- 13. 將AMPL添加到SCITE編輯器並添加GLPK求解器
- 14. 如何將新行添加到datagridview並在C#winform中進行編輯?
- 15. 將編輯器添加到組件
- 16. 如何使用Team Foundation Server打開項目以進行編輯
- 17. 動態地將行添加到表並使內容可編輯
- 18. 如何在Flex列表組件中編輯項目編輯器?
- 19. 如何填充QTableWidget的可編輯的項目,並沒有可編輯項目
- 20. 如何在NetBeans中使用Brackets.io編輯器縮進HTML標籤?
- 21. 如何編輯NSOutlineView項目
- 22. 如何編輯項目?
- 23. 如何在FLUID中編輯小部件gui編輯器
- 24. 內聯編輯並添加
- 25. Netbeans使用可視化編輯器添加彈出菜單
- 26. 編輯所有選擇的項目到一個編輯器
- 27. 如何添加編輯選項列表
- 28. 使用Javascript進行編輯
- 29. 使用xpath進行編輯
- 30. 使用awk進行編輯
創建你自己了'JFrame'形式和改變'擴展JFrame'到'擴展JWindow',修復導入。在你做任何改變之前做這個。對我來說工作得很好。 – MadProgrammer 2013-02-25 02:06:51
這會使此行(現在無效)行無法編輯:setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); – Ognjen 2013-02-25 02:09:12
你使用的是什麼版本的netbeans? – MadProgrammer 2013-02-25 03:58:59