修改变量声明(初学者) [英] Modifying variable declaration (beginner)
本文介绍了修改变量声明(初学者)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用JFrames. Java自行声明变量:
Hi, I''m using JFrames. Java declares variables on its own:
// Variables declaration - do not modify
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
等等等等.
现在可以将私人变成公众吗? ..因为我不允许对其进行编辑.
谢谢.
etc etc..
Now is it possible to change that private into a public? ..As I''m not allowed to edit it.
Thanks.
推荐答案
这些变量由编辑器声明,并且如果您更改某些内容或再次添加该组件,可能会被覆盖,因为它找不到私有版本.它早先宣布了.
通常,表单上的组件由表单本身内的代码控制.这样可以保持整洁美观.
这不太干净和清晰:
Those variables are declared by your editor and will probably be overwritten if you change something or add that component again because it can'' t find the private version it declared earlier.
Normally the components on a form are controlled by the code within the form itself. This keeps it nice and clean.
This is much less clean and clear:
JProgressFrame.jLabel1.SetText("There is some progress...");
与此相比:
Compared to this:
JProgressFrame.SetProgressText("There is some progress...");
但是,如果您真的想在表单外部公开组件,则应该为每个组件创建一个吸气剂.
祝你好运!
But if you really want to expose the components outside your form you should create a getter for each component.
Good luck!
这篇关于修改变量声明(初学者)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文