1 Attachment(s)
Sinple GUI Program which uses the BorderLayout.
I need to write a Java program to display a screen like the following screen, which uses the BorderLayout.
This is what my output is supposed to be:
Attachment 1401 or View Here: https://www.dropbox.com/s/u1pqz588b8cofxo/Untitled1.png
I tried writing the code for this program. But I am not able to do so. Following is my code:
Code Java:
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class GUI extends JFrame
{
public GUI()
{
setLayout(new BorderLayout(1000,2000));
add(new JButton("Java"), BorderLayout.NORTH);
add(new JButton("Programming"), BorderLayout.CENTER);
add(new JButton("Is Not So Easy"), BorderLayout.NORTH);
add(new JButton("Linear Data Structers!"), BorderLayout.SOUTH);
}
public static void main(String[] args)
{
GUI frame = new GUI();
frame.setTitle("EECS 1570");
frame.setSize(600,400);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Please can you help me get the output like the one in the attached picture file? Thanks for your help. Much appreciated! :)
Re: Sinple GUI Program which uses the BorderLayout.
First problem I see is that the code adds two components to the same area: NORTH.
If you want those two components to both be there, add them to a JPanel and add it to NORTH.
Re: Sinple GUI Program which uses the BorderLayout.
Okay! Thanks. I got it. Appreciate your help :)