import java.awt.*; // needed for Color import javax.swing.*; // for JFrame, JPanel, JLabel import javax.swing.border.*; // need to add this subpackage specifically to handle the LineBorder public class Ch12_5a // creates a GUI of text information with borders around each JLabel { public static void main(String[] args) { JFrame frame=new JFrame("Exercise12_1"); // set the title of the JFrame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // establish what to do when the GUI is closed frame.setSize(400,200); // set the size to something small JPanel p1=new JPanel(new GridLayout(4,1)); // we will insert 4 JLabels in 4 rows, going straight down JLabel lab1=new JLabel("Department of Computer Science"); // create the 4 JLabels with address info JLabel lab2=new JLabel("College of Informatics"); JLabel lab3=new JLabel("Northern Kentucky University"); JLabel lab4=new JLabel("Tel: 859-572-6930"); lab1.setBorder(new LineBorder(Color.BLACK,1)); // create a border for each JLabel, black, thin lab2.setBorder(new LineBorder(Color.BLACK,1)); lab3.setBorder(new LineBorder(Color.BLACK,1)); lab4.setBorder(new LineBorder(Color.BLACK,1)); p1.add(lab1); // add the 4 JLabels to the one JPanel p1.add(lab2); p1.add(lab3); p1.add(lab4); frame.add(p1); // add the JPanel to this JFrame and make it visible frame.setVisible(true); } }