• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

Swing problems - setVisible not working for my form

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
SketchySteve
Asked:
SketchySteve
  • 7
  • 2
1 Solution
 
zzynxSoftware engineerCommented:
>> 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
 
zzynxSoftware engineerCommented:
>> ... 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
 
zzynxSoftware engineerCommented:
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
zzynxSoftware engineerCommented:
Other remark:

I wonder why you define saverSelectedRButtonAction() and borrowerSelectedRButtonAction() as static?
0
 
SketchySteveAuthor Commented:
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
 
zzynxSoftware engineerCommented:
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
 
SketchySteveAuthor Commented:
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
 
zzynxSoftware engineerCommented:
>> Thanks so much for your help
You're welcome.

Please close this question by accepting one of my comments.
0
 
zzynxSoftware engineerCommented:
Thanks for accepting.
(P.S. For the people reading this afterwards it's better to accept the comment that helped you)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now