Code:
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner;
public class solano extends JFrame{
private JLabel letterL ,countL, PercentageL;
private JTextArea display;
private JButton exitB;
private ExitButtonHandler ebHandler;
private static final int WIDTH = 600;
private static final int HEIGHT = 600;
private static final int SIZE1 = 300;
private static final int SIZE2 = 20;
public solano(){
letterL= new JLabel("Letter",SwingConstants.CENTER);
countL = new JLabel("Count",SwingConstants.CENTER);
PercentageL = new JLabel("Percentage",SwingConstants.CENTER);
display = new JTextArea(26,3);
//window
setTitle("Text Character Count");
Container pane = getContentPane();
pane.setLayout(null);
letterL.setLocation(-70,1);
countL.setLocation(85,1);
PercentageL.setLocation(250,1);
exitB = new JButton("Exit");
ebHandler = new ExitButtonHandler();
exitB.addActionListener(ebHandler);
display.setLocation(SIZE2,SIZE2);
letterL.setSize(SIZE1,SIZE2);
countL.setSize(SIZE1,SIZE2);
PercentageL.setSize(SIZE1,SIZE2);
display.setSize(500,500);
exitB.setSize(100,SIZE2);
pane.add(letterL);
pane.add(countL);
pane.add(PercentageL);
pane.add(exitB);
pane.add(display);
display.setEditable(false);
setSize(WIDTH, HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
private class ExitButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
public static void main(String[] args)throws FileNotFoundException
{
solano Count = new solano();
}
Everytime I run my program the Exit Button is covering the Letter JLabel
I want to make the Exit Button be on the buttom of my GUI
How will I do that?
Comment