Search in sources :

Example 11 with GridBagConstraints

use of java.awt.GridBagConstraints in project pcgen by PCGen.

the class SummaryInfoTab method initLevelPanel.

private void initLevelPanel(JPanel panel) {
    panel.setLayout(new GridBagLayout());
    //$NON-NLS-1$
    JLabel addLabel = createLabel("in_sumAddLevels");
    //$NON-NLS-1$
    JLabel removeLabel = createLabel("in_sumRemoveLevels");
    JLabel darrowLabel = new JLabel(Icons.button_arrow_down.getImageIcon());
    JLabel uarrowLabel = new JLabel(Icons.button_arrow_up.getImageIcon());
    addLevelsButton.setMargin(new Insets(0, 8, 0, 8));
    addLevelsField.setValue(1);
    addLevelsField.setHorizontalAlignment(SwingConstants.RIGHT);
    removeLevelsButton.setMargin(new Insets(0, 8, 0, 8));
    removeLevelsField.setValue(1);
    removeLevelsField.setHorizontalAlignment(SwingConstants.RIGHT);
    GridBagConstraints gbc1 = new GridBagConstraints();
    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc1.weightx = gbc2.weightx = 0.5;
    gbc1.insets = new Insets(1, 0, 1, 0);
    gbc2.insets = new Insets(1, 0, 1, 0);
    gbc2.gridwidth = GridBagConstraints.REMAINDER;
    panel.add(addLabel, gbc1);
    panel.add(removeLabel, gbc2);
    gbc1.ipadx = 30;
    panel.add(addLevelsField, gbc1);
    gbc2.ipadx = 30;
    panel.add(removeLevelsField, gbc2);
    gbc1.ipadx = 0;
    panel.add(addLevelsButton, gbc1);
    gbc2.ipadx = 0;
    panel.add(removeLevelsButton, gbc2);
    panel.add(darrowLabel, gbc1);
    panel.add(uarrowLabel, gbc2);
    ClassLevelTableModel.initializeTable(classLevelTable);
    gbc2.weightx = 0;
    gbc2.weighty = 1;
    gbc2.fill = GridBagConstraints.BOTH;
    panel.add(new JScrollPane(classLevelTable), gbc2);
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel)

Example 12 with GridBagConstraints

use of java.awt.GridBagConstraints in project pcgen by PCGen.

the class PortraitInfoPane method initComponents.

private void initComponents() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    Utility.buildConstraints(gbc, 0, 0, 2, 1, 0, 0);
    panel.add(new JLabel(LanguageBundle.getString("in_largePortrait")), gbc);
    Utility.buildConstraints(gbc, 0, 1, 2, 1, 0, 0);
    panel.add(portraitPane, gbc);
    Utility.buildConstraints(gbc, 0, 2, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
    panel.add(loadButton, gbc);
    Utility.buildConstraints(gbc, 1, 2, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
    panel.add(clearButton, gbc);
    Utility.buildConstraints(gbc, 2, 1, 1, 1, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.CENTER);
    zoomSlider.setInverted(true);
    zoomSlider.setPreferredSize(new Dimension(20, 10));
    panel.add(zoomSlider, gbc);
    Utility.buildConstraints(gbc, 3, 0, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    panel.add(new JLabel(LanguageBundle.getString("in_thumbnailPortrait")), gbc);
    Utility.buildConstraints(gbc, 3, 1, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTH);
    panel.add(tnPane, gbc);
    this.setViewportView(panel);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 13 with GridBagConstraints

use of java.awt.GridBagConstraints in project pcgen by PCGen.

the class RunConvertPanel method setupDisplay.

/**
	 * @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
	 */
@Override
public void setupDisplay(JPanel panel, CDOMObject pc) {
    panel.setLayout(new GridBagLayout());
    JLabel introLabel = new JLabel("Conversion in progress");
    GridBagConstraints gbc = new GridBagConstraints();
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 10, 5, 10);
    panel.add(introLabel, gbc);
    JLabel explainLabel = new JLabel("<html>The LST data is being converted. In the log, " + "LSTERROR rows are errors that need to be manually corrected in the source data. " + "LSTWARN rows indicate changes the converter is making. " + "See " + changeLogFile.getAbsolutePath() + " for a log of all data changes.</html>");
    explainLabel.setFocusable(true);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 10, 5, 10);
    panel.add(explainLabel, gbc);
    progressBar = getProgressBar();
    Dimension d = progressBar.getPreferredSize();
    d.width = 400;
    progressBar.setPreferredSize(d);
    progressBar.setStringPainted(true);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel.add(progressBar, gbc);
    messageAreaContainer = new JScrollPane(getMessageArea());
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0);
    gbc.fill = GridBagConstraints.BOTH;
    panel.add(messageAreaContainer, gbc);
    panel.setPreferredSize(new Dimension(800, 500));
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 14 with GridBagConstraints

use of java.awt.GridBagConstraints in project pcgen by PCGen.

the class SourceSelectionPanel method setupDisplay.

@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(new GridBagLayout());
    JLabel label = new JLabel("Please select the Source Directory to Convert: ");
    GridBagConstraints gbc = new GridBagConstraints();
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
    gbc.insets = new Insets(50, 25, 10, 25);
    panel.add(label, gbc);
    JButton button = new JButton("Browse...");
    button.setMnemonic('r');
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser(SourceFolder.OTHER.getFile());
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setDialogType(JFileChooser.OPEN_DIALOG);
            chooser.setSelectedFile(path);
            while (true) {
                int open = chooser.showOpenDialog(null);
                if (open == JFileChooser.APPROVE_OPTION) {
                    File fileToOpen = chooser.getSelectedFile();
                    if (fileToOpen.isDirectory()) {
                        path = fileToOpen;
                        SourceFolder.OTHER.setFile(fileToOpen);
                        pc.put(ObjectKey.DIRECTORY, path);
                        PCGenSettings context = PCGenSettings.getInstance();
                        context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, path.getAbsolutePath());
                        JRadioButton button = radioButtons[SourceFolder.OTHER.ordinal()];
                        button.setSelected(true);
                        button.setText(buildFolderText(SourceFolder.OTHER, fileToOpen.getAbsolutePath()));
                        break;
                    }
                    JOptionPane.showMessageDialog(null, "Selection must be a valid Directory");
                    chooser.setSelectedFile(path);
                } else if (open == JFileChooser.CANCEL_OPTION) {
                    break;
                }
            }
        }
    });
    radioButtons = new JRadioButton[SourceFolder.values().length];
    String selectedPath = null;
    File selectedFile = pc.get(ObjectKey.DIRECTORY);
    if (selectedFile != null) {
        selectedPath = selectedFile.getAbsolutePath();
    } else {
        PCGenSettings context = PCGenSettings.getInstance();
        selectedPath = context.getProperty(PCGenSettings.CONVERT_INPUT_PATH, null);
    }
    ButtonGroup group = new ButtonGroup();
    boolean haveSelected = false;
    Font font = panel.getFont();
    font = FontManipulation.plain(font);
    for (SourceFolder folder : SourceFolder.values()) {
        JRadioButton pathButton = new JRadioButton();
        final SourceFolder buttonFolder = folder;
        pathButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                PCGenSettings context = PCGenSettings.getInstance();
                context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, buttonFolder.getFile().getAbsolutePath());
                pc.put(ObjectKey.DIRECTORY, buttonFolder.getFile());
            }
        });
        String path;
        if (folder.getFile() == null) {
            path = "Undefined";
            pathButton.setEnabled(false);
        } else {
            path = folder.getFile().getAbsolutePath();
            if (path.equals(selectedPath)) {
                pathButton.setSelected(true);
                haveSelected = true;
                PCGenSettings context = PCGenSettings.getInstance();
                context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, path);
                selectedFile = folder.getFile();
            }
        }
        pathButton.setText(buildFolderText(folder, path));
        pathButton.setFont(font);
        radioButtons[folder.ordinal()] = pathButton;
        group.add(pathButton);
        if (folder == SourceFolder.OTHER) {
            Utility.buildRelativeConstraints(gbc, 1, GridBagConstraints.REMAINDER, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
        } else {
            Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
        }
        gbc.insets = new Insets(10, 25, 10, 25);
        panel.add(pathButton, gbc);
        if (folder == SourceFolder.OTHER) {
            Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHEAST);
            gbc.insets = new Insets(10, 25, 10, 25);
            panel.add(button, gbc);
        }
    }
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
    panel.add(new JLabel(" "), gbc);
    if (!haveSelected) {
        if (selectedPath != null) {
            JRadioButton btn = radioButtons[SourceFolder.OTHER.ordinal()];
            btn.setSelected(true);
            selectedFile = new File(selectedPath);
            SourceFolder.OTHER.setFile(selectedFile);
            path = selectedFile;
            btn.setText(buildFolderText(SourceFolder.OTHER, selectedFile.getAbsolutePath()));
        } else if (radioButtons[SourceFolder.VENDORDATA.ordinal()].isEnabled()) {
            JRadioButton btn = radioButtons[SourceFolder.VENDORDATA.ordinal()];
            btn.setSelected(true);
            selectedFile = SourceFolder.VENDORDATA.getFile();
        } else if (radioButtons[SourceFolder.HOMEBREWDATA.ordinal()].isEnabled()) {
            JRadioButton btn = radioButtons[SourceFolder.HOMEBREWDATA.ordinal()];
            btn.setSelected(true);
            selectedFile = SourceFolder.HOMEBREWDATA.getFile();
        } else {
            JRadioButton btn = radioButtons[SourceFolder.DATA.ordinal()];
            btn.setSelected(true);
            selectedFile = SourceFolder.DATA.getFile();
        }
    }
    pc.put(ObjectKey.DIRECTORY, selectedFile);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Font(java.awt.Font) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) ButtonGroup(javax.swing.ButtonGroup) PCGenSettings(pcgen.system.PCGenSettings) File(java.io.File)

Example 15 with GridBagConstraints

use of java.awt.GridBagConstraints in project pcgen by PCGen.

the class CampaignPanel method setupDisplay.

/**
	 * @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
	 */
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(new GridBagLayout());
    JLabel introLabel = new JLabel("Please select the Campaign(s) to Convert:");
    GridBagConstraints gbc = new GridBagConstraints();
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
    gbc.insets = new Insets(25, 25, 5, 25);
    panel.add(introLabel, gbc);
    final CampaignTableModel model = new CampaignTableModel(gameModeCampaigns, folderName);
    final JTable table = new JTable(model) {

        //Implement table cell tool tips.
        @Override
        public String getToolTipText(MouseEvent e) {
            java.awt.Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);
            int colIndex = columnAtPoint(p);
            String tip = String.valueOf(getValueAt(rowIndex, colIndex));
            return tip;
        }
    };
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent event) {
            pc.removeListFor(ListKey.CAMPAIGN);
            int[] selRows = table.getSelectedRows();
            if (selRows.length == 0) {
                saveSourceSelection(pc);
                fireProgressEvent(ProgressEvent.NOT_ALLOWED);
            } else {
                for (int row : selRows) {
                    Campaign selCampaign = (Campaign) model.getValueAt(row, 0);
                    pc.addToListFor(ListKey.CAMPAIGN, selCampaign);
                }
                saveSourceSelection(pc);
                fireProgressEvent(ProgressEvent.ALLOWED);
            }
        }
    });
    JScrollPane listScroller = new JScrollPane(table);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0);
    gbc.fill = GridBagConstraints.BOTH;
    panel.add(listScroller, gbc);
    initSourceSelection(model, table);
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JLabel(javax.swing.JLabel) ListSelectionListener(javax.swing.event.ListSelectionListener) Campaign(pcgen.core.Campaign) JTable(javax.swing.JTable)

Aggregations

GridBagConstraints (java.awt.GridBagConstraints)1628 GridBagLayout (java.awt.GridBagLayout)1200 Insets (java.awt.Insets)1044 JPanel (javax.swing.JPanel)960 JLabel (javax.swing.JLabel)833 JButton (javax.swing.JButton)350 ActionEvent (java.awt.event.ActionEvent)303 ActionListener (java.awt.event.ActionListener)284 Dimension (java.awt.Dimension)266 JScrollPane (javax.swing.JScrollPane)252 JTextField (javax.swing.JTextField)250 BorderLayout (java.awt.BorderLayout)214 JCheckBox (javax.swing.JCheckBox)200 JComboBox (javax.swing.JComboBox)101 Color (java.awt.Color)98 FlowLayout (java.awt.FlowLayout)93 TitledBorder (javax.swing.border.TitledBorder)91 Font (java.awt.Font)85 BoxLayout (javax.swing.BoxLayout)82 EmptyBorder (javax.swing.border.EmptyBorder)72