Code example for JLabel

Methods: setHorizontalAlignment

0
 
	/** The file name of the PDF we're going to label. */ 
	String filename = "";
 
	/** the label containing the metadata */ 
	JLabel label = new JLabel();
 
	/** the scrollpane to scroll through the label */ 
	JScrollPane scrollpane = new JScrollPane();
 
	/** the panel to witch the scrollpane will be added. */ 
	JPanel panel = new JPanel();
 
	/** Construct the information label (actually it's a JPanel). */ 
	public PdfInformationPanel() { 
		try { 
			this.setLayout(new BorderLayout());
			label.setHorizontalAlignment(SwingConstants.CENTER);
			panel.setLayout(new BorderLayout());
			this.add(panel, BorderLayout.CENTER);
			scrollpane.setPreferredSize(new Dimension(200, 200));
			panel.add(scrollpane, BorderLayout.CENTER);
			scrollpane.setViewportView(label);