Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:37:18+00:00 2026-06-14T03:37:18+00:00

I am doing an assignment I’m a little stuck on. I have these requirements:

  • 0

I am doing an assignment I’m a little stuck on. I have these requirements:

  • 1 frame with BorderLayout
  • 2 buttons on Panel
  • 1 Panel with GridLayout to put the two buttons on in the SOUTH region
  • 1 FileChooser in a new frame
  • 1 TextArea in the CENTRAL region
  • 1 Label telling what the program does in the NORTH region

I will be taking the input from two files from my temp folder and reading them into
the text field in the middle of the screen.

I can’t figure out why both buttons won’t show up.

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import javax.swing.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class P_Supplemental_11 extends JFrame {

JPanel jpnl1 = new JPanel();
JButton jbtReadFile1 = new JButton("Get Student Names");
JButton jbtReadFile2 = new JButton("Get Student Grades");
JTextField jtxtFilePath = new JTextField();
JLabel jlblDesc = new JLabel("Enter the file name here:");
JTextArea jtxtAfileContents = new JTextArea();

P_Supplemental_11() {
    this.setLayout(new BorderLayout(5, 10));
    jpnl1.setLayout(new GridLayout(2, 2));
    jpnl1.add(jlblDesc);
    jpnl1.add(jtxtFilePath);
    add(jpnl1, BorderLayout.NORTH);
    add(jtxtAfileContents, BorderLayout.CENTER);



    add(jbtReadFile1, BorderLayout.SOUTH);
    jbtReadFile1.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent evt) {

         jbtReadFileActionPerformed(evt);
     }

    });

    add(jbtReadFile2, BorderLayout.SOUTH);
    jbtReadFile2.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent evt) {

         jbtReadFileActionPerformed2(evt);
     }

    });
  } // end constructor


 private void jbtReadFileActionPerformed(ActionEvent evt) {
    try {
        File inFile = new File("c:/temp/studentnames.txt");
        Scanner input = new Scanner(inFile);
        String fileContents = "";
        while(input.hasNext()) {
            fileContents+= input.nextLine() + "\n";
        } // end while

        jtxtAfileContents.setText(fileContents);
        input.close();




    } // end action method for jbtReadFile button
    catch (FileNotFoundException ex) {
    Logger.getLogger(P_Supplemental_11.class.getName()).log(Level.SEVERE, null,            ex);
    }
}

private void jbtReadFileActionPerformed2(ActionEvent evt) {
    try {
        File inFile = new File("c:/temp/studentscores.txt");
        Scanner input = new Scanner(inFile);
        String fileContents = "";
        while(input.hasNext()) {
            fileContents+= input.nextLine() + "\n";
        } // end while
        input.close();
        jtxtAfileContents.setText(fileContents);





    } // end action method for jbtReadFile button
    catch (FileNotFoundException ex) {
        Logger.getLogger(P_Supplemental_11.class.getName()).log(Level.SEVERE, null,    
 ex);
    }
}


 public static void main(String[] args) {
    P_Supplemental_11 frame = new P_Supplemental_11();
    frame.setTitle("P_Supplemenetal_10");
    frame.setSize(410, 520);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:37:19+00:00Added an answer on June 14, 2026 at 3:37 am

    You are not using a panel with a GridLayout in the BorderLayout.SOUTH location as specified in the assignment.

    2 buttons cannot share the same location in a BorderLayout with both being visible at the same time:

    add(jbtReadFile1, BorderLayout.SOUTH);
    
    add(jbtReadFile2, BorderLayout.SOUTH);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing an assignment and stuck at this point: I have a class
so we're doing this assignment at Uni and i have a serious craving to
I'm doing an assignment that requires me to measure the time taken by two
Me and my friend having a problem while doing a homework assignment. We have
I'm doing some assignment and got stuck at one point here. I am trying
I am doing an assignment for school where we are to make two php
So, I'm doing an assignment for my C# class and I have a list
I'm doing an assignment for automata theory, which I have to determine whether a
I am doing my assignment in Network architecture 1, where I have to implement
I'm doing a college assignment in XNA to make a virtual piano. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.