Example usage for javax.swing AbstractAction AbstractAction

List of usage examples for javax.swing AbstractAction AbstractAction

Introduction

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

Prototype

public AbstractAction() 

Source Link

Document

Creates an Action .

Usage

From source file:org.jivesoftware.sparkimpl.plugin.viewer.PluginViewer.java

public void initialize() {
    // Add Plugins Menu
    JMenuBar menuBar = SparkManager.getMainWindow().getJMenuBar();

    // Get last menu which is help
    JMenu sparkMenu = menuBar.getMenu(0);

    JMenuItem viewPluginsMenu = new JMenuItem();

    Action viewAction = new AbstractAction() {
        private static final long serialVersionUID = 6518407602062984752L;

        public void actionPerformed(ActionEvent e) {
            invokeViewer();/*  w  w  w .  j ava 2  s.  com*/
        }
    };

    viewAction.putValue(Action.NAME, Res.getString("menuitem.plugins"));
    viewAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.PLUGIN_IMAGE));
    viewPluginsMenu.setAction(viewAction);

    sparkMenu.insert(viewPluginsMenu, 2);
}

From source file:de.tor.tribes.ui.views.DSWorkbenchDoItYourselfAttackPlaner.java

/**
 * Creates new form DSWorkbenchDoItYourselflAttackPlaner
 *//*www .ja  va 2 s.c  o m*/
DSWorkbenchDoItYourselfAttackPlaner() {
    initComponents();

    jAttackTable.setModel(new DoItYourselfAttackTableModel());
    jAttackTable.getSelectionModel().addListSelectionListener(DSWorkbenchDoItYourselfAttackPlaner.this);

    jArriveTime.setDate(Calendar.getInstance().getTime());
    jNewArriveSpinner.setDate(Calendar.getInstance().getTime());
    capabilityInfoPanel1.addActionListener(this);
    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //no find
        }
    });

    DoItYourselfCountdownThread thread = new DoItYourselfCountdownThread();
    thread.start();

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.manual_attack_planer",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
    pack();
}

From source file:org.piraso.ui.base.ContextMonitorTopComponent.java

private void initKeyboardActions() {
    Action findAction = new AbstractAction() {
        @Override/*from www  .ja v  a  2  s.c o m*/
        public void actionPerformed(ActionEvent e) {
            searcher.reset();
            btnSearch.setSelected(!btnSearch.isSelected());
            btnSearchActionPerformed(e);
        }
    };

    Action nextAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnNextActionPerformed(e);
        }
    };

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.META_MASK);
    registerKeyboardAction(findAction, stroke, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    txtSearch.registerKeyboardAction(findAction, stroke, JComponent.WHEN_FOCUSED);

    stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    txtSearch.registerKeyboardAction(nextAction, stroke, JComponent.WHEN_FOCUSED);
}

From source file:de.codesourcery.eve.skills.ui.components.impl.planning.CostStatementComponent.java

@Override
protected JPanel createPanel() {
    final JPanel result = new JPanel();

    new SpreadSheetCellRenderer().attachTo(table);

    table.setFillsViewportHeight(true);/*from w  w w. java2 s. com*/
    table.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    final VerticalGroup vGroup = new VerticalGroup(new Cell(new JScrollPane(table)));

    new GridLayoutBuilder().add(vGroup).addTo(result);

    final PopupMenuBuilder builder = new PopupMenuBuilder();

    builder.addItem("Calculate required ore amounts", new AbstractAction() {

        private List<ItemWithQuantity> items;

        @Override
        public void actionPerformed(ActionEvent e) {
            calculateRequiredOres(items);
        }

        @Override
        public boolean isEnabled() {
            if (jobRequest != null && statement != null && table.getModel().getRowCount() > 0) {
                items = getAllMineralsFromCostStatement();
                return !items.isEmpty();
            }
            return false;
        }
    });

    builder.addItem("Create shopping list...", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            createNewShoppingList();
        }

    });

    builder.addItem("Put on clipboard (text)", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            putOnClipboard();
        }
    });

    builder.addItem("Show resource status", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ManufacturingJobRequest request = jobRequest.getManufacturingJobRequest();

            final ResourceStatusComponent comp = new ResourceStatusComponent("Production of "
                    + request.getQuantity() + " x " + request.getBlueprint().getProductType().getName());

            comp.setData(request.getCharacter(), getRequiredMaterialsFromCostStatement());

            comp.setModal(true);
            ComponentWrapper.wrapComponent("Resource status", comp).setVisible(true);
        }
    });

    builder.attach(table);

    refresh();
    return result;
}

From source file:be.nbb.demetra.dfm.DfmExecViewTopComponent.java

@Override
protected void onDfmStateChange() {
    switch (controller.getDfmState()) {
    case CANCELLED:
        appendText("\nCANCELLED");
        progressHandle.finish();/*  w ww. j  av  a  2 s.  c om*/
        break;
    case DONE:
        appendText("\nDONE");
        if (progressHandle != null) {
            progressHandle.finish();
        }
        break;
    case FAILED:
        appendText("\nFAILED");
        if (progressHandle != null) {
            progressHandle.finish();
        }
        break;
    case READY:
        jEditorPane1.setText("");
        break;
    case STARTED:
        swingWorker = new SwingWorkerImpl();
        progressHandle = ProgressHandleFactory.createHandle(getName(), new Cancellable() {
            @Override
            public boolean cancel() {
                swingWorker.cancel(false);
                return true;
            }
        }, new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                DfmExecViewTopComponent.this.open();
                DfmExecViewTopComponent.this.requestActive();
            }
        });
        progressHandle.start();
        swingWorker.execute();
        break;
    case CANCELLING:
        swingWorker.cancel(false);
        break;
    }
    super.onDfmStateChange();
}

From source file:org.kse.gui.crypto.DUpgradeCryptoStrength.java

private void initComponents() {

    jlUpgradeInstructions = new JLabel(res.getString("DUpgradeCryptoStrength.jlUpgradeInstructions.text"));
    jlDownloadPolicyInstructions = new JLabel(
            res.getString("DUpgradeCryptoStrength.jlDownloadPolicyInstructions.text"));
    jbDownloadPolicy = new JButton(res.getString("DUpgradeCryptoStrength.jbDownloadPolicy.text"));
    PlatformUtil.setMnemonic(jbDownloadPolicy,
            res.getString("DUpgradeCryptoStrength.jbDownloadPolicy.mnemonic").charAt(0));

    jlDropPolicyInstructions = new JLabel(
            res.getString("DUpgradeCryptoStrength.jlDropPolicyInstructions.text"));
    policyZipDropTarget = new PolicyZipDropTarget();
    jbBrowsePolicy = new JButton(res.getString("DUpgradeCryptoStrength.jbBrowsePolicy.text"));
    PlatformUtil.setMnemonic(jbBrowsePolicy,
            res.getString("DUpgradeCryptoStrength.jbBrowsePolicy.mnemonic").charAt(0));

    jbUpgrade = new JButton(res.getString("DUpgradeCryptoStrength.jbUpgrade.text"));
    PlatformUtil.setMnemonic(jbUpgrade, res.getString("DUpgradeCryptoStrength.jbUpgrade.mnemonic").charAt(0));
    jbUpgrade.setEnabled(false);/*  w ww  .java2 s  .c  o  m*/

    jbCancel = new JButton(res.getString("DUpgradeCryptoStrength.jbCancel.text"));
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);

    jpButtons = PlatformUtil.createDialogButtonPanel(jbUpgrade, jbCancel);

    // layout
    Container pane = getContentPane();
    pane.setLayout(new MigLayout("insets dialog, fill", "", "[]para[]"));
    pane.add(jlUpgradeInstructions, "wrap");
    pane.add(jlDownloadPolicyInstructions, "wrap");
    pane.add(jbDownloadPolicy, "wrap");
    pane.add(jlDropPolicyInstructions, "split");
    pane.add(policyZipDropTarget, "gap para, pad para, wrap");
    pane.add(jbBrowsePolicy, "wrap");
    pane.add(new JSeparator(), "spanx, growx, wrap para");
    pane.add(jpButtons, "right, spanx");

    // actions
    jbDownloadPolicy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DUpgradeCryptoStrength.this);
                downloadPolicyPressed();
            } finally {
                CursorUtil.setCursorFree(DUpgradeCryptoStrength.this);
            }
        }
    });
    jbUpgrade.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            upgradePressed();
        }
    });
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbBrowsePolicy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DUpgradeCryptoStrength.this);
                browsePolicyPressed();
            } finally {
                CursorUtil.setCursorFree(DUpgradeCryptoStrength.this);
            }
        }
    });
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setResizable(false);

    getRootPane().setDefaultButton(jbUpgrade);

    pack();
}

From source file:org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement.java

public SaisieVenteFactureSQLElement() {
    super(TABLENAME, "une facture", "factures");

    GlobalMapper.getInstance().map(VenteFactureSituationSQLComponent.ID, new PartialInvoiceEditGroup());
    addComponentFactory(VenteFactureSituationSQLComponent.ID,
            new ITransformer<Tuple2<SQLElement, String>, SQLComponent>() {

                @Override/* w w w.j  a va 2 s .co  m*/
                public SQLComponent transformChecked(Tuple2<SQLElement, String> input) {

                    return new VenteFactureSituationSQLComponent(SaisieVenteFactureSQLElement.this);
                }
            });
    GlobalMapper.getInstance().map(VenteFactureSoldeSQLComponent.ID, new VenteFactureSoldeEditGroup());
    addComponentFactory(VenteFactureSoldeSQLComponent.ID,
            new ITransformer<Tuple2<SQLElement, String>, SQLComponent>() {

                @Override
                public SQLComponent transformChecked(Tuple2<SQLElement, String> input) {

                    return new VenteFactureSoldeSQLComponent(SaisieVenteFactureSQLElement.this);
                }
            });

    final boolean affact = UserManager.getInstance().getCurrentUser().getRights()
            .haveRight(NXRights.ACCES_RETOUR_AFFACTURAGE.getCode());
    List<RowAction> l = new ArrayList<RowAction>(5);
    PredicateRowAction actionBL = new PredicateRowAction(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            TransfertBaseSQLComponent.openTransfertFrame(IListe.get(e).copySelectedRows(), "BON_DE_LIVRAISON");
        }
    }, false, "sales.invoice.create.delivery");
    actionBL.setPredicate(IListeEvent.getSingleSelectionPredicate());
    l.add(actionBL);
    PredicateRowAction actionAvoir = new PredicateRowAction(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            TransfertBaseSQLComponent.openTransfertFrame(IListe.get(e).copySelectedRows(), "AVOIR_CLIENT");
        }
    }, false, "sales.invoice.create.credit");
    actionAvoir.setPredicate(IListeEvent.getSingleSelectionPredicate());
    l.add(actionAvoir);
    RowAction actionClone = new RowAction(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {

            SQLElement eltFact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
            EditFrame editFrame = new EditFrame(eltFact, EditPanel.CREATION);

            ((SaisieVenteFactureSQLComponent) editFrame.getSQLComponent())
                    .loadFactureExistante(IListe.get(e).getSelectedId());
            editFrame.setVisible(true);
        }
    }, false, "sales.invoice.clone") {
        public boolean enabledFor(IListeEvent evt) {
            List<SQLRowAccessor> l = evt.getSelectedRows();
            if (l != null && l.size() == 1) {
                SQLRowAccessor r = l.get(0);
                return !r.getBoolean("PARTIAL") && !r.getBoolean("SOLDE");
            }
            return false;
        }
    };

    l.add(actionClone);
    getRowActions().addAll(l);

    PredicateRowAction actionClient = new PredicateRowAction(new AbstractAction("Dtails client") {
        EditFrame edit;
        private SQLElement eltClient = Configuration.getInstance().getDirectory().getElement(
                ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CLIENT"));

        public void actionPerformed(ActionEvent e) {
            if (edit == null) {
                edit = new EditFrame(eltClient, EditMode.READONLY);
            }
            edit.selectionId(IListe.get(e).fetchSelectedRow().getInt("ID_CLIENT"));
            edit.setVisible(true);
        }
    }, false, "sales.invoice.info.show");
    actionClient.setPredicate(IListeEvent.getSingleSelectionPredicate());
    getRowActions().add(actionClient);

    PredicateRowAction actionCommande = new PredicateRowAction(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            SaisieVenteFactureSQLElement elt = (SaisieVenteFactureSQLElement) Configuration.getInstance()
                    .getDirectory().getElement("SAISIE_VENTE_FACTURE");
            elt.transfertCommande(IListe.get(e).getSelectedId());
        }
    }, false, "sales.invoice.create.supplier.order");
    actionCommande.setPredicate(IListeEvent.getSingleSelectionPredicate());
    getRowActions().add(actionCommande);

    MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(
            VenteFactureXmlSheet.class);
    getRowActions().addAll(mouseSheetXmlListeListener.getRowActions());
    // this.frame.getPanel().getListe().addRowActions(mouseListener.getRowActions());

}

From source file:de.tor.tribes.ui.views.DSWorkbenchReTimerFrame.java

/** Creates new form DSWorkbenchReTimerFrame */
DSWorkbenchReTimerFrame() {/* w w  w .j  a  v  a 2s . co m*/
    initComponents();

    centerPanel = new GenericTestPanel(true);
    jReTimePanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jideRetimeTabbedPane);
    jideRetimeTabbedPane.setTabShape(JideTabbedPane.SHAPE_OFFICE2003);
    jideRetimeTabbedPane.setTabColorProvider(JideTabbedPane.ONENOTE_COLOR_PROVIDER);
    jideRetimeTabbedPane.setBoldActiveTab(true);
    jideRetimeTabbedPane.addTab("Festlegen des Angriffs", jInputPanel);
    jideRetimeTabbedPane.addTab("Errechnete Gegenangriffe", jResultPanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);
    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    jResultTable.registerKeyboardAction(DSWorkbenchReTimerFrame.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultTable.registerKeyboardAction(DSWorkbenchReTimerFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultTable.registerKeyboardAction(DSWorkbenchReTimerFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultTable.registerKeyboardAction(DSWorkbenchReTimerFrame.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });
    jCommandArea.setPrompt("<Angriffsbefehl hier einfgen>");
    jResultTable.getSelectionModel().addListSelectionListener(DSWorkbenchReTimerFrame.this);
    jPossibleUnits.setCellRenderer(new UnitListCellRenderer());
    jPossibleUnits.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                updateAttackBBView();
            }
        }
    });

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.retime_tool",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
}

From source file:org.angnysa.yaba.swing.BudgetFrame.java

private void buildReconciliationTable() {
    reconciliationModel = new ReconciliationTableModel(service);
    reconciliationTable = new JTable(reconciliationModel);
    reconciliationTable.setRowHeight((int) (reconciliationTable.getRowHeight() * 1.2));
    reconciliationTable.setDefaultEditor(LocalDate.class,
            new CustomCellEditor(new JFormattedTextField(new JodaLocalDateFormat())));
    reconciliationTable.setDefaultEditor(Double.class,
            new CustomCellEditor(new JFormattedTextField(NumberFormat.getNumberInstance())));
    reconciliationTable.setDefaultRenderer(LocalDate.class,
            new FormattedTableCellRenderer(new JodaLocalDateFormat()));
    reconciliationTable.setDefaultRenderer(Double.class,
            new FormattedTableCellRenderer(TransactionAmountFormatFactory.getFormat()));
    reconciliationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    reconciliationTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); //$NON-NLS-1$
    reconciliationTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete"); //$NON-NLS-1$
    reconciliationTable.getActionMap().put("delete", new AbstractAction() { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override//from  w  ww  .java  2 s .c  o m
        public void actionPerformed(ActionEvent e) {

            int row = reconciliationTable.getSelectedRow();
            if (row >= 0) {
                reconciliationModel.deleteRow(row);
            }
        }
    });
    transactionTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int row = transactionTable.getSelectedRow();
                if (row >= 0) {
                    row = transactionTable.getRowSorter().convertRowIndexToModel(row);
                    TransactionDefinition td = transactionModel.getTransactionForRow(row);
                    if (td != null) {
                        reconciliationModel.setCurrentTransactionId(td.getId());
                    } else {
                        reconciliationModel.setCurrentTransactionId(-1);
                    }
                } else {
                    reconciliationModel.setCurrentTransactionId(-1);
                }
            }
        }
    });
}

From source file:org.cds06.speleograph.graph.GraphEditor.java

/**
 * Creates a modal dialog by specifying the attached {@link GraphPanel}.
 * <p>Please look at {@link javax.swing.JDialog#JDialog()} to see defaults params applied to this Dialog.</p>
 *//*from w w  w .j a v  a  2 s.  c o  m*/
public GraphEditor(GraphPanel panel) {
    super((Frame) SwingUtilities.windowForComponent(panel), true);
    Validate.notNull(panel);
    this.graphPanel = panel;

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    mainPanel.registerKeyboardAction(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    setContentPane(mainPanel);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    this.setTitle(I18nSupport.translate("menus.graph.graphEditor"));

    {
        // This section use FormLayout which is an external layout for Java, consult the doc before edit the
        // following lines !
        final FormLayout layout = new FormLayout(
                "right:max(40dlu;p), 4dlu, p:grow, 4dlu, p, 4dlu, p:grow, 4dlu, p", //NON-NLS
                "p,4dlu,p,4dlu,p,4dlu,p,4dlu,p" //NON-NLS
        );

        PanelBuilder builder = new PanelBuilder(layout);

        final JLabel colorLabel = new JLabel();
        final JTextField titleForGraph = new JTextField(
                graphPanel.getChart().getTitle() != null ? graphPanel.getChart().getTitle().getText() : "");
        final JLabel colorXYPlotLabel = new JLabel();
        final JLabel colorGridLabel = new JLabel();
        final JCheckBox showLegendCheckBox = new JCheckBox("Afficher la lgende",
                graphPanel.getChart().getLegend().isVisible());

        {
            builder.addLabel("Titre :", "1,1");
            builder.add(titleForGraph, "3,1,7,1");
        }

        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.backgroundColor"), "1,3");
            colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorLabel.setText(" ");
            colorLabel.setBackground((Color) graphPanel.getChart().getBackgroundPaint());
            colorLabel.setOpaque(true);
            colorLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorLabel.getBackground());
                    if (c != null) {
                        colorLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorLabel, "3,3,5,1");
            builder.add(edit, "9,3");
        }

        final XYPlot xyPlot = graphPanel.getChart().getXYPlot();
        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.graphColor"), "1,5");
            colorXYPlotLabel.setText(" ");
            colorXYPlotLabel.setOpaque(true);
            colorXYPlotLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorXYPlotLabel.setBackground((Color) xyPlot.getBackgroundPaint());
            colorXYPlotLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorXYPlotLabel.getBackground());
                    if (c != null) {
                        colorXYPlotLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorXYPlotLabel, "3,5,5,1");
            builder.add(edit, "9,5");
        }

        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.gridColor"), "1,7");
            colorGridLabel.setOpaque(true);
            colorGridLabel.setText(" ");
            colorGridLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorGridLabel.setBackground((Color) xyPlot.getRangeGridlinePaint());
            colorGridLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorGridLabel.getBackground());
                    if (c != null) {
                        colorGridLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorGridLabel, "3,7,5,1");
            builder.add(edit, "9,7");
        }

        {
            builder.add(showLegendCheckBox, "1,9,9,1");
        }

        mainPanel.add(builder.build(), BorderLayout.CENTER);

        ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder();

        buttonBarBuilder.addGlue();

        buttonBarBuilder.addButton(new AbstractAction() {
            {
                putValue(NAME, I18nSupport.translate("cancel"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                GraphEditor.this.setVisible(false);
            }
        });

        buttonBarBuilder.addButton(new AbstractAction() {

            {
                putValue(NAME, I18nSupport.translate("ok"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                if (titleForGraph.getText().isEmpty())
                    graphPanel.getChart().setTitle((String) null);
                else
                    graphPanel.getChart().setTitle(titleForGraph.getText());
                {
                    Color c = colorGridLabel.getBackground();
                    xyPlot.setRangeGridlinePaint(c);
                    xyPlot.setRangeMinorGridlinePaint(c);
                    xyPlot.setDomainGridlinePaint(c);
                    xyPlot.setDomainMinorGridlinePaint(c);
                }
                graphPanel.getChart().setBackgroundPaint(colorLabel.getBackground());
                xyPlot.setBackgroundPaint(colorXYPlotLabel.getBackground());
                graphPanel.getChart().getLegend().setVisible(showLegendCheckBox.isSelected());
                GraphEditor.this.setVisible(false);
            }
        });

        mainPanel.add(buttonBarBuilder.build(), BorderLayout.SOUTH);
    }

    pack();
    Dimension d = this.getPreferredSize();
    this.setSize(new Dimension(d.width + 20, d.height));
    setResizable(false);
}