Example usage for javax.swing JLabel setVerticalAlignment

List of usage examples for javax.swing JLabel setVerticalAlignment

Introduction

In this page you can find the example usage for javax.swing JLabel setVerticalAlignment.

Prototype

@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.TOP", "SwingConstants.CENTER",
        "SwingConstants.BOTTOM" }, description = "The alignment of the label's contents along the Y axis.")
public void setVerticalAlignment(int alignment) 

Source Link

Document

Sets the alignment of the label's contents along the Y axis.

Usage

From source file:com.intel.stl.ui.monitor.view.PSNodesDetailsPanel.java

/**
 * Description:/* w  w  w  . j a v  a 2  s  . c  o  m*/
 * 
 * @param name
 */
protected void initComponent() {
    setLayout(new BorderLayout(0, 0));
    setOpaque(false);
    setBorder(BorderFactory.createTitledBorder((Border) null));

    JPanel titlePanel = new JPanel(new BorderLayout(5, 1));
    titlePanel.setOpaque(false);
    numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    numberLabel.setHorizontalAlignment(JLabel.RIGHT);
    titlePanel.add(numberLabel, BorderLayout.CENTER);
    nameLabel = ComponentFactory.getH3Label("", Font.PLAIN);
    nameLabel.setHorizontalAlignment(JLabel.LEFT);
    nameLabel.setVerticalAlignment(JLabel.BOTTOM);
    titlePanel.add(nameLabel, BorderLayout.EAST);
    add(titlePanel, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setOpaque(false);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    GridBagLayout gridBag = new GridBagLayout();
    mainPanel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.weighty = 0;
    gc.insets = new Insets(8, 2, 2, 2);
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.gridheight = 2;
    // gc.gridheight = 3; // Should change to 3 if we add Route
    typeChartPanel = new ChartPanel(null);
    typeChartPanel.setPreferredSize(new Dimension(80, 60));
    mainPanel.add(typeChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.insets = new Insets(12, 2, 2, 2);
    gc.weightx = 0;
    gc.gridheight = 1;
    swNumberLabel = createNumberLabel();
    mainPanel.add(swNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    swNameLabel = createNameLabel(STLConstants.K0048_SWITCHES.getValue());
    mainPanel.add(swNameLabel, gc);

    gc.insets = new Insets(2, 2, 6, 2);
    gc.gridwidth = 1;
    fiNumberLabel = createNumberLabel();
    mainPanel.add(fiNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    fiNameLabel = createNameLabel(STLConstants.K0052_HOSTS.getValue());
    mainPanel.add(fiNameLabel, gc);

    // gc.gridwidth = 1;
    // rtNumberLabel = ComponentFactory.getH4Label(
    // STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    // rtNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    // mainPanel.add(rtNumberLabel, gc);
    //
    // gc.gridwidth = GridBagConstraints.REMAINDER;
    // rtNameLabel = ComponentFactory.getH5Label(
    // STLConstants.K0050_ROUTERS.getValue(), Font.PLAIN);
    // rtNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    // mainPanel.add(rtNameLabel, gc);

    add(mainPanel, BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel(new GridBagLayout());
    bottomPanel.setOpaque(false);
    bottomPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.INTEL_BORDER_GRAY));
    gc = new GridBagConstraints();
    gc.insets = new Insets(0, 5, 1, 5);
    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 1;
    gc.gridheight = 2;
    otherPortsLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    otherPortsLabel.setForeground(UIConstants.INTEL_GRAY);
    otherPortsLabel.setHorizontalAlignment(JLabel.RIGHT);
    bottomPanel.add(otherPortsLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.gridheight = 1;
    gc.weightx = 0;
    gc.weighty = 1;
    JLabel label = ComponentFactory.getH4Label(STLConstants.K1026_PORT_RESOURCE.getValue(), Font.PLAIN);
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setVerticalAlignment(JLabel.BOTTOM);
    bottomPanel.add(label, gc);

    gc.weighty = 0;
    label = ComponentFactory.getH4Label(STLConstants.K2077_NOT_IN_FABRIC.getValue(), Font.PLAIN);
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setVerticalAlignment(JLabel.BOTTOM);
    bottomPanel.add(label, gc);
    add(bottomPanel, BorderLayout.SOUTH);
}

From source file:com.hexidec.ekit.component.UnicodeDialog.java

public void init(int startIndex) {
    String customFont = Translatrix.getTranslationString("UnicodeDialogButtonFont");
    if (customFont != null && customFont.length() > 0) {
        buttonFont = new Font(Translatrix.getTranslationString("UnicodeDialogButtonFont"), Font.PLAIN, 12);
    } else {//from   www. j  a  va 2s.c o m
        buttonFont = new Font("Monospaced", Font.PLAIN, 12);
    }

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(0, 17, 0, 0));
    buttonGroup = new ButtonGroup();

    int prefButtonWidth = 32;
    int prefButtonHeight = 32;

    centerPanel.add(new JLabel(""));
    for (int labelLoop = 0; labelLoop < 16; labelLoop++) {
        JLabel jlblMarker = new JLabel(
                "x" + (labelLoop > 9 ? "" + (char) (65 + (labelLoop - 10)) : "" + labelLoop));
        jlblMarker.setHorizontalAlignment(SwingConstants.CENTER);
        jlblMarker.setVerticalAlignment(SwingConstants.CENTER);
        jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f));
        centerPanel.add(jlblMarker);
    }

    int labelcount = 0;
    for (int counter = 0; counter < UNICODEBLOCKSIZE; counter++) {
        if ((counter % 16) == 0) {
            JLabel jlblMarker = new JLabel(
                    (labelcount > 9 ? "" + (char) (65 + (labelcount - 10)) : "" + labelcount) + "x");
            jlblMarker.setHorizontalAlignment(SwingConstants.CENTER);
            jlblMarker.setVerticalAlignment(SwingConstants.CENTER);
            jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f));
            centerPanel.add(jlblMarker);
            labelcount++;
        }
        buttonArray[counter] = new JToggleButton(" ");
        buttonArray[counter].getModel().setActionCommand("");
        buttonArray[counter].setFont(buttonFont);
        buttonArray[counter].setBorder(
                javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
        buttonArray[counter].addActionListener(this);
        if (counter == 0) {
            FontRenderContext frcLocal = ((java.awt.Graphics2D) (parentEkit.getGraphics()))
                    .getFontRenderContext();
            Rectangle2D fontBounds = buttonFont.getMaxCharBounds(frcLocal);
            int maxCharWidth = (int) (Math.abs(fontBounds.getX())) + (int) (Math.abs(fontBounds.getWidth()));
            int maxCharHeight = (int) (Math.abs(fontBounds.getY())) + (int) (Math.abs(fontBounds.getHeight()));
            Insets buttonInsets = buttonArray[counter].getBorder().getBorderInsets(buttonArray[counter]);
            prefButtonWidth = maxCharWidth + buttonInsets.left + buttonInsets.right;
            prefButtonHeight = maxCharHeight + buttonInsets.top + buttonInsets.bottom;
        }
        buttonArray[counter].setPreferredSize(new Dimension(prefButtonWidth, prefButtonHeight));
        centerPanel.add(buttonArray[counter]);
        buttonGroup.add(buttonArray[counter]);
    }

    JPanel selectorPanel = new JPanel();

    jcmbBlockSelector = new JComboBox(unicodeBlocks);
    jcmbBlockSelector.setSelectedIndex(startIndex);
    jcmbBlockSelector.setActionCommand(CMDCHANGEBLOCK);
    jcmbBlockSelector.addActionListener(this);

    String[] sPages = { "1" };
    jcmbPageSelector = new JComboBox(sPages);
    jcmbPageSelector.setSelectedIndex(0);
    jcmbPageSelector.setActionCommand(CMDCHANGEBLOCK);
    jcmbPageSelector.addActionListener(this);

    selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodeBlock")));
    selectorPanel.add(jcmbBlockSelector);
    selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodePage")));
    selectorPanel.add(jcmbPageSelector);

    JPanel buttonPanel = new JPanel();

    JButton closeButton = new JButton(Translatrix.getTranslationString("DialogClose"));
    closeButton.setActionCommand("close");
    closeButton.addActionListener(this);
    buttonPanel.add(closeButton);

    contentPane.add(centerPanel, BorderLayout.CENTER);
    contentPane.add(selectorPanel, BorderLayout.NORTH);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);

    this.pack();

    populateButtons(startIndex, 0);

    this.setVisible(true);
}

From source file:edu.ku.brc.specify.config.init.secwiz.SpecifyDBSecurityWizard.java

/**
 * @param specify//  w  ww . j  av a2 s  . c  om
 */
public SpecifyDBSecurityWizard(final WizardListener listener) {
    super();

    this.listener = listener;

    System.setProperty(DBMSUserMgr.factoryName, "edu.ku.brc.dbsupport.MySQLDMBSUserMgr");

    /*setupXMLPath = UIRegistry.getUserHomeAppDir() + File.separator + "setup_prefs.xml";
    try
    {
    props.loadFromXML(new FileInputStream(new File(setupXMLPath)));
            
    } catch (Exception ex)
    {
    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, ex);
    }*/

    HelpMgr.setLoadingPage("Load");

    cardPanel = new JPanel(cardLayout);

    cancelBtn = createButton(UIRegistry.getResourceString("CANCEL"));
    helpBtn = createButton(UIRegistry.getResourceString("HELP"));

    JPanel btnBar;
    backBtn = createButton(UIRegistry.getResourceString("BACK"));
    nextBtn = createButton(UIRegistry.getResourceString("NEXT"));

    CellConstraints cc = new CellConstraints();
    PanelBuilder bbpb = new PanelBuilder(new FormLayout("f:p:g,p,4px,p,4px,p,4px,p,4px", "p"));

    bbpb.add(helpBtn, cc.xy(2, 1));
    bbpb.add(backBtn, cc.xy(4, 1));
    bbpb.add(nextBtn, cc.xy(6, 1));
    bbpb.add(cancelBtn, cc.xy(8, 1));

    btnBar = bbpb.getPanel();

    boolean doTesting = AppPreferences.getLocalPrefs().getBoolean("wizard.defaults", false);
    if (doTesting) {
        props.put("hostName", "localhost");
        props.put("dbName", "testfish");
        props.put("dbUserName", "root");
        props.put("dbPassword", "root");

        props.put("saUserName", "Master");
        props.put("saPassword", "Master");

        props.put("firstName", "Test");
        props.put("lastName", "User");
        props.put("middleInitial", "a");
        props.put("email", "tester@ku.edu");
        props.put("usrUsername", "testuser");
        props.put("usrPassword", "testuser");

        props.put("instName", "KU natural History Museum");
        props.put("instAbbrev", "KU-NHM");

        props.put("divName", "Fish");
        props.put("divAbbrev", "IT");

        props.put("collName", "Fish");
        props.put("collPrefix", "KUFSH");

        // Address
        props.put("addr1", "1345 Jayhawk Blvd");
        props.put("addr2", "606 Dyche Hall");
        props.put("city", "Lawrence");
        props.put("state", "KS");
        props.put("country", "USA");
        props.put("zip", "66044");
        props.put("phone", "785-864-5555");

        props.put("addtaxon", true);
    } else {
        props.put("hostName", "localhost");
        props.put("dbName", "specify");
    }

    props.put("userType", SpecifyUserTypes.UserType.Manager.toString());

    UIFieldFormatterMgr.setDoingLocal(true);

    dbPanel = new DatabasePanel(nextBtn, backBtn, "security_wiz1", true);
    panels.add(dbPanel);
    HelpMgr.registerComponent(helpBtn, dbPanel.getHelpContext());

    MasterLoginPanel masterLoginPanel = new MasterLoginPanel("SA", "ENTER_SA_INFO", "security_wiz2",
            new String[] { "SA_USERNAME", "SA_PASSWORD" }, new String[] { "saUserName", "saPassword" },
            new Integer[] { 32, 32 }, nextBtn, backBtn, true);

    panels.add(masterLoginPanel);

    panels.add(new UserPanel("SECURITY", "security_wiz3", nextBtn, backBtn, true, masterLoginPanel));

    lastStep = panels.size();

    if (backBtn != null) {
        backBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                if (step > 0) {
                    step--;
                    panels.get(step).doingPrev();
                    HelpMgr.registerComponent(helpBtn, panels.get(step).getHelpContext());
                    cardLayout.show(cardPanel, Integer.toString(step));
                }
                updateBtnBar();
                if (listener != null) {
                    listener.panelChanged(getResourceString(panels.get(step).getPanelName() + ".TITLE"));
                }
            }
        });

        backBtn.setEnabled(false);
    }

    nextBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (step < lastStep - 1) {
                panels.get(step).getValues(props);
                panels.get(step).aboutToLeave();

                advanceToNextPanel();

            } else {
                panels.get(step).aboutToLeave();
                nextBtn.setEnabled(false);
                SpecifyDBSecurityWizard.this.listener.finished();

            }
        }
    });

    cancelBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (SpecifyDBSecurityWizard.this.listener != null) {
                if (step == lastStep) {
                    SpecifyDBSecurityWizard.this.listener.finished();
                } else {
                    if (UIHelper.promptForAction("QUIT", "NO", "CANCEL", getResourceString("SURE_QUIT"))) {
                        SpecifyDBSecurityWizard.this.listener.cancelled();
                    }
                }
            }
        }
    });

    for (int i = 0; i < panels.size(); i++) {
        cardPanel.add(Integer.toString(i), panels.get(i));
        panels.get(i).setValues(props);
    }
    cardLayout.show(cardPanel, "0");

    if (dbPanel != null) {
        dbPanel.updateBtnUI();
    }

    PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g", "f:p:g,10px,p"));
    builder.add(cardPanel, cc.xy(1, 1));
    builder.add(btnBar, cc.xy(1, 3));

    builder.setDefaultDialogBorder();

    setLayout(new BorderLayout());
    PanelBuilder iconBldr = new PanelBuilder(new FormLayout("20px, f:p:g,p,f:p:g,8px", "20px,t:p,f:p:g, 8px"));
    JLabel iconLbl = new JLabel(IconManager.getIcon(getIconName()));
    iconLbl.setVerticalAlignment(SwingConstants.TOP);
    iconBldr.add(iconLbl, cc.xy(2, 3));
    add(iconBldr.getPanel(), BorderLayout.WEST);
    add(builder.getPanel(), BorderLayout.CENTER);

    progressBar = new JProgressBar(0, lastStep - 1);
    progressBar.setStringPainted(true);
    add(progressBar, BorderLayout.SOUTH);

    panels.get(0).updateBtnUI();

}

From source file:gov.nih.nci.nbia.StandaloneDMV3.java

JFrame showProgressForMac(String message) {
    JFrame f = new JFrame("Info");
    f.setUndecorated(true);//from www  .  j a v a  2 s .  c om

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    JLabel waitInfo = new JLabel("Loading your data...");
    waitInfo.setForeground(new Color(105, 105, 105));
    waitInfo.setFont(new Font("Tahoma", Font.BOLD, 13));
    waitInfo.setHorizontalAlignment(JLabel.CENTER);
    waitInfo.setVerticalAlignment(JLabel.CENTER);
    p.add(waitInfo, BorderLayout.CENTER);
    f.getContentPane().add(p);
    f.setSize(360, 40);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    return f;
}

From source file:davmail.ui.SettingsFrame.java

protected void addSettingComponent(JPanel panel, String label, JComponent component, String toolTipText) {
    JLabel fieldLabel = new JLabel(label);
    fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    fieldLabel.setVerticalAlignment(SwingConstants.CENTER);
    panel.add(fieldLabel);/*from w  ww.j av a  2s . com*/
    component.setMaximumSize(component.getPreferredSize());
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
    innerPanel.add(component);
    panel.add(innerPanel);
    if (toolTipText != null) {
        fieldLabel.setToolTipText(toolTipText);
        component.setToolTipText(toolTipText);
    }
}

From source file:davmail.ui.SettingsFrame.java

protected void addPortSettingComponent(JPanel panel, String label, JComponent component,
        JComponent checkboxComponent, JComponent checkboxSSLComponent, String toolTipText) {
    JLabel fieldLabel = new JLabel(label);
    fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    fieldLabel.setVerticalAlignment(SwingConstants.CENTER);
    panel.add(fieldLabel);/*from w  w w. j a v  a  2 s .  com*/
    component.setMaximumSize(component.getPreferredSize());
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
    innerPanel.add(checkboxComponent);
    innerPanel.add(component);
    innerPanel.add(checkboxSSLComponent);
    panel.add(innerPanel);
    if (toolTipText != null) {
        fieldLabel.setToolTipText(toolTipText);
        component.setToolTipText(toolTipText);
    }
}

From source file:greenfoot.gui.export.ExportPublishPane.java

/**
 * Creates a login panel with a username and password and a create account option
 * @return Login panel Component//from ww w  . ja  v  a  2 s.c om
 */
private JComponent getLoginPanel() {
    JComponent loginPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 8, 4));

    loginPanel.setBackground(background);
    loginPanel.setAlignmentX(LEFT_ALIGNMENT);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createEmptyBorder(12, 12, 12, 12));
    loginPanel.setBorder(border);

    JLabel text = new JLabel(Config.getString("export.publish.login"));
    text.setForeground(headingColor);
    text.setVerticalAlignment(SwingConstants.TOP);
    loginPanel.add(text);

    text = new JLabel(Config.getString("export.publish.username"), SwingConstants.TRAILING);
    text.setFont(font);
    loginPanel.add(text);
    userNameField = new JTextField(10);
    userNameField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            String text = userNameField.getText();
            return text.length() > 0;
        }
    });
    userNameField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            checkForExistingScenario();
        }
    });
    loginPanel.add(userNameField);
    text = new JLabel(Config.getString("export.publish.password"), SwingConstants.TRAILING);
    text.setFont(font);
    loginPanel.add(text);
    passwordField = new JPasswordField(10);
    loginPanel.add(passwordField);

    JLabel createAccountLabel = new JLabel(Config.getString("export.publish.createAccount"));
    {
        createAccountLabel.setBackground(background);

        createAccountLabel.setHorizontalAlignment(SwingConstants.RIGHT);
        GreenfootUtil.makeLink(createAccountLabel, createAccountUrl);
    }
    loginPanel.add(createAccountLabel);
    return loginPanel;
}

From source file:com.polivoto.vistas.Charts.java

private JPanel hacerTabla(Pregunta pregunta, List<Opcion> opciones, String perfil) {
    Tabla panel = new Tabla();
    //Panel completo
    //scrollPanel.setBackground(Color.blue);

    //Ttulo pregunta
    JLabel tituloPregunta = new JLabel("\t" + pregunta.getTitulo() + " (" + perfil + ")");
    tituloPregunta.setFont(new Font("Roboto", 1, 24));
    tituloPregunta.setForeground(Color.black);
    tituloPregunta.setVerticalAlignment(JLabel.CENTER);
    JPanel panelHeader = panel.getjPanelHead();
    panelHeader.add(tituloPregunta);//from   w w  w .ja  v a  2 s  .c  o m
    panelHeader.setOpaque(false);
    panelHeader.setPreferredSize(panelGrafica.getSize());

    //Panel de la tabla
    JPanel tabla = new JPanel(new GridLayout(pregunta.obtenerCantidadDeOpciones() + 2, 3, 5, 5));
    tabla.setBackground(Color.white);

    //Poner el titulo de cada columna
    for (int i = 0; i < 3; i++) {
        JPanel tilt = new JPanel();
        tilt.setBackground(new Color(137, 36, 31));
        JLabel label = new JLabel(i == 0 ? "Opcion" : i == 2 ? "Porcentaje" : "Cantidad");
        label.setFont(new Font("Roboto", 1, 18));
        label.setForeground(Color.white);
        tilt.add(label);
        tilt.setSize(new Dimension(0, 35));
        tilt.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230)));
        tabla.add(tilt);
    }

    int sum = 0;

    for (Opcion opcion : opciones) {
        sum += opcion.getCantidad();
    }

    for (Opcion opc : opciones) {
        JPanel p1 = new JPanel(new GridLayout(0, 1));
        p1.setBackground(Color.white);
        p1.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230)));
        JTextArea l1 = new JTextArea(opc.getNombre());

        l1.setWrapStyleWord(true);
        l1.setLineWrap(true);
        l1.setFont(new Font("Roboto", 0, 18));
        l1.setEditable(false);
        l1.setBorder(null);
        p1.setPreferredSize(l1.getSize());
        p1.add(l1);
        tabla.add(p1);

        JPanel p2 = new JPanel();
        p2.setBackground(Color.white);
        p2.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230)));
        JLabel l2 = new JLabel("" + opc.getCantidad());
        l2.setFont(new Font("Roboto", 0, 18));
        p2.add(l2);
        tabla.add(p2);

        JPanel p3 = new JPanel();
        p3.setBackground(Color.white);
        p3.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230)));
        double porcentaje = (opc.getCantidad() * 100.0) / sum;
        JLabel l3 = new JLabel(String.format("%.2f", porcentaje) + "%");
        l3.setFont(new Font("Roboto", 0, 18));
        p3.add(l3);
        tabla.add(p3);
    }

    JPanel p1 = new JPanel();
    p1.setBackground(Color.white);
    p1.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230)));
    JLabel l1 = new JLabel("Total");
    l1.setHorizontalTextPosition(JLabel.LEFT);
    l1.setFont(new Font("Roboto", 1, 18));
    p1.add(l1);
    tabla.add(p1);

    JPanel p2 = new JPanel();
    p2.setBackground(Color.white);
    p2.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230)));
    JLabel l2 = new JLabel("" + sum);
    l2.setFont(new Font("Roboto", 1, 18));
    p2.add(l2);
    tabla.add(p2);

    JPanel p3 = new JPanel();
    p3.setBackground(Color.white);
    p3.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230)));
    JLabel l3 = new JLabel("100.00%");
    l3.setFont(new Font("Roboto", 1, 18));
    p3.add(l3);
    tabla.add(p3);

    panel.getjPanelContent().add(tabla, BorderLayout.CENTER);

    //Relleno
    JPanel x = new JPanel(new GridLayout());
    x.setPreferredSize(new Dimension(100, 0));
    x.setBackground(Color.white);
    panel.getjPanelContent().add(x, BorderLayout.LINE_START);
    JPanel y = new JPanel(new GridLayout());
    y.setPreferredSize(new Dimension(100, 0));
    y.setBackground(Color.white);
    panel.getjPanelContent().add(y, BorderLayout.LINE_END);
    JPanel z = new JPanel(new GridLayout());
    z.setBackground(Color.white);
    z.setPreferredSize(new Dimension(0, 40));
    panel.getjPanelContent().add(z, BorderLayout.PAGE_END);

    return panel;
}

From source file:greenfoot.gui.export.ExportPublishPane.java

/**
 * Creates the scenario information display including information such as title, description, url.
 * For an update (isUpdate = true), the displayed options are slightly different.
 *//*w ww . java2  s. c  o  m*/
private void createScenarioDisplay() {
    leftPanel = new Box(BoxLayout.Y_AXIS);
    JLabel text;
    MiksGridLayout titleAndDescLayout = new MiksGridLayout(6, 2, 8, 8);
    titleAndDescLayout.setVerticallyExpandingRow(3);

    titleAndDescPanel = new JPanel(titleAndDescLayout);
    titleAndDescPanel.setBackground(background);

    if (imagePanel == null) {
        imagePanel = new ImageEditPanel(IMAGE_WIDTH, IMAGE_HEIGHT);
        imagePanel.setBackground(background);
    }

    Box textPanel = new Box(BoxLayout.Y_AXIS);
    {
        text = new JLabel(Config.getString("export.publish.image1"));
        text.setAlignmentX(Component.RIGHT_ALIGNMENT);
        text.setFont(font);
        textPanel.add(text);
        text = new JLabel(Config.getString("export.publish.image2"));
        text.setAlignmentX(Component.RIGHT_ALIGNMENT);
        text.setFont(font);
        textPanel.add(text);
    }
    titleAndDescPanel.add(textPanel);
    titleAndDescPanel.add(imagePanel);

    if (isUpdate) {
        text = new JLabel(Config.getString("export.snapshot.label"), SwingConstants.TRAILING);
        text.setFont(font);
        titleAndDescPanel.add(text);

        keepScenarioScreenshot = new JCheckBox();
        keepScenarioScreenshot.setSelected(true);
        // "keep screenshot" defaults to true, therefore the image panel should be disabled
        imagePanel.enableImageEditPanel(false);
        keepScenarioScreenshot.setName(Config.getString("export.publish.keepScenario"));
        keepScenarioScreenshot.setOpaque(false);
        keepScenarioScreenshot.addChangeListener(this);
        titleAndDescPanel.add(keepScenarioScreenshot);
    }

    text = new JLabel(Config.getString("export.publish.title"), SwingConstants.TRAILING);
    text.setFont(font);
    titleAndDescPanel.add(text);

    String title = project.getName();
    if (getTitle() != null) {
        title = getTitle();
    }
    titleField = new JTextField(title);
    titleField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            String text = titleField.getText();
            return text.length() > 0;
        }
    });
    titleField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            checkForExistingScenario();
        }
    });
    titleAndDescPanel.add(titleField);

    // If there is an update a "changes" description area is shown.
    // If not there a short description and long description area are shown.
    if (isUpdate) {
        JLabel updateLabel = new JLabel(Config.getString("export.publish.update"), SwingConstants.TRAILING);
        updateLabel.setVerticalAlignment(SwingConstants.TOP);
        updateLabel.setFont(font);

        updateArea = new JTextArea();
        updateArea.setRows(6);
        updateArea.setLineWrap(true);
        updateArea.setWrapStyleWord(true);
        JScrollPane updatePane = new JScrollPane(updateArea);

        titleAndDescPanel.add(updateLabel);
        titleAndDescPanel.add(updatePane);
        titleAndDescLayout.setVerticallyExpandingRow(4);
    } else {
        text = new JLabel(Config.getString("export.publish.shortDescription"), SwingConstants.TRAILING);
        text.setFont(font);
        shortDescriptionField = new JTextField();
        titleAndDescPanel.add(text);
        titleAndDescPanel.add(shortDescriptionField);
        text = new JLabel(Config.getString("export.publish.longDescription"), SwingConstants.TRAILING);
        text.setVerticalAlignment(SwingConstants.TOP);
        text.setFont(font);

        descriptionArea = new JTextArea();
        descriptionArea.setRows(6);
        descriptionArea.setLineWrap(true);
        descriptionArea.setWrapStyleWord(true);
        JScrollPane description = new JScrollPane(descriptionArea);
        titleAndDescPanel.add(text);
        titleAndDescPanel.add(description);
    }

    text = new JLabel(Config.getString("export.publish.url"), SwingConstants.TRAILING);
    text.setFont(font);
    titleAndDescPanel.add(text);

    urlField = new JTextField();
    titleAndDescPanel.add(urlField);

    leftPanel.add(titleAndDescPanel, BorderLayout.SOUTH);

    JComponent sourceAndLockPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 8, 0));
    {
        sourceAndLockPanel.setBackground(background);
        includeSource = new JCheckBox(Config.getString("export.publish.includeSource"));
        includeSource.setOpaque(false);
        includeSource.setSelected(false);
        includeSource.setFont(font);
        sourceAndLockPanel.add(includeSource);
        lockScenario.setFont(font);
        sourceAndLockPanel.add(lockScenario);
        sourceAndLockPanel.setMaximumSize(sourceAndLockPanel.getPreferredSize());
    }

    leftPanel.add(sourceAndLockPanel, BorderLayout.SOUTH);
}

From source file:com.polivoto.vistas.Charts.java

public void getHeader(JPanel header) {
    header.removeAll();// w w  w. j av  a  2 s  . co  m
    GridBagConstraints gridBagConstraints;
    header.setLayout(new GridBagLayout());
    header.setBackground(Color.white);
    header.setPreferredSize(new Dimension(0, 100));
    JLabel titulo = new JLabel("<html>     <b>Votacin: </b>" + votacion.getTitulo() + "</html>");
    JLabel lugar = new JLabel("<html>     <b>Lugar: </b>" + votacion.getLugar() + "</html>");
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE d' de 'MMMM' del 'yyyy, hh:mm:ss");
    JLabel fechaInicio = new JLabel(
            "<html><b>Fecha de inicio: </b>" + sdf.format(new Date(votacion.getFechaInicio())) + "</html>");
    JLabel fechaFin = new JLabel(
            "<html><b>Fecha de fin: </b>" + sdf.format(new Date(votacion.getFechaFin())) + "</html>");
    titulo.setFont(fuenteNormal);
    titulo.setVerticalAlignment(JLabel.CENTER);
    lugar.setFont(fuenteNormal);
    lugar.setVerticalAlignment(JLabel.CENTER);
    fechaFin.setFont(fuenteNormal);
    fechaFin.setVerticalAlignment(JLabel.CENTER);
    fechaInicio.setFont(fuenteNormal);
    fechaInicio.setVerticalAlignment(JLabel.CENTER);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5);
    header.add(titulo, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15);
    header.add(fechaInicio, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5);
    header.add(lugar, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15);
    header.add(fechaFin, gridBagConstraints);

    header.repaint();
    header.revalidate();

}