Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package swingExercises;
- import java.awt.GridLayout;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.SwingConstants;
- import javax.imageio.ImageIO;
- public class GridLabels2 {
- public static void main(String[] args) {
- JFrame jfrm = new JFrame("Show labels");
- jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- jfrm.setLayout(new GridLayout(3, 1));
- jfrm.setSize(700, 500);
- JLabel[][] labels = new JLabel[3][1];
- labels[0][0] = new JLabel("Label Tester");
- labels[1][0] = new JLabel(ImageIO.read(new File("C:\\Users\\AJB\\Downloads\\logoDataDino.gif")));
- labels[2][0] = new JLabel(ImageIO.read(new File("C:\\Users\\AJB\\Downloads\\logoSquirrelSQL.gif")) + "text and icon");
- jfrm.getContentPane().add(labels[0][0]);
- jfrm.getContentPane().add(labels[1][0]);
- jfrm.getContentPane().add(labels[2][0]);
- labels[0][0].setHorizontalAlignment(SwingConstants.CENTER);
- jfrm.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement