Java Code Examples for javax.swing.JLabel.CENTER

The following are Jave code examples for showing how to use CENTER 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: SimpleERP   File: Chooser.java   Source Code and License Vote up 6 votes
public DayLabel(Calendar cal){
    super(""+cal.get(Calendar.DAY_OF_MONTH), JLabel.CENTER);
    this.year = cal.get(Calendar.YEAR);
    this.month = cal.get(Calendar.MONTH);
    this.day = cal.get(Calendar.DAY_OF_MONTH);
    
    this.setFont(font);
    this.addMouseListener(this);
    this.addMouseMotionListener(this);
    if(month == calendar.get(Calendar.MONTH)) this.setForeground(java.awt.Color.BLACK);
    else this.setForeground(java.awt.Color.LIGHT_GRAY);
    
}
 
Example 2
Project: DicomViewer   File: FlyingToolTip.java   Source Code and License Vote up 6 votes
public FlyingToolTip(final FlyingToolTipListener source) {
    this.source = source;
    label = new JLabel("test", JLabel.CENTER) {
        @Override
        public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g.create();
            int w = getWidth(), h = getHeight();
            g.setColor(getBackground());
            g.fillRect(0,0,w,h);

            if (path != null) {                    
                g2.setStroke(new BasicStroke(4f));
                g2.setColor(getForeground());
                g2.draw(path);
            }
            setOpaque(false);
            super.paintComponent(g2);
            setOpaque(true);
            g2.dispose();
        }
    };    
    label.setBorder(new EmptyBorder(2,4,10,4));
    label.setOpaque(true);
}
 
Example 3
Project: incubator-netbeans   File: NotificationCenterTopComponent.java   Source Code and License Vote up 5 votes
private void init() {
        initComponents();
        detailsPanel = new JPanel(new GridLayout(1, 1));
        Color color = Utils.getTextBackground();
        detailsPanel.setBackground(new Color(color.getRed(), color.getGreen(), color.getBlue()));
        lblEmptyDetails = new JLabel(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_EmptyDetails"), JLabel.CENTER);
        lblEmptyDetails.setFont(italicFont);
        lblEmptyDetails.setEnabled(false);

        JScrollPane scrollPane = new JScrollPane(detailsPanel);
        splitPane.setRightComponent(scrollPane);

        toolBar.setFocusable(false);
        toolBar.setFloatable(false);
        btnSearch = new JToggleButton(ImageUtilities.loadImageIcon("org/netbeans/modules/notifications/resources/find16.png", true));
        btnSearch.setToolTipText(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_SearchToolTip"));
        btnSearch.setFocusable(false);
        btnSearch.setSelected(NotificationSettings.isSearchVisible());
        //TODO delete 2 lines then quick search API clear text correctly
//        btnSearch.setToolTipText("Disabled due to Quick Search API defects");
//        btnSearch.setEnabled(false);
        btnSearch.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setSearchVisible(btnSearch.isSelected());
            }
        });
        toolBar.add(btnSearch);
        toolBar.add(new FiltersMenuButton(notificationManager.getActiveFilter()));

        initLeft();
        showDetails();
    }
 
Example 4
Project: FreeCol   File: FreeColActionUI.java   Source Code and License Vote up 5 votes
BlinkingLabel() {
    super(getHumanKeyStrokeText(keyStroke), JLabel.CENTER);

    setOpaque(false);
    setBorder(Utility.TRIVIAL_LINE_BORDER);
    addKeyListener(this);
    addMouseListener(this);
}
 
Example 5
Project: incubator-netbeans   File: Utils.java   Source Code and License Vote up 5 votes
PlaceholderPanel(String className) {
    super(null);
    
    putClientProperty("className", className);
    
    setOpaque(true);
    setBorder(BorderFactory.createLineBorder(LINE));
    
    label = new JLabel(BrowserUtils.getSimpleType(className), JLabel.CENTER);
    label.setOpaque(true);
}
 
Example 6
Project: openjdk-jdk10   File: FileChooserDemo.java   Source Code and License Vote up 5 votes
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
Example 7
Project: marathonv5   File: BorderDemo.java   Source Code and License Vote up 5 votes
void addCompForBorder(Border border, String description, Container container) {
    JPanel comp = new JPanel(new GridLayout(1, 1), false);
    JLabel label = new JLabel(description, JLabel.CENTER);
    comp.add(label);
    comp.setBorder(border);

    container.add(Box.createRigidArea(new Dimension(0, 10)));
    container.add(comp);
}
 
Example 8
Project: jdk8u-jdk   File: FileChooserDemo.java   Source Code and License Vote up 5 votes
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
Example 9
Project: hearthstone   File: PanelHeroi.java   Source Code and License Vote up 5 votes
private void init() {
    setOpaque(false);
    congelado = new Congelado();
    heroi = new JLabel(imagemHeroi, JLabel.CENTER);
    animacao = new Animacao(hero);
    add(animacao, new AbsoluteConstraints(0, 0, imagemHeroi.getIconWidth(), imagemHeroi.getIconHeight()));
    add(congelado, AbsolutesConstraints.ZERO);
    add(heroi, AbsolutesConstraints.ZERO);
}
 
Example 10
Project: SE2017-Team2   File: ActionPane.java   Source Code and License Vote up 5 votes
public ActionPane() {
	this.setLayout(new BorderLayout());
	this.actions = new JPanel();
	setBorder(BorderFactory.createLineBorder(Color.black));

	JLabel label1 = new JLabel(" Possible Actions ", null, JLabel.CENTER);
	add(label1, BorderLayout.NORTH);

	actionsScrollPane = new JScrollPane(this.actions);
	this.actions.setLayout(new BoxLayout(this.actions, BoxLayout.Y_AXIS));
	this.add(actionsScrollPane, BorderLayout.CENTER);
	// this.add(this.actions);

	// this.add(this.panel);
}
 
Example 11
Project: OpenJSharp   File: FileChooserDemo.java   Source Code and License Vote up 5 votes
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
Example 12
Project: hearthstone   File: Util.java   Source Code and License Vote up 5 votes
/**
 * Cria um JLabel padrão para a exibição de um card na mão do jogador
 *
 * @param card card dono do JLabel
 * @param image imagem do JLabel
 * @return JLabel configurado
 */
public static JLabel JLabelMaoDefault(Card card, ImageIcon image) {
    return new JLabel(image, JLabel.CENTER) {
        @Override
        public String toString() {
            return Values.TO_STRING_MAO + card.id_long;
        }
    };
}
 
Example 13
Project: incubator-netbeans   File: DetailsProvider.java   Source Code and License Vote up 4 votes
protected View(Instance instance, Heap heap) {
    this(instance, heap, new JLabel(Bundle.BrowserUtils_Loading(), JLabel.CENTER) {
        public void addNotify() { setEnabled(false); }
    });
}
 
Example 14
Project: incubator-netbeans   File: BookmarkKeyChooser.java   Source Code and License Vote up 4 votes
public void show(Component parent, Runnable runOnClose) {
    this.runOnClose = runOnClose;
    key2bookmark = new HashMap<Character, BookmarkInfo>(2 * 46, 0.5f);
    BookmarkManager lockedBookmarkManager = BookmarkManager.getLocked();
    try {
        // Open projects should have their bookmarks loaded before invocation of this method
        // so that it's possible to enumerate present keys properly
        for (ProjectBookmarks projectBookmarks : lockedBookmarkManager.activeProjectBookmarks()) {
            for (FileBookmarks fileBookmarks : projectBookmarks.getFileBookmarks()) {
                for (BookmarkInfo bookmark : fileBookmarks.getBookmarks()) {
                    String key = bookmark.getKey();
                    if (key != null && key.length() > 0) {
                        key2bookmark.put(key.charAt(0), bookmark);
                    }
                }
            }
        }
    } finally {
        lockedBookmarkManager.unlock();
    }
    
    JPanel cellPanel = new JPanel();
    if (key2bookmark.size() > 0) {
        cellPanel.setLayout(new GridLayout(4, 10, 2, 2));
        addCells(cellPanel, 10 * 4, '1', '9', '0', '0', 'A', 'Z');
    } else { // No bookmarks with keys
        cellPanel.setLayout(new GridLayout(2, 1, 2, 2));
        JLabel noKeysLabel = new JLabel(NbBundle.getMessage(BookmarkKeyChooser.class, "LBL_keyChooserNoActiveKeys"), JLabel.CENTER);
        JLabel noKeysHelpLabel = new JLabel(NbBundle.getMessage(BookmarkKeyChooser.class, "LBL_keyChooserNoActiveKeysHelp"), JLabel.CENTER);
        cellPanel.add(noKeysLabel);
        cellPanel.add(noKeysHelpLabel);
    }
    cellPanel.setBorder(new EmptyBorder(4, 4, 4, 4));
    closeButton = new JButton(NbBundle.getMessage(BookmarkKeyChooser.class, "CTL_keyChooserCloseButton")); // NOI18N

    dialog = org.netbeans.editor.DialogSupport.createDialog(
            NbBundle.getMessage(BookmarkKeyChooser.class, "CTL_keyChooserTitle"), // NOI18N
            cellPanel, true, // modal
            new JButton[] { closeButton }, false, // bottom buttons
            0, // defaultIndex = 0 => allow close by Enter key too
            0, // cancelIndex
            this // ActionListener
    );
    dialog.pack();
    
    Point parentMidPoint = new Point(parent.getWidth() / 2, parent.getHeight() / 2);
    SwingUtilities.convertPointToScreen(parentMidPoint, parent);
    dialog.setBounds(
            parentMidPoint.x - dialog.getWidth() / 2,
            parentMidPoint.y - dialog.getHeight() / 2,
            dialog.getWidth(),
            dialog.getHeight()
    );
    closeButton.addKeyListener(this);
    dialog.setAlwaysOnTop(true);
    dialog.setVisible(true);
}
 
Example 15
Project: hearthstone   File: Segredo.java   Source Code and License Vote up 4 votes
public Quantidade(Heroi heroi) {
    super("", JLabel.CENTER);
    this.heroi = heroi;
    init();
}
 
Example 16
Project: ants   File: MenuQualificationTableCellRenderer.java   Source Code and License Vote up 4 votes
@Override
public int getHorizontalAlignment() {
       return JLabel.CENTER;
   }
 
Example 17
Project: SimpleERP   File: Chooser.java   Source Code and License Vote up 4 votes
public WeekLabel(int index, String name){
    super(name, JLabel.CENTER);
    this.name = name;
}
 
Example 18
Project: hearthstone   File: PanelHeroi.java   Source Code and License Vote up 4 votes
public Congelado() {
    super(Images.HEROI_CONGELADO, JLabel.CENTER);
    init();
}
 
Example 19
Project: restaurant-app   File: Card.java   Source Code and License Vote up 4 votes
/**
 * 
 * Creates new form Card
 */
public Card(Navigator navigator, Order order) {
    initComponents();
    setSize(1024, 768);
    this.navigator = navigator;
    this.order = order;
    
    JLabel paid = new JLabel("You paid with a card!", JLabel.CENTER);
    paid.setFont(new Font("Serif", Font.PLAIN, 24));
    paid.setForeground(Color.YELLOW);
    
    
    add(paid);
   

}
 
Example 20
Project: hearthstone   File: PanelHeroi.java   Source Code and License Vote up 4 votes
private void init() {
    congelado = new JLabel();
    heroi = new JLabel("", JLabel.CENTER);
    animacao = new Animacao(hero);        
}