labelMode.setAlignmentY(0.0F); panelModeInner.add(labelMode);
label.setOpaque(false); label.setAlignmentX(0.5f); label.setAlignmentY(0.5f); Font font = Story.myFont; label.setFont(font.deriveFont(Font.PLAIN, 72f));
public ColorPanel(ColorComponent colorComponent) { this.colorComponent = colorComponent; setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); Dimension d = new Dimension(Integer.MAX_VALUE, 30); setMinimumSize(d); setPreferredSize(d); setMaximumSize(d); JLabel label = new JLabel(nodebox.util.StringUtils.humanizeName(colorComponent.toString().toLowerCase(Locale.US)), JLabel.RIGHT); Dimension size = label.getSize(); label.setFont(Theme.SMALL_BOLD_FONT); label.setForeground(new Color(66, 66, 66)); label.setPreferredSize(new Dimension(75, size.height)); label.setAlignmentY(JLabel.CENTER); label.setBorder(new EmptyBorder(3, 0, 0, 0)); add(label); add(Box.createHorizontalStrut(2)); draggableNumber = new DraggableNumber(); draggableNumber.addChangeListener(this); d = new Dimension(20, Integer.MAX_VALUE); draggableNumber.setPreferredSize(d); draggableNumber.setMaximumSize(d); draggableNumber.setSize(d); add(draggableNumber); slider = new ColorSlider(this); add(slider); add(Box.createHorizontalStrut(7)); }
this.labelPlaceholderResult.setAlignmentY(Component.CENTER_ALIGNMENT);
jLabelFooterLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabelFooterLabel.setText("Message of the Day:"); jLabelFooterLabel.setAlignmentY(0.3F); jPanelBottom.add(jLabelFooterLabel);
private JLabel getLabel(String txt) { JLabel lbl = new JLabel(txt); //lbl.setFont(lbl.getFont().deriveFont(Font.ITALIC)); lbl.setToolTipText("Foo"); lbl.setAlignmentX(1.0f); lbl.setAlignmentY(1.0f); return lbl; }
private JComponent buildExplanationsPanel(String[] explanations) { JPanel explanationPanel = new JPanel(); explanationPanel.setLayout(new BoxLayout(explanationPanel, BoxLayout.Y_AXIS)); for (String explanation : explanations) { if (explanation.equals(PARAGRAPH)) { explanationPanel.add(Box.createVerticalStrut(5)); continue; } JLabel label = new JLabel(explanation); label.setAlignmentY(0f); explanationPanel.add(label); } return explanationPanel; }
public class JStatusPanel extends JPanel { protected JLabel message = new JLabel("Status"); public JStatusPanel() { this.setLayout(new BorderLayout()); message.setAlignmentY(JLabel.CENTER_ALIGNMENT); message.setAlignmentX(JLabel.CENTER_ALIGNMENT); add(message, BorderLayout.CENTER); } public void showInfo(String text) { message.setForeground(new Color(0, 0, 0)); message.setText(text); } public void showError(String text) { message.setForeground(new Color(255, 0, 0)); message.setText(text); } }
public MainJFrame(){ ImageIcon imageIcon = new ImageIcon("src/slime.png"); ImageIcon image = new ImageIcon("src/slime.gif"); JLabel label = new JLabel(image, JLabel.CENTER); label.setAlignmentX(0); label.setAlignmentY(0); label.setIcon(image); JFrame window = new JFrame("Slime"); window.setVisible(true); window.setSize(250, 200); window.setResizable(false); window.setIconImage(new ImageIcon(getClass().getResource("src/slime.png")).getImage()); window.add(label); }
JPanel panel = new JPanel(); try{ panel.add(new JLabel (new ImageIcon (ImageIO.read(new File(""))))); }catch (IOException e){ System.out.print("wrong place"); } JLabel label = new JLabel ("hello world", JLabel.CENTER); label.setAlignmentX(0); label.setAlignmentY(0); panel.add(label); JFrame F = new JFrame("name"); F.add(panel); F.setResizable(false); F.setSize(600, 400); F.setVisible(true);
public static JPanel createBoldLabelPanel(String labelText, Component c, Font font, Color c1) { c.setFont(new Font(font.getName(), Font.PLAIN, font.getSize())); c.setBackground(c1); JPanel jp = new JPanel(); if (!labelText.isEmpty()) { //jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.setLayout( new BorderLayout()); JLabel label = new JLabel(labelText); label.setFont(new Font(font.getFontName(), Font.BOLD, font.getSize())); label.setBackground(c1); label.setAlignmentY(Component.TOP_ALIGNMENT); jp.add(label, BorderLayout.NORTH); } jp.add(c); jp.setBackground(c1); return jp; }
public JButtonO() { super("the button"); this.setSize(400, 200); // Create a panel with a borderlayout JPanel jpanel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Output Items:"); label.setAlignmentX(1); label.setAlignmentY(1); // Add Label to top of layout jpanel.add(label, BorderLayout.NORTH); JList conList = new JList(values); conList.setVisibleRowCount(3); JScrollPane scroller = new JScrollPane(conList); //AddScroll to center jpanel.add(scroller); //Add Panel to JFrame this.add(jpanel); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }
public window(){ JFrame frame = new JFrame("name"); JLabel label = new JLabel ("hello world", JLabel.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel() { public boolean isOptimizedDrawingEnabled() { return false; } }; LayoutManager overlay = new OverlayLayout(panel); panel.setLayout(overlay); frame.setResizable(false); frame.setSize(600, 400); frame.setVisible(true); label.setAlignmentX(0); label.setAlignmentY(0); panel.add(label); panel.add(new JLabel(new ImageIcon("file"))); frame.add(panel, BorderLayout.CENTER); } }
label1.setFont(new Font("SansSerif", Font.BOLD, 16)); label1.setAlignmentX(0.5f); label1.setAlignmentY(0.5f); panel.add(label1); label2.setAlignmentY(0.5f); panel.add(label2);
private void PaintIcon(int l_iDice, boolean bColored, boolean bSingle, String strTooltip) { try { JLabel l_objLabel = new JLabel((bSingle ? mar_objSingleDieIcon[l_iDice - 1] : (bColored ? mar_objColoredDCIcon[l_iDice - 1] : mar_objWhiteDCIcon[l_iDice - 1]))); l_objLabel.setAlignmentY(0.7f); if (!strTooltip.isEmpty()) l_objLabel.setToolTipText(strTooltip.trim()); StyleConstants.setComponent(m_objIconStyle, l_objLabel); m_objDocument.insertString(m_objDocument.getLength(), "Ignored", m_objIconStyle); } catch (Exception ex) { ex.printStackTrace(); } }
case LEFTOP: { label.setAlignmentX(Component.LEFT_ALIGNMENT); label.setAlignmentY(Component.TOP_ALIGNMENT); label.setAlignmentY(Component.TOP_ALIGNMENT); label.setAlignmentY(Component.TOP_ALIGNMENT);
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { messageLabel = new javax.swing.JLabel(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5)); browsePluginsButton = new javax.swing.JButton(); setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10)); setMinimumSize(new java.awt.Dimension(250, 200)); setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS)); org.openide.awt.Mnemonics.setLocalizedText(messageLabel, OStrings.getString("PREFS_PLUGINS_AVAILABLE_ONLINE")); // NOI18N messageLabel.setAlignmentY(0.0F); add(messageLabel); add(filler1); org.openide.awt.Mnemonics.setLocalizedText(browsePluginsButton, OStrings.getString("PREFS_PLUGINS_BROWSE_ONLINE")); // NOI18N browsePluginsButton.setAlignmentY(0.0F); add(browsePluginsButton); }// </editor-fold>//GEN-END:initComponents
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { currentVersionLabel = new javax.swing.JLabel(); updateChannelLabel = new javax.swing.JLabel(); filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5)); autoCheckCheckBox = new javax.swing.JCheckBox(); filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5)); checkNowButton = new javax.swing.JButton(); setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10)); setMinimumSize(new java.awt.Dimension(250, 200)); setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS)); org.openide.awt.Mnemonics.setLocalizedText(currentVersionLabel, OStrings.getString("PREFS_VERSION_CURRENT_VERSION")); // NOI18N currentVersionLabel.setAlignmentY(0.0F); add(currentVersionLabel); org.openide.awt.Mnemonics.setLocalizedText(updateChannelLabel, OStrings.getString("PREFS_VERSION_UPDATE_CHANNEL")); // NOI18N updateChannelLabel.setAlignmentY(0.0F); add(updateChannelLabel); add(filler4); org.openide.awt.Mnemonics.setLocalizedText(autoCheckCheckBox, OStrings.getString("PREFS_VERSION_CHECK_AUTO_CHECK")); // NOI18N add(autoCheckCheckBox); add(filler2); org.openide.awt.Mnemonics.setLocalizedText(checkNowButton, OStrings.getString("PREFS_VERSION_CHECK_CHECK_NOW")); // NOI18N add(checkNowButton); }// </editor-fold>//GEN-END:initComponents
/** * Adds a labeled separator to the given container. * * @param aContainer * the container to add the separator + label to, cannot be * <code>null</code>. * @param aText * the (optional) text of the label to add, may be <code>null</code>. * @return the given container, never <code>null</code>. */ public static final Container addSeparator( final Container aContainer, final String aText ) { final Color color = getSeparatorForegroundColor(); final JLabel label = new JLabel( aText ); label.setAlignmentY( Component.BOTTOM_ALIGNMENT ); // Take the selection color of a JList to make a "striking" difference // between separators and other components... label.setForeground( color ); label.setFont( label.getFont().deriveFont( Font.BOLD ) ); label.setHorizontalAlignment( SwingConstants.RIGHT ); setSeparatorProperty( label ); final JSeparator separator = new JSeparator(); // Apparently, on Mac OSX, the height of a separator is slightly different // than on other OSs... separator.setAlignmentY( HostUtils.getHostInfo().isMacOS() ? 0.25f : Component.CENTER_ALIGNMENT ); setSeparatorProperty( separator ); aContainer.add( label ); aContainer.add( separator ); return aContainer; }
JLabel label = new JLabel(text, JLabel.CENTER); label.setAlignmentX(AX); label.setAlignmentY(AY); label.setVisible(true); return label;