Solved

Swing problems - setVisible not working for my form

Posted on 2004-10-08
9
272 Views
Last Modified: 2013-11-23
As a small project I'm creating a user interface for a customer DB. On one screen the user can choose input a borrower or a saver customer type. What I want to do is hide the borrower fields when a saver is selected and vice versa.

I have one method to create the GUI and some methods attached to the buttons. Below is the code triggered when a borrower is selected - the loanAmountField and savingsAmountField part works fine but the Lables still arent set to Visible (or Invisible when a saver is selected).

  private static void borrowerSelectedRButtonAction(java.awt.event.ActionEvent evt){
        loanAmountField.setEnabled(true);
        .setEnabled(false);
        customerMonthlyRepaymentRateLabel.setVisible(true);
        customerLenghtOfLoanLabel.setVisible(true);
        customerMortgageInterestRateLabel.setVisible(true);
    }

I've declared all the variables i'm using in the root class so they should be visible.

So i've got two questions

A : Why arent the fields becoming visible / invisible on the form when I set them that way?

B : When creating a GUI were should GUI Objects be declared and initialised? Most Objects such as buttons and Panels wont need to be accessed from outside my createGUI method - so should they be declared / initialised inside the method or should all objects be declared in the class and initialised in the method?

Here is the code for the whole program, just click on the add client button = when the radio buttons are used the customerMortgageInterestRateLabel and others should switch between visibale and invisible.

Thanks

Steve



/*/*
 * MenuSystem.java
 *
 * Created on 05 October 2004, 00:51
 */

/**
 *
 * @author  Steve
 */
import javax.swing.*;
import java.awt.*;
import org.netbeans.lib.awtextra.*; // Used for "Absolute Constraints"


public class MenuSystem {
   
    private static JPanel cardPanel,  addCustomerPanel;
    private static CardLayout cardLayout = new CardLayout();                    
    private static JTextField loanAmountField, savingsAmountField;
    private static JLabel customerMonthlyRepaymentRateLabel, customerLenghtOfLoanLabel,
                   customerMortgageInterestRateLabel;
   
     
    /** Creates a new instance of MenuSystem */
    public MenuSystem() {
       
    }
   
   
    private static void setUpGUI(){
        // Create and set up frame.
        JFrame.setDefaultLookAndFeelDecorated(true);
        JFrame frame = new JFrame("Virtual Bank");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
        // Set Root Container Panel
      JPanel rootPanel = new JPanel();
        rootPanel.setPreferredSize(new java.awt.Dimension(490, 330));
        rootPanel.setLayout(new AbsoluteLayout());
       
        // Set Header Label.
        JLabel headerLabel = new javax.swing.JLabel();
        headerLabel.setText("Virtual Bank Customer DB");
        headerLabel.setFont(new java.awt.Font("Karate", 1, 18));
        headerLabel.setBorder(new javax.swing.border.EtchedBorder());
       
        // Set card panel
        cardPanel = new JPanel();
        cardPanel.setBackground(new java.awt.Color(255, 255, 255));
        cardPanel.setBorder(new javax.swing.border.EtchedBorder());
        cardPanel.setLayout(cardLayout);
       
       
        // Set Main Menu Screen Panel
        JPanel mainMenuPanel = new JPanel();
        mainMenuPanel.setBackground(new java.awt.Color(255, 51, 102));
        mainMenuPanel.setBorder(new javax.swing.border.EtchedBorder());
        mainMenuPanel.setLayout(new AbsoluteLayout());
       
            // Set Componants for Main Screen Panel
            JLabel mainMenuLabel = new javax.swing.JLabel("Main Menu");
            JButton addClientButton = new JButton("Add Client");
            JButton removeClientButton = new JButton("Remove Client");
            JButton showBadBorrowersButton = new JButton("Show Bad Borrowers");
            JButton adjustRatesButton = new JButton("Adjust Rates");
            JButton loadDBButton = new JButton("Load DB");
            JButton saveDBButton = new JButton("Save DB");
           
            // Add Componants to Menu Screen Panel
            mainMenuPanel.add(mainMenuLabel, new AbsoluteConstraints(200, 0, 80, 20));
            mainMenuPanel.add(addClientButton, new AbsoluteConstraints(20, 40, 155, 20));
            mainMenuPanel.add(removeClientButton, new AbsoluteConstraints(20, 65, 155, 20));
            mainMenuPanel.add(showBadBorrowersButton, new AbsoluteConstraints(20, 90, 155, 20));
            mainMenuPanel.add(adjustRatesButton, new AbsoluteConstraints(260, 40, 155, 20));
            mainMenuPanel.add(loadDBButton, new AbsoluteConstraints(260, 65, 155, 20));
            mainMenuPanel.add(saveDBButton, new AbsoluteConstraints(260, 90, 155, 20));
           
            // Add Button Functions
            addClientButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cardLayout.show(cardPanel, "addCustomerPanel");
                }
            });
           
           
           
         // Set Add Customer Screen Panel
        addCustomerPanel = new JPanel();
        addCustomerPanel.setBackground(new java.awt.Color(255, 51, 102));
        addCustomerPanel.setBorder(new javax.swing.border.EtchedBorder());
        addCustomerPanel.setLayout(new AbsoluteLayout());
       
            // Set Add Customer Screen Panel
            addCustomerPanel = new JPanel();
            addCustomerPanel.setBackground(new java.awt.Color(255, 51, 102));
            addCustomerPanel.setBorder(new javax.swing.border.EtchedBorder());
            addCustomerPanel.setLayout(new AbsoluteLayout());
           
            // Set Componants for Add Customer Panel
            JLabel addCustomerLabel = new javax.swing.JLabel("Add Customer");
            JLabel customerFirstNameLabel = new javax.swing.JLabel("First Name");
            JLabel customerLastNameLabel = new javax.swing.JLabel("Last Name");
            JLabel customerInitialsLabel = new javax.swing.JLabel("Initials");
            JLabel customerTownLabel = new javax.swing.JLabel("Town");
            JLabel customerDistrictLabel = new javax.swing.JLabel("District");
            JLabel customerStreetLabel = new javax.swing.JLabel("Street");
            JLabel customerPostCodeLabel = new javax.swing.JLabel("Postcode");
            JLabel customerNetMonthlyIncomeLabel = new javax.swing.JLabel("Net Monthly Income");
            JLabel customerMonthlyRepaymentRateLabel = new javax.swing.JLabel("Monthly Repayment Rate");
            JLabel customerLenghtOfLoanLabel = new javax.swing.JLabel("Length of Loan");
            JLabel customerMortgageInterestRateLabel = new javax.swing.JLabel("Morgage Interest Rate");
           
            JLabel loanAmountLabel = new javax.swing.JLabel("Loan Amount");
            JLabel savingsAmountLabel = new javax.swing.JLabel("Savings Amount");
            JLabel customerAddressLabel = new javax.swing.JLabel("Address");
            JLabel customerDOBLabel = new javax.swing.JLabel("DOB");
            JRadioButton borrowerSelectedRButton = new JRadioButton("Borrower Account");
            JRadioButton saverSelectedRButton = new JRadioButton("Saver Account");
            loanAmountField = new JTextField();
            savingsAmountField = new JTextField();
            ButtonGroup customerTypeButtonGroup = new ButtonGroup();
            customerTypeButtonGroup.add(saverSelectedRButton);
            customerTypeButtonGroup.add(borrowerSelectedRButton);
            loanAmountField.setEnabled(false);
            savingsAmountField.setEnabled(false);
            customerMonthlyRepaymentRateLabel.setVisible(true);
            customerLenghtOfLoanLabel.setVisible(true);
            customerMortgageInterestRateLabel.setVisible(true);
           
           
            // Add Componants to Add Customer Panel
            addCustomerPanel.add(addCustomerLabel, new AbsoluteConstraints(180, 0, 120, 20));
            addCustomerPanel.add(customerFirstNameLabel, new AbsoluteConstraints(20, 20, 70, 20));
            addCustomerPanel.add(customerLastNameLabel, new AbsoluteConstraints(20, 40, 70, 20));
            addCustomerPanel.add(customerInitialsLabel, new AbsoluteConstraints(20, 60, 70, 20));
            addCustomerPanel.add(customerDOBLabel, new AbsoluteConstraints(20, 80, 70, 20));
            addCustomerPanel.add(customerTownLabel, new AbsoluteConstraints(20, 100, 70, 20));
            addCustomerPanel.add(customerStreetLabel, new AbsoluteConstraints(20, 120, 70, 20));
            addCustomerPanel.add(customerPostCodeLabel, new AbsoluteConstraints(20, 140, 70, 20));
          addCustomerPanel.add(customerNetMonthlyIncomeLabel, new AbsoluteConstraints(240, 80, 120, 20));
            addCustomerPanel.add(customerMonthlyRepaymentRateLabel, new AbsoluteConstraints(240, 120, 140, 20));  
            addCustomerPanel.add(customerLenghtOfLoanLabel, new AbsoluteConstraints(240, 100, 120, 20));  
            addCustomerPanel.add(customerMortgageInterestRateLabel, new AbsoluteConstraints(240, 140, 150, 20));  
            addCustomerPanel.add(loanAmountLabel, new AbsoluteConstraints(20, 170, 110, 20));
            addCustomerPanel.add(savingsAmountLabel, new AbsoluteConstraints(20, 190, 110, 20));
            addCustomerPanel.add(loanAmountField, new AbsoluteConstraints(130, 170, 50, 20));
            addCustomerPanel.add(savingsAmountField, new AbsoluteConstraints(130, 190, 50, 20));
            addCustomerPanel.add(saverSelectedRButton, new AbsoluteConstraints(240, 190, 160, 20));
            addCustomerPanel.add(borrowerSelectedRButton, new AbsoluteConstraints(240, 170, 160, 20));
           
           
           
            // Add Button Functions
            saverSelectedRButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    saverSelectedRButtonAction(evt);
                }
            });
           
            borrowerSelectedRButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    borrowerSelectedRButtonAction(evt);
                   
                }
            });
           
       
        // CONFIGURE PANELS AND FRAME
           
            // Add Menu Panels to Card Panel
            cardPanel.add(mainMenuPanel, "mainMenuPanel");
            cardPanel.add(addCustomerPanel, "addCustomerPanel");
            // Add Header and Card Panel to Root Panel
            rootPanel.add(headerLabel, new AbsoluteConstraints(100, 10, 260, 40));
            rootPanel.add(cardPanel, new AbsoluteConstraints(20, 65, 450, 225));
            // Configure Frame
            frame.getContentPane().add(rootPanel);
            frame.pack();
            frame.setVisible(true);
       
           
        cardLayout.show(cardPanel, "mainMenuPanel");

    }
 
   
    public static void main (String[] args){
        setUpGUI();
    }
   
   
    private static void saverSelectedRButtonAction(java.awt.event.ActionEvent evt){
        savingsAmountField.setEnabled(true);
        loanAmountField.setEnabled(false);
        customerMonthlyRepaymentRateLabel.setVisible(false);
        customerLenghtOfLoanLabel.setVisible(false);
        customerMortgageInterestRateLabel.setVisible(false);
       
    }
   
    private static void borrowerSelectedRButtonAction(java.awt.event.ActionEvent evt){
        loanAmountField.setEnabled(true);
        savingsAmountField.setEnabled(false);
        customerMonthlyRepaymentRateLabel.setVisible(true);
        customerLenghtOfLoanLabel.setVisible(true);
        customerMortgageInterestRateLabel.setVisible(true);
    }
   
   
}

0
Comment
Question by:SketchySteve
  • 7
  • 2
9 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12258727
>> A : Why arent the fields becoming visible / invisible on the form when I set them that way?
A repaint might be needed.

  on your mainPanel perform:

  mainPanel.revalidate();
  mainPanel.repaint();
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12258775
>> ... or should all objects be declared in the class and initialised in the method?
Yes.

Typical code:

public class MyPanel extends JPanel {
    private JButton theButton;
    private JLabel theLabel;

    public MyPanel() {
        theButton = new JButton();
        thebutton.addActionListener(...);
        theLabel = new JLabel("Hello world");
        theLabel.setIcon(...);
        ...
    }

}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12258997
I see, you have a NullPointerException.

Why?

You have this:
    private static JLabel customerMonthlyRepaymentRateLabel, customerLenghtOfLoanLabel,
                   customerMortgageInterestRateLabel;

and further one this:

            JLabel customerMonthlyRepaymentRateLabel = new javax.swing.JLabel("Monthly Repayment Rate");     // <<< Remove the JLabel
            JLabel customerLenghtOfLoanLabel = new javax.swing.JLabel("Length of Loan");                                 // <<< Remove the JLabel
            JLabel customerMortgageInterestRateLabel = new javax.swing.JLabel("Morgage Interest Rate");           // <<< Remove the JLabel

You have to remove "JLabel" otherwise you just create temporary JLabel objects, while the ones of your class stay null (default)

Then this:

    private static void saverSelectedRButtonAction(java.awt.event.ActionEvent evt){
        savingsAmountField.setEnabled(true);
        loanAmountField.setEnabled(false);
        customerMonthlyRepaymentRateLabel.setVisible(false);      // <<<<<<< NPE, since the labels aren't initialized yet
        customerLenghtOfLoanLabel.setVisible(false);
        customerMortgageInterestRateLabel.setVisible(false);
       
    }

0
 
LVL 37

Expert Comment

by:zzynx
ID: 12259105
Other remark:

I wonder why you define saverSelectedRButtonAction() and borrowerSelectedRButtonAction() as static?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:SketchySteve
ID: 12259673
Which Panel should I use revalidate and repaint on? I've tried it on the add customer panel and the rootPanel. Neither seems to work still. Here is the chnaged bit of code

    private static void borrowerSelectedRButtonAction(java.awt.event.ActionEvent evt){
        loanAmountField.setEnabled(true);
        savingsAmountField.setEnabled(false);
        customerMonthlyRepaymentRateLabel.setVisible(true);
        customerLenghtOfLoanLabel.setVisible(true);
        customerMortgageInterestRateLabel.setVisible(true);
        addCustomerPanel.revalidate();
        addCustomerPanel.repaint();
    }


New program...


/*/*
 * MenuSystem.java
 *
 * Created on 05 October 2004, 00:51
 */

/**
 *
 * @author  Steve
 */
import javax.swing.*;
import java.awt.*;
import org.netbeans.lib.awtextra.*; // Used for "Absolute Constraints"


public class MenuSystem {
   
    private static JPanel cardPanel,  addCustomerPanel, rootPanel, mainMenuPanel;
    private static CardLayout cardLayout = new CardLayout();                    
    private static JTextField loanAmountField, savingsAmountField;
    private static JLabel customerMonthlyRepaymentRateLabel, customerLenghtOfLoanLabel,
                   customerMortgageInterestRateLabel;
   
     
    /** Creates a new instance of MenuSystem */
    public MenuSystem() {
       
    }
   
   
    private static void setUpGUI(){
        // Create and set up frame.
        JFrame.setDefaultLookAndFeelDecorated(true);
        JFrame frame = new JFrame("Virtual Bank");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
        // Set Root Container Panel
      JPanel rootPanel = new JPanel();
        rootPanel.setPreferredSize(new java.awt.Dimension(490, 330));
        rootPanel.setLayout(new AbsoluteLayout());
       
        // Set Header Label.
        JLabel headerLabel = new javax.swing.JLabel();
        headerLabel.setText("Virtual Bank Customer DB");
        headerLabel.setFont(new java.awt.Font("Karate", 1, 18));
        headerLabel.setBorder(new javax.swing.border.EtchedBorder());
       
        // Set card panel
        cardPanel = new JPanel();
        cardPanel.setBackground(new java.awt.Color(255, 255, 255));
        cardPanel.setBorder(new javax.swing.border.EtchedBorder());
        cardPanel.setLayout(cardLayout);
       
       
        // Set Main Menu Screen Panel
        JPanel mainMenuPanel = new JPanel();
        mainMenuPanel.setBackground(new java.awt.Color(255, 51, 102));
        mainMenuPanel.setBorder(new javax.swing.border.EtchedBorder());
        mainMenuPanel.setLayout(new AbsoluteLayout());
       
            // Set Componants for Main Screen Panel
            JLabel mainMenuLabel = new javax.swing.JLabel("Main Menu");
            JButton addClientButton = new JButton("Add Client");
            JButton removeClientButton = new JButton("Remove Client");
            JButton showBadBorrowersButton = new JButton("Show Bad Borrowers");
            JButton adjustRatesButton = new JButton("Adjust Rates");
            JButton loadDBButton = new JButton("Load DB");
            JButton saveDBButton = new JButton("Save DB");
           
            // Add Componants to Menu Screen Panel
            mainMenuPanel.add(mainMenuLabel, new AbsoluteConstraints(200, 0, 80, 20));
            mainMenuPanel.add(addClientButton, new AbsoluteConstraints(20, 40, 155, 20));
            mainMenuPanel.add(removeClientButton, new AbsoluteConstraints(20, 65, 155, 20));
            mainMenuPanel.add(showBadBorrowersButton, new AbsoluteConstraints(20, 90, 155, 20));
            mainMenuPanel.add(adjustRatesButton, new AbsoluteConstraints(260, 40, 155, 20));
            mainMenuPanel.add(loadDBButton, new AbsoluteConstraints(260, 65, 155, 20));
            mainMenuPanel.add(saveDBButton, new AbsoluteConstraints(260, 90, 155, 20));
           
            // Add Button Functions
            addClientButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cardLayout.show(cardPanel, "addCustomerPanel");
                }
            });
           
           
           
         // Set Add Customer Screen Panel
        addCustomerPanel = new JPanel();
        addCustomerPanel.setBackground(new java.awt.Color(255, 51, 102));
        addCustomerPanel.setBorder(new javax.swing.border.EtchedBorder());
        addCustomerPanel.setLayout(new AbsoluteLayout());
       
            // Set Add Customer Screen Panel
            addCustomerPanel = new JPanel();
            addCustomerPanel.setBackground(new java.awt.Color(255, 51, 102));
            addCustomerPanel.setBorder(new javax.swing.border.EtchedBorder());
            addCustomerPanel.setLayout(new AbsoluteLayout());
           
            // Set Componants for Add Customer Panel
            JLabel addCustomerLabel = new javax.swing.JLabel("Add Customer");
            JLabel customerFirstNameLabel = new javax.swing.JLabel("First Name");
            JLabel customerLastNameLabel = new javax.swing.JLabel("Last Name");
            JLabel customerInitialsLabel = new javax.swing.JLabel("Initials");
            JLabel customerTownLabel = new javax.swing.JLabel("Town");
            JLabel customerDistrictLabel = new javax.swing.JLabel("District");
            JLabel customerStreetLabel = new javax.swing.JLabel("Street");
            JLabel customerPostCodeLabel = new javax.swing.JLabel("Postcode");
            JLabel customerNetMonthlyIncomeLabel = new javax.swing.JLabel("Net Monthly Income");
            JLabel customerMonthlyRepaymentRateLabel = new javax.swing.JLabel("Monthly Repayment Rate");
            JLabel customerLenghtOfLoanLabel = new javax.swing.JLabel("Length of Loan");
            JLabel customerMortgageInterestRateLabel = new javax.swing.JLabel("Morgage Interest Rate");
           
            JLabel loanAmountLabel = new javax.swing.JLabel("Loan Amount");
            JLabel savingsAmountLabel = new javax.swing.JLabel("Savings Amount");
            JLabel customerAddressLabel = new javax.swing.JLabel("Address");
            JLabel customerDOBLabel = new javax.swing.JLabel("DOB");
            JRadioButton borrowerSelectedRButton = new JRadioButton("Borrower Account");
            JRadioButton saverSelectedRButton = new JRadioButton("Saver Account");
            loanAmountField = new JTextField();
            savingsAmountField = new JTextField();
            ButtonGroup customerTypeButtonGroup = new ButtonGroup();
            customerTypeButtonGroup.add(saverSelectedRButton);
            customerTypeButtonGroup.add(borrowerSelectedRButton);
            loanAmountField.setEnabled(false);
            savingsAmountField.setEnabled(false);
            customerMonthlyRepaymentRateLabel.setVisible(true);
            customerLenghtOfLoanLabel.setVisible(true);
            customerMortgageInterestRateLabel.setVisible(true);
           
           
            // Add Componants to Add Customer Panel
            addCustomerPanel.add(addCustomerLabel, new AbsoluteConstraints(180, 0, 120, 20));
            addCustomerPanel.add(customerFirstNameLabel, new AbsoluteConstraints(20, 20, 70, 20));
            addCustomerPanel.add(customerLastNameLabel, new AbsoluteConstraints(20, 40, 70, 20));
            addCustomerPanel.add(customerInitialsLabel, new AbsoluteConstraints(20, 60, 70, 20));
            addCustomerPanel.add(customerDOBLabel, new AbsoluteConstraints(20, 80, 70, 20));
            addCustomerPanel.add(customerTownLabel, new AbsoluteConstraints(20, 100, 70, 20));
            addCustomerPanel.add(customerStreetLabel, new AbsoluteConstraints(20, 120, 70, 20));
            addCustomerPanel.add(customerPostCodeLabel, new AbsoluteConstraints(20, 140, 70, 20));
          addCustomerPanel.add(customerNetMonthlyIncomeLabel, new AbsoluteConstraints(240, 80, 120, 20));
            addCustomerPanel.add(customerMonthlyRepaymentRateLabel, new AbsoluteConstraints(240, 120, 140, 20));  
            addCustomerPanel.add(customerLenghtOfLoanLabel, new AbsoluteConstraints(240, 100, 120, 20));  
            addCustomerPanel.add(customerMortgageInterestRateLabel, new AbsoluteConstraints(240, 140, 150, 20));  
            addCustomerPanel.add(loanAmountLabel, new AbsoluteConstraints(20, 170, 110, 20));
            addCustomerPanel.add(savingsAmountLabel, new AbsoluteConstraints(20, 190, 110, 20));
            addCustomerPanel.add(loanAmountField, new AbsoluteConstraints(130, 170, 50, 20));
            addCustomerPanel.add(savingsAmountField, new AbsoluteConstraints(130, 190, 50, 20));
            addCustomerPanel.add(saverSelectedRButton, new AbsoluteConstraints(240, 190, 160, 20));
            addCustomerPanel.add(borrowerSelectedRButton, new AbsoluteConstraints(240, 170, 160, 20));
           
           
           
            // Add Button Functions
            saverSelectedRButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    saverSelectedRButtonAction(evt);
                   
                }
            });
           
            borrowerSelectedRButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    borrowerSelectedRButtonAction(evt);
         
                   
                }
            });
           
       
        // CONFIGURE PANELS AND FRAME
           
            // Add Menu Panels to Card Panel
            cardPanel.add(mainMenuPanel, "mainMenuPanel");
            cardPanel.add(addCustomerPanel, "addCustomerPanel");
            // Add Header and Card Panel to Root Panel
            rootPanel.add(headerLabel, new AbsoluteConstraints(100, 10, 260, 40));
            rootPanel.add(cardPanel, new AbsoluteConstraints(20, 65, 450, 225));
            // Configure Frame
            frame.getContentPane().add(rootPanel);
            frame.pack();
            frame.setVisible(true);
       
           
        cardLayout.show(cardPanel, "mainMenuPanel");

    }
 
   
    public static void main (String[] args){
        setUpGUI();
    }
   
   
    private static void saverSelectedRButtonAction(java.awt.event.ActionEvent evt){
        savingsAmountField.setEnabled(true);
        loanAmountField.setEnabled(false);
        customerMonthlyRepaymentRateLabel.setVisible(false);
        customerLenghtOfLoanLabel.setVisible(false);
        customerMortgageInterestRateLabel.setVisible(false);
        addCustomerPanel.revalidate();
        addCustomerPanel.repaint();
       
    }
   
    private static void borrowerSelectedRButtonAction(java.awt.event.ActionEvent evt){
        loanAmountField.setEnabled(true);
        savingsAmountField.setEnabled(false);
        customerMonthlyRepaymentRateLabel.setVisible(true);
        customerLenghtOfLoanLabel.setVisible(true);
        customerMortgageInterestRateLabel.setVisible(true);
        addCustomerPanel.revalidate();
        addCustomerPanel.repaint();
    }
   
   
}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12259701
Forget about that revalidate() and repaint()

Just change these three lines

            JLabel customerMonthlyRepaymentRateLabel = new javax.swing.JLabel("Monthly Repayment Rate");
            JLabel customerLenghtOfLoanLabel = new javax.swing.JLabel("Length of Loan");
            JLabel customerMortgageInterestRateLabel = new javax.swing.JLabel("Morgage Interest Rate");

to

            customerMonthlyRepaymentRateLabel = new javax.swing.JLabel("Monthly Repayment Rate");
            customerLenghtOfLoanLabel = new javax.swing.JLabel("Length of Loan");
            customerMortgageInterestRateLabel = new javax.swing.JLabel("Morgage Interest Rate");
0
 
LVL 1

Author Comment

by:SketchySteve
ID: 12259735
Sorry zzynx didnt see your other post there :)

Thanks so much for your help, your answer went into more detail than ive got before and really sorted me out. Thanks!


Take Care

Steve

0
 
LVL 37

Accepted Solution

by:
zzynx earned 50 total points
ID: 12267498
>> Thanks so much for your help
You're welcome.

Please close this question by accepting one of my comments.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12316416
Thanks for accepting.
(P.S. For the people reading this afterwards it's better to accept the comment that helped you)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now