Results 1 to 7 of 7
  1. #1
    Markmywoods is offline Member
    Join Date
    Feb 2016
    Posts
    14
    Rep Power
    0

    Default I have a gui problem i know what it is but how is what idk

    So basically i need to load the file to get the get budget report method but to read the file youre supposed to hit load and they pick the file and i dont know how to make that file accessible to the method also because he btn is private

    Java Code:
    private void loadFileBtnActionPerformed(java.awt.event.ActionEvent evt) {                                            
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
            int result = fileChooser.showOpenDialog(this);
            if (result == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();
            
           
            
            Client clients = new Client();
            
            clients.loadClientFile(selectedFile);
            
            Contact contacts = clients.getContact();
            
            jLabel9.setText(clients.getFirstName() + " " + clients.getLastName() );
            jLabel10.setText(contacts.getPhone());
            jLabel11.setText(contacts.getHomeAddress());
            jLabel12.setText(contacts.getEmail());
            
            
    // TODO add your handling code here:
        }                                           
        }
        private void saveFileBtnActionPerformed(java.awt.event.ActionEvent evt) {                                            
            Client clients = new Client();
            
            JFrame parentFrame = new JFrame();
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setDialogTitle("Specify a file to save");   
     
            int userSelection = fileChooser.showSaveDialog(parentFrame);
     
            if (userSelection == JFileChooser.APPROVE_OPTION) {
            File fileToSave = fileChooser.getSelectedFile();
            
            clients.saveClientFile(fileToSave);
            
    
        }                                           
        }
        
        private void ExitBtnActionPerformed(java.awt.event.ActionEvent evt) {                                        
             System.exit(0);
        }                                       
    
        private void BudgetReportBtnActionPerformed(java.awt.event.ActionEvent evt) {                                                
            Client clients = new Client();
            textAreas.setText(clients.getBudgetReport());
            
        }                                               
    
        private void TransReportBtnActionPerformed(java.awt.event.ActionEvent evt) {                                               
            Client clients = new Client();
            textAreas.setText(clients.getTransactionReport());

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: I have a gui problem i know what it is but how is what idk

    What is the Client class for?
    What does it do?

    Why, for each action, do you create a new one?

    At first glance it looks to me like that is a controller, in which case it should be listening on events from the GUI.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Markmywoods is offline Member
    Join Date
    Feb 2016
    Posts
    14
    Rep Power
    0

    Default Re: I have a gui problem i know what it is but how is what idk

    Quote Originally Posted by Tolls View Post
    What is the Client class for?
    What does it do?

    Why, for each action, do you create a new one?

    At first glance it looks to me like that is a controller, in which case it should be listening on events from the GUI.
    The client class is a big class that calls other classes to be able to read the file correctly.
    I create a new one because idk how to make it work for all of them yet I could make it at the top but thats not my main concern unless it can help me with my problem. how do i make it listen so it is able to use the file that was loaded also.

  4. #4
    Markmywoods is offline Member
    Join Date
    Feb 2016
    Posts
    14
    Rep Power
    0

    Default Re: I have a gui problem i know what it is but how is what idk

    Thanks that was the problem client object not being in the main

  5. #5
    Markmywoods is offline Member
    Join Date
    Feb 2016
    Posts
    14
    Rep Power
    0

    Default Re: I have a gui problem i know what it is but how is what idk

    I thought the problem was fixed but once I formatted the getBudgetReport method it doesn't set the text once you press the gui . I think it is because it was loaded in a private thing. How do I make it so the button for budget report can also pull data from the file

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: I have a gui problem i know what it is but how is what idk

    make it so the button for budget report can also pull data from the file
    Add code to the method to read the file.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: I have a gui problem i know what it is but how is what idk

    Quote Originally Posted by Markmywoods View Post
    I thought the problem was fixed but once I formatted the getBudgetReport method it doesn't set the text once you press the gui . I think it is because it was loaded in a private thing. How do I make it so the button for budget report can also pull data from the file
    What does the budgetReportActionPerformed method look like now?
    I would have thought it simply called the getBudgetReport method on the Client object?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 5
    Last Post: 11-11-2015, 01:16 PM
  2. Replies: 0
    Last Post: 11-07-2012, 01:44 PM
  3. Small problem with problem with Java, C++ parse program.
    By dragstang86 in forum New To Java
    Replies: 4
    Last Post: 10-30-2011, 04:43 AM
  4. Replies: 9
    Last Post: 09-21-2010, 05:15 PM
  5. simple line problem / for loop problem
    By helpisontheway in forum New To Java
    Replies: 1
    Last Post: 11-17-2009, 07:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •