Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi, I'm using JFrames. Java declares variables on its own:

CSS
// 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.
Posted

1 solution

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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900