This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Re: variable in JLabel in custom code
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 13, 2008
04:57 AM
variable in JLabel in custom code
My requirement is to display a panel which will have some radio buttons and text. the custom code looks like this:
When the panel is displayed, instead of the value of String "VS_Version", 'null is displayed.
like "These applications require runtime libraries of Visual C++null or higher to run"
Am I doing anything wrong?
JLabel line1, line2, line3, line4;
JRadioButton Button1, Button2;
static String Button2_Name = "No";
static String Button1_Name = "Yes";
static String VS_Version;
public boolean setupUI(CustomCodePanelProxy customCodePanelProxy)
{
if (initPanel == true)
return true;
initPanel = true;
// capture PanelProxy for later use.
ccpp = customCodePanelProxy;
init();
return true; // display this panel
}
public void init()
{
setLayout(new GridBagLayout());
VS_Version = System.getenv("VS_VERSION");
}
private JPanel createPane()
{
JPanel main = new JPanel(new GridBagLayout());
// set the background as white
main.setBackground(Color.white);
main.setForeground(Color.black);
Insets firstLabelInsets = new Insets(3, 5, 0, 0);
Insets nextLabelInsets = new Insets(5, 5, 0, 0);
GridBagConstraints gbc = new GridBagConstraints();
line1 = new JLabel("These applications require runtime libraries");
line1.setFont(new Font("Dialog", Font.PLAIN, 12));
line2 = new JLabel();
line2.setText("of Visual C++ " + VS_Version + "or higher to run. If you do not have it");
line2.setFont(new Font("Dialog", Font.PLAIN, 12));
......
When the panel is displayed, instead of the value of String "VS_Version", 'null is displayed.
like "These applications require runtime libraries of Visual C++null or higher to run"
Am I doing anything wrong?
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 13, 2008
07:53 AM
You need to add the lines to the GridBag layout. Something like add(line1, gbc) after you set the constraints for line1. You will need to do that for each item you are adding to the Panel. Maybe you are already doing that but it doesn't look like it from the code you posted.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 13, 2008
10:29 PM
Yes, It's already there in my code.. I posted incomplete code..
The code was working fine.. The only change I did is that I have added the variable in JLabel. But that doesn't seem to work.
Earlier part of code:
The modified code:
The code was working fine.. The only change I did is that I have added the variable in JLabel. But that doesn't seem to work.
Earlier part of code:
line1 = new JLabel("These applications require runtime libraries");
line1.setFont(new Font("Dialog", Font.PLAIN, 12));
line2 = new JLabel("of Visual C++ 2005 or higher to run. If you do not have it");
line2.setFont(new Font("Dialog", Font.PLAIN, 12));
The modified code:
static String VS_Version;
VS_Version = System.getenv("VS_VERSION");
line1 = new JLabel("These applications require runtime libraries");
line1.setFont(new Font("Dialog", Font.PLAIN, 12));
line2 = new JLabel();
line2.setText("of Visual C++ " + VS_Version + "or higher to run. If you do not have it");
line2.setFont(new Font("Dialog", Font.PLAIN, 12));
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 14, 2008
09:57 AM
I would say that the value that VS_VERSION is getting back must be null then. You can try poping up a dialog box with the value of VS_Version to see what it is, I do this when in development to see what my values are while I am working with them.
