Example usage for javax.swing JLabel setAlignmentX

List of usage examples for javax.swing JLabel setAlignmentX

Introduction

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

Prototype

@BeanProperty(description = "The preferred horizontal alignment of the component.")
public void setAlignmentX(float alignmentX) 

Source Link

Document

Sets the horizontal alignment.

Usage

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

private void initFileNamePatternPanel(SwingConfig config, ComponentRepository componentRepository) {

    JLabel labelPattern = new JLabel(localizer.localize("label.file-name-pattern"));
    labelPattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(labelPattern);

    listPattern = new JComboBox(config.getFileNamePatternListModel());
    listPattern.setEditable(true);/*from w  ww.  j  a  va2 s  .  c o m*/
    listPattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));

    JButton buttonSavePattern = new JButton(localizer.localize("button.save-pattern"));
    buttonSavePattern.setEnabled(false);
    TwoComponentsPanel linePattern = new TwoComponentsPanel(listPattern, buttonSavePattern);
    linePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(linePattern);

    patternFlag = new JCheckBox(localizer.localize("label.regular-expression"));
    patternFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternFlag.setSelected(dataModel.getFileNamePattern().isRegex());
    patternFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.getFileNamePattern().setRegex((ItemEvent.SELECTED == event.getStateChange()));
        }
    });
    patternFlag.addItemListener(componentRepository.getSearchBaseListener());
    browseButtonListener.setRegexCheckBox(patternFlag);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(patternFlag);
    componentRepository.getSearchBaseListener().addToBeEnabled(patternFlag);
    componentRepository.getResetDispatcher().addToBeEnabled(patternFlag);
    listPattern.addActionListener(new PatternListListener(patternFlag, componentRepository.getMessageBox()));
    listPattern.addActionListener(componentRepository.getSearchBaseListener());
    ComboBoxEditor comboBoxEditor = new FileNamePatternEditor(buttonSavePattern);
    listPattern.setEditor(comboBoxEditor);
    browseButtonListener.setComboBox(listPattern);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(listPattern);
    componentRepository.getSearchBaseListener().addToBeEnabled(listPattern);
    componentRepository.getResetDispatcher().addToBeEnabled(listPattern);
    buttonSavePattern.addActionListener(
            new SaveFileNamePatternListener(listPattern, patternFlag, config, componentRepository));
    this.add(patternFlag);

    datePanel = new DateRestrictionPanel(dataModel, componentRepository, config);
    componentRepository.getResetDispatcher().addResetable(datePanel);
    datePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(datePanel);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());
}

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

private void initBaseDirPanel(SwingConfig config, ComponentRepository componentRepository) {

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    JLabel labelBaseDir = new JLabel(config.getLocalizer().localize("label.base-directory"));
    labelBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(labelBaseDir);

    baseDirPathTextField/*from   w  w w  . j  av a 2 s.  c o  m*/
            .setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH, config.getStandardComponentHight()));
    baseDirPathTextField
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    // baseDirPathTextField.setText( dataModel.getBaseDirectory().getPath() );
    baseDirPathTextField.addItem(dataModel.getBaseDirectory().getPath());
    baseDirPathTextField.setSelectedItem(dataModel.getBaseDirectory().getPath());
    baseDirPathTextField.setToolTipText(dataModel.getBaseDirectory().getPath());
    baseDirPathTextField.setEditable(false);
    baseDirPathTextField.addItemListener(new BaseDirectoryComboBoxListener(config, dataModel));

    JButton openBaseDirFileChooserButton = new JButton(localizer.localize("button.browse"));
    openBaseDirFileChooserButton.requestFocusInWindow();
    class BaseDirectoryRepository extends AbstractFileRepository {
        public BaseDirectoryRepository(FARConfig cfg, ComponentRepository repository) {
            super(cfg, repository.getFindForm(), repository.getReplaceForm(), repository.getMessageBox());
        }

        public File getFile() {
            return farconfig.getBaseDirectory();
        }

        public boolean setFile(File file) {
            if (isSubdirectory(replaceForm.getBackupDirectory(), file)) {
                messageBox.error(localizer.localize("message.nested-base-child"));
                return false;
            } else if (isSubdirectory(file, replaceForm.getBackupDirectory())) {
                messageBox.error(localizer.localize("message.nested-base-parent"));
                return false;
            } else {
                baseDirPathTextField.addItem(file.getPath());
                baseDirPathTextField.setSelectedItem(file.getPath());
                baseDirPathTextField.setToolTipText(file.getPath());
                farconfig.setBaseDirectory(file);
                findForm.setBaseDirectory(file);
                return true;
            }
        }
    }
    browseButtonListener = new FindFilePanelBrowseButtonListener(baseDirPathTextField,
            new BaseDirectoryRepository(config, componentRepository),
            localizer.localize("label.choose-base-directory"), componentRepository.getFindCommand(),
            componentRepository.getResetDispatcher());
    browseButtonListener.addActionListener(componentRepository.getSearchBaseListener());
    openBaseDirFileChooserButton.addActionListener(browseButtonListener);
    TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(baseDirPathTextField, openBaseDirFileChooserButton);
    lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(lineBaseDir);

    subdirFlag = new JCheckBox(localizer.localize("label.include-subdir") + ":");
    subdirFlag.setSelected(dataModel.isIncludeSubDirs());
    subdirFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setIncludeSubDirs((ItemEvent.SELECTED == event.getStateChange()));
            if (ItemEvent.SELECTED != event.getStateChange())
                subdirButton.reset();
        }
    });
    subdirFlag.addItemListener(componentRepository.getSearchBaseListener());
    componentRepository.getResetDispatcher().addToBeSelected(subdirFlag);
    browseButtonListener.setSubdirCheckBox(subdirFlag);
    subdirButton = new SubdirPatternLink(dataModel, localizer, componentRepository.getSearchBaseListener(),
            componentRepository.getRootWindow());
    componentRepository.getResetDispatcher().addResetable(subdirButton);
    TwoComponentsPanel subdirpanel = new TwoComponentsPanel(subdirFlag, subdirButton);
    subdirpanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(subdirpanel);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());
}

From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java

/**
 * Creates the UI panel containing all of the fields necessary to upload
 * the current session data to the web service
 *//*w ww  .j  a  va 2  s  . c  o m*/
private void createSetupPane() {
    this.setupPanel = new JPanel();
    this.setupPanel.setLayout(new BorderLayout());
    this.setupPanel.setBackground(Color.white);

    try {
        String data = IOUtils.toString(LoginDialog.class.getResourceAsStream("/export2.html"));
        data = data.replace("{LIST}", formatWitnessList());
        JLabel txt = new JLabel(data);
        this.setupPanel.add(txt, BorderLayout.NORTH);
    } catch (IOException e) {
        // dunno. not much that can be done!
    }

    // ugly layout code to follow. avert your eyes
    JPanel data = new JPanel();
    data.setLayout(new BorderLayout());
    data.setBackground(Color.white);

    JPanel names = new JPanel();
    names.setLayout(new BoxLayout(names, BoxLayout.Y_AXIS));
    names.setBackground(Color.white);
    JLabel l = new JLabel("Name:", SwingConstants.RIGHT);
    l.setPreferredSize(new Dimension(100, 20));
    l.setMaximumSize(new Dimension(100, 20));
    l.setAlignmentX(RIGHT_ALIGNMENT);
    names.add(l);
    names.add(Box.createVerticalStrut(5));

    JLabel l2 = new JLabel("Description:", SwingConstants.RIGHT);
    l2.setPreferredSize(new Dimension(100, 20));
    l2.setMaximumSize(new Dimension(100, 20));
    l2.setAlignmentX(RIGHT_ALIGNMENT);
    names.add(l2);
    data.add(names, BorderLayout.WEST);

    JPanel edits = new JPanel();
    edits.setBackground(Color.white);
    edits.setLayout(new BoxLayout(edits, BoxLayout.Y_AXIS));
    this.nameEdit = new JTextField();
    this.nameEdit.setPreferredSize(new Dimension(200, 22));
    this.nameEdit.setMaximumSize(new Dimension(200, 22));
    File saveFile = this.juxtaFrame.getSession().getSaveFile();
    if (saveFile == null) {
        this.nameEdit.setText("new_session");
    } else {
        String name = saveFile.getName();
        this.nameEdit.setText(name.substring(0, name.lastIndexOf('.')));
    }
    edits.add(this.nameEdit);

    this.descriptionEdit = new JTextArea(3, 0);
    this.descriptionEdit.setLineWrap(true);
    this.descriptionEdit.setWrapStyleWord(true);

    JScrollPane sp = new JScrollPane(this.descriptionEdit);
    sp.setPreferredSize(new Dimension(194, 60));
    sp.setMaximumSize(new Dimension(194, 300));
    edits.add(Box.createVerticalStrut(4));
    edits.add(sp);

    data.add(edits, BorderLayout.CENTER);

    this.setupPanel.add(data, BorderLayout.SOUTH);
}

From source file:net.pandoragames.far.ui.swing.dialog.SettingsDialog.java

private void init() {
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
    this.setResizable(false);

    JPanel basePanel = new JPanel();
    basePanel.setLayout(new BoxLayout(basePanel, BoxLayout.Y_AXIS));
    basePanel.setBorder(/*from   w  ww .  j  ava2s.  c  o m*/
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));
    registerCloseWindowKeyListener(basePanel);

    // sink for error messages
    MessageLabel errorField = new MessageLabel();
    errorField.setMinimumSize(new Dimension(100, swingConfig.getStandardComponentHight()));
    errorField.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING));
    TwoComponentsPanel lineError = new TwoComponentsPanel(errorField,
            Box.createRigidArea(new Dimension(1, swingConfig.getStandardComponentHight())));
    lineError.setAlignmentX(Component.LEFT_ALIGNMENT);
    basePanel.add(lineError);

    // character set
    JLabel labelCharset = new JLabel(swingConfig.getLocalizer().localize("label.default-characterset"));
    labelCharset.setAlignmentX(Component.LEFT_ALIGNMENT);
    basePanel.add(labelCharset);

    JComboBox listCharset = new JComboBox(swingConfig.getCharsetList().toArray());
    listCharset.setAlignmentX(Component.LEFT_ALIGNMENT);
    listCharset.setSelectedItem(swingConfig.getDefaultCharset());
    listCharset.setEditable(true);
    listCharset.setMaximumSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight()));

    listCharset.addActionListener(new CharacterSetListener(errorField));
    listCharset.setEditor(new CharacterSetEditor(errorField));
    basePanel.add(listCharset);

    basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // select the group selector
    JPanel selectorPanel = new JPanel();
    selectorPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    selectorPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    // linePattern.setAlignmentX( Component.LEFT_ALIGNMENT );
    JLabel labelSelector = new JLabel(swingConfig.getLocalizer().localize("label.group-ref-indicator"));
    selectorPanel.add(labelSelector);
    JComboBox selectorBox = new JComboBox(FARConfig.GROUPREFINDICATORLIST);
    selectorBox.setSelectedItem(Character.toString(groupReference));
    selectorBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            JComboBox cbox = (JComboBox) event.getSource();
            String indicator = (String) cbox.getSelectedItem();
            groupReference = indicator.charAt(0);
        }
    });
    selectorPanel.add(selectorBox);
    basePanel.add(selectorPanel);

    basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // checkbox DO BACKUP
    JCheckBox doBackupFlag = new JCheckBox(swingConfig.getLocalizer().localize("label.create-backup"));
    doBackupFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    doBackupFlag.setHorizontalTextPosition(SwingConstants.LEADING);
    doBackupFlag.setSelected(replaceForm.isDoBackup());
    doBackupFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            doBackup = ItemEvent.SELECTED == event.getStateChange();
            backupFlagEvent = event;
        }
    });
    basePanel.add(doBackupFlag);

    JTextField backupDirPathTextField = new JTextField();
    backupDirPathTextField.setPreferredSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH, swingConfig.getStandardComponentHight()));
    backupDirPathTextField.setMaximumSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight()));
    backupDirPathTextField.setText(backupDirectory.getPath());
    backupDirPathTextField.setToolTipText(backupDirectory.getPath());
    backupDirPathTextField.setEditable(false);
    JButton openBaseDirFileChooserButton = new JButton(swingConfig.getLocalizer().localize("button.browse"));
    BrowseButtonListener backupDirButtonListener = new BrowseButtonListener(backupDirPathTextField,
            new BackUpDirectoryRepository(swingConfig, findForm, replaceForm, errorField),
            swingConfig.getLocalizer().localize("label.choose-backup-directory"));
    openBaseDirFileChooserButton.addActionListener(backupDirButtonListener);
    TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(backupDirPathTextField,
            openBaseDirFileChooserButton);
    lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT);
    basePanel.add(lineBaseDir);

    basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    JPanel fileInfoPanel = new JPanel();
    fileInfoPanel
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                    swingConfig.getLocalizer().localize("label.default-file-info")));
    fileInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    fileInfoPanel.setLayout(new BoxLayout(fileInfoPanel, BoxLayout.Y_AXIS));
    JLabel fileInfoLabel = new JLabel(swingConfig.getLocalizer().localize("message.displayed-in-info-column"));
    fileInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    fileInfoPanel.add(fileInfoLabel);
    fileInfoPanel.add(Box.createHorizontalGlue());
    JRadioButton nothingRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.nothing"));
    nothingRadio.setAlignmentX(Component.LEFT_ALIGNMENT);
    nothingRadio.setActionCommand(SwingConfig.DefaultFileInfo.NOTHING.name());
    nothingRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.NOTHING);
    fileInfoOptions.add(nothingRadio);
    fileInfoPanel.add(nothingRadio);
    JRadioButton readOnlyRadio = new JRadioButton(
            swingConfig.getLocalizer().localize("label.read-only-warning"));
    readOnlyRadio.setAlignmentX(Component.LEFT_ALIGNMENT);
    readOnlyRadio.setActionCommand(SwingConfig.DefaultFileInfo.READONLY.name());
    readOnlyRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.READONLY);
    fileInfoOptions.add(readOnlyRadio);
    fileInfoPanel.add(readOnlyRadio);
    JRadioButton sizeRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.filesize"));
    sizeRadio.setAlignmentX(Component.LEFT_ALIGNMENT);
    sizeRadio.setActionCommand(SwingConfig.DefaultFileInfo.SIZE.name());
    sizeRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.SIZE);
    fileInfoOptions.add(sizeRadio);
    fileInfoPanel.add(sizeRadio);
    JCheckBox showPlainBytesFlag = new JCheckBox(
            "  " + swingConfig.getLocalizer().localize("label.show-plain-bytes"));
    showPlainBytesFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    showPlainBytesFlag.setHorizontalTextPosition(SwingConstants.LEADING);
    showPlainBytesFlag.setSelected(swingConfig.isShowPlainBytes());
    showPlainBytesFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            showBytes = ItemEvent.SELECTED == event.getStateChange();
        }
    });
    fileInfoPanel.add(showPlainBytesFlag);
    JRadioButton lastModifiedRadio = new JRadioButton(
            swingConfig.getLocalizer().localize("label.last-modified"));
    lastModifiedRadio.setAlignmentX(Component.LEFT_ALIGNMENT);
    lastModifiedRadio.setActionCommand(SwingConfig.DefaultFileInfo.LAST_MODIFIED.name());
    lastModifiedRadio
            .setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.LAST_MODIFIED);
    fileInfoOptions.add(lastModifiedRadio);
    fileInfoPanel.add(lastModifiedRadio);
    basePanel.add(fileInfoPanel);

    // buttons
    JPanel buttonPannel = new JPanel();
    buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    // cancel
    JButton cancelButton = new JButton(swingConfig.getLocalizer().localize("button.cancel"));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            SettingsDialog.this.dispose();
        }
    });
    buttonPannel.add(cancelButton);
    // save
    JButton saveButton = new JButton(swingConfig.getLocalizer().localize("button.save"));
    saveButton.addActionListener(new SaveButtonListener());
    buttonPannel.add(saveButton);
    this.getRootPane().setDefaultButton(saveButton);

    this.add(basePanel);
    this.add(buttonPannel);
    placeOnScreen(swingConfig.getScreenCenter());
}

From source file:tn.mariages.gui.Accueil.java

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    int h = Toolkit.getDefaultToolkit().getScreenSize().height;
    int w = Toolkit.getDefaultToolkit().getScreenSize().width;

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    this.setLocation(-27, -16);
    this.setSize(144, h + 16);
    this.setExtendedState(this.MAXIMIZED_VERT);

    System.out.println("H " + h);

    JFrame LogoFrame = new JFrame("Logo");
    LogoFrame.setSize(w - 45, h + 16);/*from  ww  w  .j  a va 2  s .co m*/
    LogoFrame.setExtendedState(this.MAXIMIZED_HORIZ);
    this.setAlwaysOnTop(true);
    //LogoFrame.setExtendedState(LogoFrame.MAXIMIZED_BOTH);
    LogoFrame.setLocation(65, -16);
    JPanel logoPanel = new JPanel();
    LogoFrame.add(logoPanel);

    ImageIcon icon;
    try {
        icon = new ImageIcon(new URL("http://www.images.tn/upload/original/1394208853.png")); /// TO CHANGE
        icon = new ImageIcon(icon.getImage().getScaledInstance(400, 400, BufferedImage.SCALE_SMOOTH));
        JLabel logoLabel = new JLabel(icon);

        logoPanel.add(logoLabel);
        logoLabel.setAlignmentX(CENTER_ALIGNMENT);
        logoLabel.setAlignmentY(400);
    } catch (MalformedURLException ex) {
        Logger.getLogger(ListeFeatProd.class.getName()).log(Level.SEVERE, null, ex);
    }
    LogoFrame.setVisible(true);
    // TODO add your handling code here:
}

From source file:com.funambol.json.admin.JsonConnectorConfigPanel.java

/**
 * Create the panel/*from  www  . j  a  v  a2 s . c o m*/
 */
private void init() {

    JLabel title, serverLabel;
    JPanel seccPanel;
    JPanel behaviourOnErrorsPanel;

    title = new JLabel();
    seccPanel = new JPanel();
    behaviourOnErrorsPanel = new JPanel();

    serverLabel = new JLabel();
    serverValue = new JTextField();

    setLayout(null);

    title.setFont(titlePanelFont);
    title.setText("Funambol Json Connector");
    title.setBounds(new Rectangle(14, 5, 316, 28));
    title.setAlignmentX(SwingConstants.CENTER);
    title.setBorder(new TitledBorder(""));

    seccPanel.setLayout(null);
    seccPanel.setBorder(new TitledBorder("HTTP Server Configuration"));

    serverLabel.setText("Server:");
    seccPanel.add(serverLabel);
    serverLabel.setBounds(10, 20, 116, 15);
    seccPanel.add(serverValue);
    serverValue.setBounds(150, 20, 220, 19);
    serverValue.setFont(defaultFont);

    add(seccPanel);
    seccPanel.setBounds(10, 50, 380, 70);

    //the ssl option panel

    behaviourOnErrorsPanel.setBorder(new TitledBorder("Behaviour on errors"));
    behaviourOnErrorsPanel.setLayout(null);

    stopSyncOnFatalError.setText("Stop sync on fatal errors");
    stopSyncOnFatalError.setBounds(10, 25, 200, 15);

    behaviourOnErrorsPanel.add(stopSyncOnFatalError);

    add(behaviourOnErrorsPanel);
    behaviourOnErrorsPanel.setBounds(10, 130, 380, 60);

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Save");
    add(confirmButton);
    confirmButton.setBounds(160, 200, 70, 25);

    confirmButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                JsonConnectorConfigPanel.this.actionPerformed(new ActionEvent(JsonConnectorConfigPanel.this,
                        ACTION_EVENT_UPDATE, event.getActionCommand()));
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    //
    // Setting font...
    //
    Component[] components = getComponents();
    for (int i = 0; (components != null) && (i < components.length); ++i) {
        components[i].setFont(defaultFont);
    }

    //
    // We add it as the last one so that the font won't be changed
    //
    add(title);
}

From source file:com.game.ui.views.ItemPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(
            "<html><div style='width : 500px;'>Pls select a value from the dropdown or you can create a new "
                    + "entity below. Once selected an Item, its' details will be available below</div></html>");
    noteLbl.setAlignmentX(0);
    add(noteLbl);/*w w w .  j a v a  2 s  .  c om*/
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    if (ringPanel) {
        for (Item item : GameBean.ringDetails) {
            model.addElement(((Ring) item).getName());
        }
    } else if (armourPanel) {
        for (Item item : GameBean.armourDetails) {
            model.addElement(((Armour) item).getName());
        }
    } else if (potionPanel) {
        for (Item item : GameBean.potionDetails) {
            model.addElement(((Potion) item).getName());
        }
    } else if (treasurePanel) {
        for (Item item : GameBean.treasureDetails) {
            model.addElement(((Treasure) item).getName());
        }
    }
    doCommonStuffForDropDown(model);
    doCommonStuffForContent();
}

From source file:com.game.ui.views.CharacterEditor.java

/**
 * This method draws up the gui on the panel.
 *///from  ww w  .  jav a 2 s  .com
public void doGui() {
    JPanel outerPane = new JPanel();
    outerPane.setLayout(new GridBagLayout());
    //        setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(lblContent);
    noteLbl.setAlignmentX(0);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 4;
    c.gridy = 0;
    c.gridx = 0;
    outerPane.add(noteLbl, c);
    System.out.println(c.gridy);
    c.gridy++;
    System.out.println(c.gridy);
    c.gridx = 0;
    c.gridwidth = 1;
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    outerPane.add(comboBox, c);
    c.gridy++;
    JLabel nameLbl = new JLabel("Name : ");
    outerPane.add(nameLbl, c);
    c.gridx++;
    name = new JTextField();
    name.setColumns(20);
    outerPane.add(name, c);
    c.gridx = 0;
    c.gridy++;
    JLabel imageLbl = new JLabel("Image Path : ");
    outerPane.add(imageLbl, c);
    c.gridx++;
    imgPath = new JTextField();
    imgPath.setColumns(20);
    outerPane.add(imgPath, c);
    c.gridx = 0;
    c.gridy++;
    JLabel hitPtsLbl = new JLabel("Hit Points : ");
    outerPane.add(hitPtsLbl, c);
    c.gridx++;
    hitPoints = new JTextField();
    hitPoints.setColumns(20);
    outerPane.add(hitPoints, c);
    c.gridx = 0;
    c.gridy++;
    JLabel lvl = new JLabel("Level : ");
    outerPane.add(lvl, c);
    c.gridx++;
    level = new JTextField();
    level.setColumns(20);
    /*if(!isEnemy){
    level.setText("1");
    level.setEnabled(false);
    }*/
    outerPane.add(level, c);
    c.gridx = 0;
    c.gridy++;
    JLabel mlWpn = new JLabel("Melee Weapon : ");
    outerPane.add(mlWpn, c);
    c.gridx++;
    model = new DefaultComboBoxModel();
    LinkedList<String> meleeWpnList = new LinkedList<String>();
    LinkedList<String> rngdWpnList = new LinkedList<String>();
    for (Item item : GameBean.weaponDetails) {
        Weapon wpn = (Weapon) item;
        if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[0])) {
            meleeWpnList.add(wpn.getName());
        } else {
            rngdWpnList.add(wpn.getName());
        }
        weaponMap.put(wpn.getName(), wpn);
    }
    meleeWeapon = new JComboBox(new DefaultComboBoxModel(meleeWpnList.toArray()));
    meleeWeapon.setSelectedIndex(-1);
    meleeWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(meleeWeapon, c);
    c.gridx++;
    JLabel rngdWpn = new JLabel("Ranged Weapon : ");
    outerPane.add(rngdWpn, c);
    c.gridx++;
    rangedWeapon = new JComboBox(new DefaultComboBoxModel(rngdWpnList.toArray()));
    rangedWeapon.setSelectedIndex(-1);
    rangedWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(rangedWeapon, c);
    c.gridy++;
    c.gridx = 0;
    JLabel armourLbl = new JLabel("Armour : ");
    outerPane.add(armourLbl, c);
    c.gridx++;
    LinkedList<String> armourList = new LinkedList<String>();
    LinkedList<String> shildList = new LinkedList<String>();
    for (Item item : GameBean.armourDetails) {
        Armour temp = (Armour) item;
        if (temp.getArmourType() != null) {
            if (temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[1])) {
                armourList.add(temp.getName());
            } else {
                shildList.add(temp.getName());
            }
        } else {
            armourList.add(temp.getName());
            //            else if(temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[2]))
            shildList.add(temp.getName());
        }
        armorMap.put(temp.getName(), temp);
    }
    armour = new JComboBox(new DefaultComboBoxModel(armourList.toArray()));
    armour.setSelectedIndex(-1);
    armour.setMaximumSize(new Dimension(100, 30));
    outerPane.add(armour, c);
    c.gridx++;
    JLabel shieldLbl = new JLabel("Shield : ");
    outerPane.add(shieldLbl, c);
    c.gridx++;
    shield = new JComboBox(new DefaultComboBoxModel(shildList.toArray()));
    shield.setSelectedIndex(-1);
    shield.setMaximumSize(new Dimension(100, 30));
    outerPane.add(shield, c);
    ta = new JTextArea(10, 50);
    ta.setRows(40);
    ta.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    JScrollPane scrollPane = new JScrollPane(ta);
    scrollPane.setPreferredSize(new Dimension(600, 250));
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = 4;
    c.gridheight = 4;
    c.weightx = .5;
    c.weighty = 1;
    outerPane.add(scrollPane, c);
    c.gridy += 4;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.gridheight = 1;
    c.gridwidth = 1;
    JButton generate = new JButton("Generate");
    JButton submit = new JButton("Submit");
    outerPane.add(generate, c);
    submit.addActionListener(this);
    generate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            ta.setText("");
            HashSet<Integer> set = new HashSet<Integer>();
            int strength = getUniqueVal(set);
            int constitution = getUniqueVal(set);
            int dext = getUniqueVal(set);
            int intel = getUniqueVal(set);
            int charisma = getUniqueVal(set);
            int wisdom = getUniqueVal(set);
            if (character == null) {
                builder = new CharacterBuilder(isEnemy);
            } else {
                builder = new CharacterBuilder(character);
            }
            builder.setStrength(strength);
            builder.setConstitution(constitution);
            builder.setDexterity(dext);
            builder.setIntelligence(intel);
            builder.setCharisma(charisma);
            builder.setWisdom(wisdom);
            int strModifier = GameUtils.calculateAbilityModifier(strength);
            int conModifier = GameUtils.calculateAbilityModifier(constitution);
            int dexModifier = GameUtils.calculateAbilityModifier(dext);
            int wisModifier = GameUtils.calculateAbilityModifier(wisdom);
            int intModifier = GameUtils.calculateAbilityModifier(intel);
            int chaModifier = GameUtils.calculateAbilityModifier(charisma);
            builder.setStrengthModifier(strModifier);
            builder.setConstitutionModifier(conModifier);
            builder.setCharismaModifier(chaModifier);
            builder.setWisdomModifier(wisModifier);
            builder.setIntelligenceModifier(intModifier);
            builder.setDexterityModifier(dexModifier);
            String type = null;
            if (constitution < strength && constitution > dext) {
                type = "Bully";
                builder.setType("Bully");
            } else if (dext > constitution && constitution > strength) {
                builder.setType("Nimble");
                type = "Nimble";
            } else {
                builder.setType("Tank");
                type = "Tank";
            }
            ta.append("Strength : " + strength);
            ta.append("\nDexterity : " + dexModifier);
            ta.append("\nConstitution : " + constitution);
            ta.append("\nIntelligence : " + intel);
            ta.append("\nCharisma: " + charisma);
            ta.append("\nWisdom : " + wisdom);
            ta.append("\nType :" + type);
            ta.append("\nStrength Modifier :" + strModifier);
            ta.append("\nConstitution Modifier :" + conModifier);
            ta.append("\nDexterity Modifier :" + dexModifier);
            generated = true;
            if (character != null) {
                character = builder.build();
            }
        }
    });
    c.gridx++;
    outerPane.add(submit, c);
    validationMess = new JLabel();
    validationMess.setForeground(Color.red);
    //        validationMess.setVisible(false);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 4;
    outerPane.add(validationMess, c);
    JScrollPane outerScrollPane = new JScrollPane(outerPane);
    setLayout(new BorderLayout());
    add(outerScrollPane, BorderLayout.CENTER);
}

From source file:diet.gridr.g5k.gui.GanttChart.java

/**
 * Method returning the TablePanel/*  ww w  .  j a  va  2  s.co m*/
 *
 * @return the table panel
 */
private JPanel getTablePanel() {
    tablePanel = new JPanel();
    tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.Y_AXIS));
    tablePanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
    jobsTable = new JTable();
    jobsModel = new ClusterJobsSummaryModel();
    jobsTable.setModel(jobsModel);
    ClusterJobsSummaryCellRenderer renderer = new ClusterJobsSummaryCellRenderer();
    jobsTable.setDefaultRenderer(String.class, renderer);
    JLabel jobsTableTitle = new JLabel("Jobs status");
    jobsTableTitle.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    jobsTableTitle.setFont(new Font("Dialog", Font.BOLD, 14));
    tablePanel.add(Box.createVerticalStrut(5));
    tablePanel.add(jobsTableTitle);
    tablePanel.add(Box.createVerticalStrut(10));
    tablePanel.add(jobsTable.getTableHeader());
    tablePanel.add(jobsTable);
    LoggingManager.log(Level.FINE, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "getTablePanel",
            "TablePanel constructed");
    return tablePanel;
}

From source file:diet.gridr.g5k.gui.ClusterInfoPanel.java

/**
 * This method initializes jPanel2/* ww  w . j  a  v  a 2s  . c  o  m*/
 *
 * @return javax.swing.JPanel
 */
private JPanel getJPanel2() {
    if (jPanel2 == null) {
        jPanel2 = new JPanel();
        jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.Y_AXIS));
        jPanel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        jobsTable = new JTable();
        jobsModel = new ClusterJobsSummaryModel();
        jobsTable.setModel(jobsModel);
        ClusterJobsSummaryCellRenderer renderer = new ClusterJobsSummaryCellRenderer();
        jobsTable.setDefaultRenderer(String.class, renderer);
        //jobsTable.createDefaultColumnsFromModel();
        JLabel jobsTableTitle = new JLabel("Jobs status");
        jobsTableTitle.setAlignmentX(JLabel.CENTER_ALIGNMENT);
        jobsTableTitle.setFont(new Font("Dialog", Font.BOLD, 14));
        jPanel2.add(Box.createVerticalStrut(5));
        jPanel2.add(jobsTableTitle);
        jPanel2.add(Box.createVerticalStrut(10));
        jPanel2.add(jobsTable.getTableHeader());
        jPanel2.add(jobsTable);
        LoggingManager.log(Level.FINER, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "getJPanel2",
                "Cluster jobs summary table added");
    }
    return jPanel2;
}