netbeans 生成的一些代码不让修改如何设置成可以修改呢?

SambaGao 2010-02-24 02:22:15
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JPanel mainPanel;
private javax.swing.JMenuBar menuBar;
...全文
535 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
runshine 2010-02-24
  • 打赏
  • 举报
回复
关于1可以在 initComponents()之前添加this.setUndecorated(true);(禁用标题栏)来达到禁止拖动的目的...
runshine 2010-02-24
  • 打赏
  • 举报
回复
引用 4 楼 nihaozhangchao 的回复:
两个功能如何完成?


1.
  使登陆窗口不能拖动

2.
  窗体退出


1.
这个恐怕不是IDE能帮你完成的,自己写监控drag事件的代码

2.
在"设计区",点击选择最外的窗体(jframe),属性选择区有个defaultCloseOperation,里边有几个选项就是对应的点击窗体的关闭按钮后的操作EXIT_ON_CLOSE,DISPOSE(DISPOSE_ON_CLOSE)这两个是关闭操作
SambaGao 2010-02-24
  • 打赏
  • 举报
回复
两个功能如何完成?


1.
使登陆窗口不能拖动

2.
窗体退出
SambaGao 2010-02-24
  • 打赏
  • 举报
回复
这是netbeans 生成的

package blcpos2010_01;
import blcpos2010_01.gjhohj.client.view.ClientMainFrame;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;

public class Blcpos2010_01View extends FrameView {

public Blcpos2010_01View(SingleFrameApplication app) {
super(app);

initComponents();

private void initComponents() {

mainPanel = new javax.swing.JPanel();
username = new javax.swing.JLabel();
password = new javax.swing.JLabel();
usernameText = new javax.swing.JTextField();
passwordText = new javax.swing.JTextField();
ok = new javax.swing.JButton();
cancel = new javax.swing.JButton();
statusPanel = new javax.swing.JPanel();
javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
statusMessageLabel = new javax.swing.JLabel();
statusAnimationLabel = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();

org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(blcpos2010_01.Blcpos2010_01App.class).getContext().getResourceMap(Blcpos2010_01View.class);
mainPanel.setToolTipText(resourceMap.getString("mainPanel.toolTipText")); // NOI18N
mainPanel.setName("mainPanel"); // NOI18N

username.setText(resourceMap.getString("username.text")); // NOI18N
username.setName("username"); // NOI18N

password.setText(resourceMap.getString("password.text")); // NOI18N
password.setName("password"); // NOI18N

usernameText.setText(resourceMap.getString("usernameText.text")); // NOI18N
usernameText.setName("usernameText"); // NOI18N

passwordText.setText(resourceMap.getString("passwordText.text")); // NOI18N
passwordText.setName("passwordText"); // NOI18N

ok.setText(resourceMap.getString("ok.text")); // NOI18N
ok.setActionCommand(resourceMap.getString("ok.actionCommand")); // NOI18N
ok.setName("ok"); // NOI18N
ok.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okActionPerformed(evt);
}
});
cancel.setText(resourceMap.getString("cancel.text")); // NOI18N
cancel.setName("cancel");
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addGap(39, 39, 39)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(password)
.addGroup(mainPanelLayout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(ok)))
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(passwordText)
.addComponent(usernameText, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(mainPanelLayout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(cancel)))
.addContainerGap(46, Short.MAX_VALUE))
);
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addGap(44, 44, 44)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(username, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
.addGap(32, 32, 32)
.addComponent(password, javax.swing.GroupLayout.DEFAULT_SIZE, 15, Short.MAX_VALUE))
.addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(usernameText)
.addGap(29, 29, 29)
.addComponent(passwordText)))
.addGap(30, 30, 30)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ok)
.addComponent(cancel))
.addGap(87, 87, 87))
);

username.getAccessibleContext().setAccessibleName(resourceMap.getString("jLabel1.AccessibleContext.accessibleName")); // NOI18N

statusPanel.setName("statusPanel"); // NOI18N

statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

statusMessageLabel.setName("statusMessageLabel"); // NOI18N

statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
jLabel4.setName("jLabel4"); // NOI18N

javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
statusPanel.setLayout(statusPanelLayout);
statusPanelLayout.setHorizontalGroup(
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(statusPanelLayout.createSequentialGroup()
.addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(statusMessageLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 244, Short.MAX_VALUE)
.addComponent(statusAnimationLabel))
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
.addContainerGap(85, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
statusPanelLayout.setVerticalGroup(
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(statusPanelLayout.createSequentialGroup()
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(statusMessageLabel)
.addComponent(statusAnimationLabel))
.addGap(3, 3, 3))
);

setComponent(mainPanel);
setStatusBar(statusPanel);
}// </editor-fold>

private void okActionPerformed(java.awt.event.ActionEvent evt) {

usernameText.setText("nihao");
//自已先退出

// new ClientMainFrame().show() ;
}


// Variables declaration - do not modify
private javax.swing.JButton cancel;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel mainPanel;
private javax.swing.JButton ok;
private javax.swing.JLabel password;
private javax.swing.JTextField passwordText;
private javax.swing.JLabel statusAnimationLabel;
private javax.swing.JLabel statusMessageLabel;
private javax.swing.JPanel statusPanel;
private javax.swing.JLabel username;
private javax.swing.JTextField usernameText;
// End of variables declaration

private final Timer messageTimer;
private final Timer busyIconTimer;
private final Icon idleIcon;
private final Icon[] busyIcons = new Icon[15];
private int busyIconIndex = 0;

private JDialog aboutBox;
}

runshine 2010-02-24
  • 打赏
  • 举报
回复
netbeans不允许直接在编辑区修改自动生成的代码
可以用第三方编辑器修改源文件,不过下次再用NB打开会被还原

其实按NB视图编辑器的意思来说,它不允许你修改自动生成的代码
而是应该在视图区的添加/修改组件前/后定制代码
即可得到自己定制的代码
跟VS的视图编辑器相比确实显得有点繁琐

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧