class PalettePopupButton extends JXHyperlink {

        private final PaletteManager paletteManager;

        public PalettePopupButton() {
            setText(NbBundle
                .getMessage(PartitionColorTransformerPanel.class, "PartitionColorTransformerPanel.paletteButton"));
            setFocusPainted(false);
            setFocusable(false);
            paletteManager = PaletteManager.getInstance();

            addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    int size = function.getPartition().size(function.getGraph());
                    JPopupMenu menu = createPopup(size);
                    menu.show(PalettePopupButton.this, 0, getHeight());
                }
            });
        }

        private JPopupMenu createPopup(final int colorsCount) {<FILL_FUNCTION_BODY>}
    }

            JPopupMenu menu = new JPopupMenu();
            menu.add(new JXTitledSeparator(
                NbBundle.getMessage(PartitionColorTransformerPanel.class, "PalettePopup.recent")));
            Collection<Palette> recentPalettes = paletteManager.getRecentPalettes();
            if (recentPalettes.isEmpty()) {
                menu.add(
                    "<html><i>" + NbBundle.getMessage(PartitionColorTransformerPanel.class, "PalettePopup.norecent") +
                        "</i></html>");
            } else {
                for (Palette pl : recentPalettes) {
                    if (pl.size() >= colorsCount) {
                        menu.add(new PaletteMenuItem(pl, Math.min(PALETTE_DISPLAY_LIMIT, colorsCount)));
                    }
                }
            }

            menu.add(new JXTitledSeparator(
                NbBundle.getMessage(PartitionColorTransformerPanel.class, "PalettePopup.standard")));
            JMenu lightPalette =
                new JMenu(NbBundle.getMessage(PartitionColorTransformerPanel.class, "PalettePopup.palette"));
            for (Palette pl : paletteManager.getDefaultPalette(colorsCount)) {
                lightPalette.add(new PaletteMenuItem(pl, Math.min(PALETTE_DISPLAY_LIMIT, colorsCount)));
            }
            menu.add(lightPalette);

            JMenuItem allGrey =
                new JMenuItem(NbBundle.getMessage(PartitionColorTransformerPanel.class, "PalettePopup.allgrey"));
            allGrey.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    applyColor(Color.LIGHT_GRAY);
                }
            });
            menu.add(allGrey);

            JMenuItem allWhite =
                new JMenuItem(NbBundle.getMessage(PartitionColorTransformerPanel.class, "PalettePopup.allwhite"));
            allWhite.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    applyColor(Color.WHITE);
                }
            });
            menu.add(allWhite);

            JMenuItem generate =
                new JMenuItem(NbBundle.getMessage(PartitionColorTransformerPanel.class, "PalettePopup.generate"));
            generate.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    PaletteGeneratorPanel pgn = new PaletteGeneratorPanel();
                    pgn.setup(colorsCount);
                    NotifyDescriptor nd = new NotifyDescriptor(pgn,
                        NbBundle.getMessage(PartitionColorTransformerPanel.class,
                            "PartitionColorTransformerPanel.generatePalettePanel.title"),
                        NotifyDescriptor.OK_CANCEL_OPTION,
                        NotifyDescriptor.DEFAULT_OPTION, null, null);

                    if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) {
                        Palette pl = pgn.getSelectedPalette();
                        if (pl != null) {
                            applyPalette(pl);
                        }
                    }
                }
            });
            menu.add(generate);

            return menu;
        
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID