Results 1 to 8 of 8
Thread: jLabel is Private
- 03-20-2011, 08:35 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 29
- Rep Power
- 0
jLabel is Private
Hello, i need your help as soon as posible.
I am creating a project on Netbeans and java with GUI.
I have many JFrame forms but the problem is this: When i try to change the text to a label from other form i cant because i Private.
e.g: I have 2 JFrame forms (form1 and form2) i try to change the value (setText) to a label on form2 from the code of form1 but it return me that the label is private how can i solve it?
- 03-20-2011, 08:40 AM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
create a public setter-method in your form2 class. additional, the form1 need a reference to an instance of form2 !
Java Code:class Form2{ private Jlabel label ...... public void setLabelText(String txt){ label.setText(txt); } ...... }Java Code:class Form1{ ..... form2instance.setLabelText("......"); .... }
- 03-20-2011, 09:38 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 29
- Rep Power
- 0
can you explain it with more details?
The label name is jLabel3 and i want FROM form1 to change jLabel3 of form2.
Thank you.
-
What details do you want? What question do you have about getter and setter methods?
- 03-20-2011, 11:55 AM #5
Member
- Join Date
- Sep 2010
- Posts
- 29
- Rep Power
- 0
My question is:
how to create this "private Jlabel label"
and how to call the method that we create in form2
-
Your question is low on details and this is probably why no one has answered it yet. Please check out the link in my signature below on how to ask smart questions and it will help give you suggestions on the information we would need to be able to give you an answer that could possibly help you.
- 03-20-2011, 07:40 PM #7
Member
- Join Date
- Sep 2010
- Posts
- 29
- Rep Power
- 0
Sorry for that, but English is not my nuture language =\
Now, the private jLabel label; is not correct and compiler show it as fault
Can you write full please?
- 03-21-2011, 04:33 PM #8
Member
- Join Date
- Sep 2010
- Posts
- 29
- Rep Power
- 0
I try the code above but when i write "private jLabel3 label;" the compiler return me "cannot find symbol".Java Code:public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new result().setVisible(true); } private jLabel3 label; public void setLabelText(String txt){ label.setText(txt); } }); }
I am sure that, this code "private jLabel....." is not the full but eRaaa give me a part. So can anyone help me please?
Similar Threads
-
Anyone else get this private message?
By Fubarable in forum New To JavaReplies: 20Last Post: 03-18-2011, 11:26 AM -
Ideas about private to private IP networking over the Internet
By mr_anderson in forum Advanced JavaReplies: 7Last Post: 06-28-2010, 07:52 AM -
Adding a JLabel to a JPanel - jlabel not showing
By Bongeh in forum New To JavaReplies: 17Last Post: 04-06-2010, 11:02 PM -
private
By Gary_10 in forum New To JavaReplies: 1Last Post: 01-29-2010, 12:42 AM -
private array
By tnght in forum New To JavaReplies: 10Last Post: 12-05-2009, 08:43 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks