- 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();
-
-
}
-
I did not put all of my codes..
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?
7 1278
[code]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?
That's what you get for not using an appropriate LayoutManager. For now you
can explicitly set the location of your exit button. You only set its size now.
kind regards,
Jos
Change
to - pane.add(exitB,BorderLayout.SOUTH);
and it should end up at the bottom of your pane. Also, you probably should read the Sun LayoutManager Tutorial - LayoutManagers make Life much easier.
Greetings,
Nepomuk
Change
to - pane.add(exitB,BorderLayout.SOUTH);
and it should end up at the bottom of your pane.
That'd only work if there *were* actually a BorderLayout manager installed.
kind regards,
Jos
That's what you get for not using an appropriate LayoutManager. For now you
can explicitly set the location of your exit button. You only set its size now.
kind regards,
Jos
Thank you Jos..you made my day!!
keep it up!! and for those who answer this forum..
I thank you all!!
That'd only work if there *were* actually a BorderLayout manager installed.
Correct me if I'm wrong, but BorderLayout is the default LayoutManager, so a BorderLayout manager is installed, isn't it? In the code for the BorderLayoutDemo in the BorderLayout Tutorial it says:
- //Use the content pane's default BorderLayout. No need for
-
//setLayout(new BorderLayout());
So, shouldn't it work although no LayoutManager was chosen here? They don't choose one in that example.
Greetings,
Nepomuk
Correct me if I'm wrong, but BorderLayout is the default LayoutManager, so a BorderLayout manager is installed, isn't it?
Yup, normally it is but see what the OP did in line #32 (see above)
kind regards,
Jos
Yup, normally it is but see what the OP did in line #32 (see above)
Ah, right. Well. Not good. (Although line 32 wasn't that easy to find with the new code display...)
Greetings,
Nepomuk
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jesper |
last post by:
I know that user interface library questions come up on this list every now
and then. I've lurked here for a while and also searched google for anything
that would fit my needs but haven't found...
|
by: ·sÂA¤H |
last post by:
I am doing a XML-based workflow management system in Final year project.
I wanted to develop a GUI (drag and drop graphic) to define the rule of
workflow and save it to XML.
How can I generate...
|
by: John F. |
last post by:
I want to write a client app in Python using wxWindows that connects to
my FreeBSD server via SSH (using my machine account credentials) and
runs a python or shell script when requested (by...
|
by: Alexander Muylaert |
last post by:
Hi
I'm in need of a graphical engine for custom-made-GUI. I don't mind writing
it myself, it's fun, but
I need it to run on Pocket and PC.
What technology can I use best in .net. I don't...
|
by: John Smith |
last post by:
Hello
Coould please any one to help me to find good graphical controls to create
GDI in ASP.NET.
Some related websites also really appreciated
Thanks in Advance
John
|
by: noylec |
last post by:
Hi... I'm new in Java programming. Can you please help me in creating a program using GUI (specifically, using swing)? Here is the problem given:
Create a program using GUI (swing) that will ask...
|
by: psbasha |
last post by:
Hi,
I would like to call the same aplication executable with and without Graphical User Interface.
Requirement:
With Tkinter User interface,user can give the inputs to run the application (...
|
by: psbasha |
last post by:
Hi ,
Currenty I am storing the Graphical User Interface options in a string memeber variable of a class as show below:
SampleCode
Tkinter Modules ( Graphical User Interface):...
|
by: r0g |
last post by:
Hi There,
I'm trying to migrate a locally hosted page from windows to a private
Ubuntu development server and one of the key bits of functionality
(which used to work fine in Windows) was the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |