private void launchEventPanel(String title) {
EventQueue.invokeLater(new Runnable(title) {
public void run() {
JFrame myFrame = new JFrame();
myFrame.setTitle(this.val$title);
myFrame.setIconImage(CrConference.this.mainCore.myPanel.myIconManager.getPromptIcon(Mart.class.toString()));
myFrame.getContentPane().add(Conference.this.myEventPanel, "Center");
myFrame.pack();
myFrame.setVisible(true);
}
});
}
i got some code that i am trying to compile and understand. help highly appreciated
val$title
a perfectly valid Java identifier -- it's just as valid as foobar
-- but the "rule" is to not use it (except tools that generate code automatically) - NoName 2012-04-05 18:31
This line:
myFrame.setTitle(this.val$title);
Is simply setting the title of a JFrame
object, using the value of the attribute val$title
for doing so. val$title
is an instance attribute of the current class, its name is a bit unusual (because of the $
) but nevertheless, valid for an identifier in Java.
As described here and here, the argument to the Runnable
constuctor and "this.val$" to the field name is added by the compiler and shows up in the generated bytecode. Hence these extra things are reflected in the decompiled code.
To get the original decompiled code, add final
to the declaration of title
and remove title
from the call to Runnable
and the this.val$
from in front of title
:
private void launchEventPanel(final String title) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame myFrame = new JFrame();
myFrame.setTitle(title);
myFrame.setIconImage(CrConference.this.mainCore.myPanel.myIconManager.getPromptIcon(Mart.class.toString()));
myFrame.getContentPane().add(Conference.this.myEventPanel, "Center");
myFrame.pack();
myFrame.setVisible(true);
}
});
}
line 5 is just setting the title of the frame (the text you see on the top of the window frame in windows) "this.val$title" is just a local memeber named val$title that whoever wrote the code stored the title string in.
While it is a bit uncommon to see most languages based on C treat $ as an alphapetic character, like a-z or A-Z.