Java Code Examples for javax.swing.JLabel.setVerticalTextPosition()

The following are Jave code examples for showing how to use setVerticalTextPosition() of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jmt   File: AboutDialogFactory.java   Source Code and License Vote up 6 votes
/**
 * @return the logo of the contributor company
 */
public JComponent getLogo() {
	switch (this) {
	case POLIMI:
		JLabel logo = new JLabel(GraphStartScreen.HTML_POLI);
		logo.setHorizontalTextPosition(SwingConstants.TRAILING);
		logo.setVerticalTextPosition(SwingConstants.CENTER);
		logo.setIconTextGap(10);
		logo.setIcon(JMTImageLoader.loadImage("logo", new Dimension(70, 70)));
		return logo;
	case ICL:
		return new JLabel(JMTImageLoader.loadImage("logo_icl", new Dimension(-1,40)));
	default:
		return null;
	}
}
 
Example 2
Project: LivroJavaComoProgramar10Edicao   File: LabelFrame.java   Source Code and License Vote up 6 votes
public LabelFrame()
{
   super("Testing JLabel");
   setLayout(new FlowLayout()); // set frame layout

   // JLabel constructor with a string argument
   label1 = new JLabel("Label with text");
   label1.setToolTipText("This is label1");
   add(label1); // add label1 to JFrame

   // JLabel constructor with string, Icon and alignment arguments
   Icon bug = new ImageIcon(getClass().getResource("bug1.png"));
   label2 = new JLabel("Label with text and icon", bug, 
      SwingConstants.LEFT);
   label2.setToolTipText("This is label2");
   add(label2); // add label2 to JFrame

   label3 = new JLabel(); // JLabel constructor no arguments
   label3.setText("Label with icon and text at bottom");
   label3.setIcon(bug); // add icon to JLabel
   label3.setHorizontalTextPosition(SwingConstants.CENTER);
   label3.setVerticalTextPosition(SwingConstants.BOTTOM);
   label3.setToolTipText("This is label3");
   add(label3); // add label3 to JFrame
}
 
Example 3
Project: GIFKR   File: ProgressFrame.java   Source Code and License Vote up 6 votes
private void initializeComponents() {
	progressText = new JLabel(new ImageIcon(ImageTools.scaleToHeight(ImageTools.getResourceImage("iconsmall.png"), 50, false)));
	progressText.setForeground(Color.white);
	progressText.setVerticalTextPosition(JLabel.BOTTOM);
	progressText.setHorizontalTextPosition(JLabel.CENTER);
	cancelButton = new JButton("Cancel");
	
	setContentPane(new JPanel() {
		private static final long serialVersionUID = -8098561857624764691L;
		@Override
		public void paintComponent(Graphics g) {
			setOpaque(false);
			super.paintComponent(g);
			paintBG((Graphics2D) g);
		}
	});
	cancelButton.addActionListener(ae -> {if(onCancel != null) onCancel.actionPerformed(ae);});
}
 
Example 4
Project: incubator-netbeans   File: JComponentBuilders.java   Source Code and License Vote up 5 votes
protected void setupInstance(JLabel instance) {
    super.setupInstance(instance);
    
    instance.setText(text);
    
    if (defaultIcon != null) instance.setIcon(defaultIcon.createInstance());
    
    instance.setVerticalAlignment(verticalAlignment);
    instance.setHorizontalAlignment(horizontalAlignment);
    instance.setVerticalTextPosition(verticalTextPosition);
    instance.setHorizontalTextPosition(horizontalTextPosition);
    instance.setIconTextGap(iconTextGap);
}
 
Example 5
Project: Equella   File: AbstractListWithView.java   Source Code and License Vote up 5 votes
protected Component getNoSelectionComponent()
{
	JLabel label = new JLabel(getNoSelectionText());

	// Centre it!
	label.setVerticalAlignment(SwingConstants.CENTER);
	label.setHorizontalAlignment(SwingConstants.CENTER);
	label.setVerticalTextPosition(SwingConstants.CENTER);
	label.setHorizontalTextPosition(SwingConstants.CENTER);

	return label;
}
 
Example 6
Project: rapidminer   File: AbstractToRepositoryStep.java   Source Code and License Vote up 4 votes
/**
 * Creates a panel which displays the process animation and a stop button.
 *
 * @return the created panel
 */
private JPanel createProgressPanel() {
	JPanel panel = new JPanel(new GridBagLayout());

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weightx = 0.0;
	gbc.weighty = 0.0;
	gbc.insets = new Insets(0, 5, 5, 5);

	ImageIcon animation = SwingTools
			.createImage(I18N.getGUILabel("io.dataimport.step.store_data_to_repository.animation"));
	animationLabel = new JLabel(animation);
	animationLabel.setHorizontalTextPosition(JLabel.CENTER);
	animationLabel.setVerticalTextPosition(JLabel.BOTTOM);

	gbc.gridy += 1;
	panel.add(animationLabel, gbc);

	stopButton = new JButton(
			new ResourceAction(true, "io.dataimport.step.store_data_to_repository.stop_data_import_progress") {

				private static final long serialVersionUID = 1L;

				@Override
				public void actionPerformed(ActionEvent e) {
					if (backgroundJob != null) {
						setEnabled(false);
						backgroundJob.cancel();
						isImportCancelled = true;
					}
				}
			});

	gbc.insets = new Insets(40, 5, 5, 5);
	gbc.gridy += 1;
	panel.add(stopButton, gbc);

	return panel;
}
 
Example 7
Project: rapidminer   File: PackageListCellRenderer.java   Source Code and License Vote up 4 votes
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    JPanel panel = new JPanel() {
        private static final long serialVersionUID = 1L;

        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            if(d == null) {
                return d;
            } else {
                d.width = 10;
                return d;
            }
        }
    };
    JLabel label = new JLabel();
    panel.setLayout(new FlowLayout(0));
    panel.add(label);
    panel.setOpaque(true);
    if(isSelected && value instanceof PackageDescriptor) {
        panel.setBackground(Colors.TEXT_HIGHLIGHT_BACKGROUND);
    } else {
        panel.setBackground(Colors.TEXTFIELD_BACKGROUND);
    }

    String text = "";
    if(value instanceof PackageDescriptor) {
        PackageDescriptor desc = (PackageDescriptor)value;
        Icon packageIcon = this.getResizedIcon(this.getIcon(desc));
        text = "<html><body style=\'width: " + (packageIcon != null?300 - packageIcon.getIconWidth():314) + (this.textPixelSize > 0?";font-size:":"") + this.textPixelSize + "px;" + (packageIcon == null?"margin-left:40px;":"") + "\'>";
        text = text + "<div><strong>" + desc.getName() + "</strong> " + desc.getVersion();
        if(desc.isRestricted()) {
            text = text + "&nbsp;&nbsp;<img src=\'icon:///16/currency_euro.png\' style=\'vertical-align:middle;\'/>";
        }

        text = text + "</div>";
        text = text + "<div style=\'margin-top:5px;\'>" + this.getLicenseType(desc.getLicenseName()) + "</div>";
        if(this.dependecyMap != null && ((HashSet)this.dependecyMap.get(desc)).size() > 0) {
            text = text + "<div style=\'margin-top:5px;\'>" + this.getSourcePackages(desc) + "</div>";
        }

        text = text + "</body></html>";
        label.setIcon(packageIcon);
        label.setVerticalTextPosition(1);
        label.setForeground(Colors.TEXT_HIGHLIGHT_FOREGROUND);
        label.setText(text);
    }

    return panel;
}
 
Example 8
Project: GIFKR   File: CreditsFrame.java   Source Code and License Vote up 4 votes
public CreditsFrame() {
	super("Credits");
	setLayout(new GridBagLayout());
	GridBagConstraints gbc = ViewUtils.createGBC();
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.weighty=1;
	gbc.insets = new Insets(0, 10, 10, 10);
	
	JLabel logoLabel = new JLabel(new ImageIcon(ImageTools.scaleToHeight(ImageTools.getResourceImage("icon.png"), 100, false)));
	logoLabel.setText("<HTML>GIFKR &copy; 2017 Caleb Kussmaul");
	logoLabel.setHorizontalTextPosition(JLabel.CENTER);
	logoLabel.setVerticalTextPosition(JLabel.BOTTOM);
	
	add(logoLabel, gbc);
	
	gbc.gridy++;
	gbc.weighty=0;
	
	JTextPane dedicationPane = new JTextPane();
	
	dedicationPane.setText("Dedicated to my dad, Wes Kussmaul, for inspiring my passion for programming, creativity, and entrepreneurship.");
	dedicationPane.setOpaque(false);
	dedicationPane.setEditable(false);
	ViewUtils.centerText(dedicationPane);
	
	add(dedicationPane, gbc);
	gbc.gridy++;
	
	JTextPane copyrightPane = new JTextPane();
	copyrightPane.setText("Referenced libraries:\nOpen-Imaging under Apache 2.0\nJavaCV under Apache 2.0\nFFmpeg under LGPL 2.1");
	add(copyrightPane, gbc);
	gbc.gridy++;
	gbc.fill = GridBagConstraints.NONE;
	gbc.anchor = GridBagConstraints.CENTER;
	
	
	JCheckBox doNotShowBox = new JCheckBox("Do not show again", !GIFKRPrefs.showCreditsFrame());
	doNotShowBox.addChangeListener(ce -> {
		GIFKRPrefs.setShowCreditsFrame(!doNotShowBox.isSelected());
	});
	
	add(doNotShowBox, gbc);
	
	setSize(500, 350);
	setLocationRelativeTo(null);
	setAlwaysOnTop(true);
}
 
Example 9
Project: Equella   File: GroupDetailsPanel.java   Source Code and License Vote up 4 votes
private void setupGui()
{
	JLabel groupIdLabel = new JLabel(
		CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.groupid")); //$NON-NLS-1$
	JLabel groupNameLabel = new JLabel(
		CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.groupname")); //$NON-NLS-1$
	JLabel descriptionLabel = new JLabel(
		CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.desc")); //$NON-NLS-1$
	JLabel usersLabel = new JLabel(
		CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.members")); //$NON-NLS-1$

	descriptionLabel.setVerticalTextPosition(SwingConstants.TOP);
	descriptionLabel.setVerticalAlignment(SwingConstants.TOP);

	groupId = new JTextField();
	groupId.setEditable(false);
	groupName = new JSmartTextField(100);
	description = new JTextArea();
	description.setLineWrap(true);
	description.setWrapStyleWord(true);

	users = new FilteredShuffleList<UserBean>(
		CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.search"), //$NON-NLS-1$
		new FilterUserBeanModel(userService), Format.USER_BEAN_COMPARATOR);
	users.setSearchText(getString("internal.groupdetailspanel.searchbutton")); //$NON-NLS-1$
	users.setRemoveText(getString("internal.groupdetailspanel.removebutton")); //$NON-NLS-1$

	JButton save = new JButton(saveAction);

	final int height1 = groupName.getPreferredSize().height;
	final int height2 = save.getPreferredSize().height;
	final int width1 = groupNameLabel.getPreferredSize().width;
	final int width2 = save.getPreferredSize().width;

	final int[] rows = {height1, height1, TableLayout.FILL, height1, TableLayout.TRIPLE_FILL, height2,};
	final int[] cols = {width1, TableLayout.FILL, width2,};

	setLayout(new TableLayout(rows, cols));

	add(groupIdLabel, new Rectangle(0, 0, 1, 1));
	add(groupId, new Rectangle(1, 0, 2, 1));
	add(groupNameLabel, new Rectangle(0, 1, 1, 1));
	add(groupName, new Rectangle(1, 1, 2, 1));
	add(descriptionLabel, new Rectangle(0, 2, 1, 1));
	add(new JScrollPane(description), new Rectangle(1, 2, 2, 1));

	add(usersLabel, new Rectangle(0, 3, 3, 1));
	add(users, new Rectangle(0, 4, 3, 1));
	add(save, new Rectangle(2, 5, 1, 1));

	changeDetector = new ChangeDetector();
	changeDetector.watch(groupName);
	changeDetector.watch(description);
	changeDetector.watch(users.getModel());

	saveAction.setEnabled(false);
}