Example usage for javax.swing.event ChangeListener ChangeListener

List of usage examples for javax.swing.event ChangeListener ChangeListener

Introduction

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

Prototype

ChangeListener

Source Link

Usage

From source file:au.edu.uwa.csse.plot.Clustering.java

private void setUpView(Graph graph) throws IOException {

    //Create a simple layout frame
    //specify the Fruchterman-Rheingold layout algorithm
    final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>(
            new FRLayout<Integer, Number>(graph));

    vv = new VisualizationViewer<Integer, Number>(layout);
    vv.setBackground(Color.white);
    vv.setVertexToolTipTransformer(Plot.vertexLabelTransformer);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()// ww w .ja v a  2s. c o m
            .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() {
        public Paint transform(Integer v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.cyan;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY)
                return THIN;
            else
                return THICK;
        }
    });

    //add restart button
    JButton scramble = new JButton("Restart");
    scramble.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Layout layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }

    });

    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    //Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(graph.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    //      edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):"));
    //I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    eastControls.setOpaque(true);
    eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS));
    eastControls.add(Box.createVerticalGlue());
    eastControls.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    eastControls.setBorder(sliderBorder);
    //eastControls.add(eastSize);
    eastControls.add(Box.createVerticalGlue());

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    grid.add(scramble);
    grid.add(groupVertices);
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    p.add(gm.getModeComboBox());
    south.add(p);
    content.add(south, BorderLayout.SOUTH);
}

From source file:edu.ku.brc.specify.ui.LoanReturnDlg.java

/**
 * @return//from  w w  w  .  j  a  v a2s .c o  m
 */
public boolean createUI() {
    DataProviderSessionIFace session = null;
    try {
        session = DataProviderFactory.getInstance().createSession();

        loan = session.merge(loan);

        setTitle(getResourceString("LOANRET_TITLE"));

        validator.addValidationListener(new ValidationListener() {
            public void wasValidated(UIValidator val) {
                doEnableOKBtn();
            }
        });

        JPanel contentPanel = new JPanel(new BorderLayout());

        JPanel mainPanel = new JPanel();

        System.out.println("Num Loan Preps for Loan: " + loan.getLoanPreparations());

        HashMap<Integer, Pair<CollectionObject, Vector<LoanPreparation>>> colObjHash = new HashMap<Integer, Pair<CollectionObject, Vector<LoanPreparation>>>();
        for (LoanPreparation loanPrep : loan.getLoanPreparations()) {
            CollectionObject colObj = loanPrep.getPreparation().getCollectionObject();
            System.out.println("For LoanPrep ColObj Is: " + colObj.getIdentityTitle());

            Vector<LoanPreparation> list = null;
            Pair<CollectionObject, Vector<LoanPreparation>> pair = colObjHash.get(colObj.getId());
            if (pair == null) {
                list = new Vector<LoanPreparation>();
                colObjHash.put(colObj.getId(),
                        new Pair<CollectionObject, Vector<LoanPreparation>>(colObj, list));
            } else {
                list = pair.second;

            }
            list.add(loanPrep);
        }

        int colObjCnt = colObjHash.size();
        String rowDef = UIHelper.createDuplicateJGoodiesDef("p", "1px,p,4px", (colObjCnt * 2) - 1);
        PanelBuilder pbuilder = new PanelBuilder(new FormLayout("f:p:g", rowDef), mainPanel);
        CellConstraints cc = new CellConstraints();

        ActionListener al = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doEnableOKBtn();
            }
        };

        ChangeListener cl = new ChangeListener() {
            public void stateChanged(ChangeEvent ae) {
                doEnableOKBtn();
            }
        };

        int i = 0;
        int y = 1;

        Vector<Pair<CollectionObject, Vector<LoanPreparation>>> pairList = new Vector<Pair<CollectionObject, Vector<LoanPreparation>>>(
                colObjHash.values());

        Collections.sort(pairList, new Comparator<Pair<CollectionObject, Vector<LoanPreparation>>>() {
            @Override
            public int compare(Pair<CollectionObject, Vector<LoanPreparation>> o1,
                    Pair<CollectionObject, Vector<LoanPreparation>> o2) {
                return o1.first.getIdentityTitle().compareTo(o2.first.getIdentityTitle());
            }
        });

        for (Pair<CollectionObject, Vector<LoanPreparation>> pair : pairList) {
            CollectionObject co = pair.first;

            if (i > 0) {
                pbuilder.addSeparator("", cc.xy(1, y));
                y += 2;
            }

            ColObjPanel panel = new ColObjPanel(session, this, co, colObjHash.get(co.getId()).second);
            colObjPanels.add(panel);
            panel.addActionListener(al, cl);
            pbuilder.add(panel, cc.xy(1, y));
            y += 2;
            i++;
        }

        JButton selectAllBtn = createButton(getResourceString("SELECTALL"));
        okBtn = createButton(getResourceString("SAVE"));
        JButton cancel = createButton(getResourceString("CANCEL"));

        PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,2px,p,2px,p,2px,p,2px,p", "p"));

        dateClosed = new ValFormattedTextFieldSingle("Date", false, false, 10);
        dateClosed.setNew(true);
        dateClosed.setValue(null, "");
        dateClosed.setRequired(true);
        validator.hookupTextField(dateClosed, "2", true, UIValidator.Type.Changed, "", false);
        summaryLabel = createLabel("");
        pb.add(summaryLabel, cc.xy(1, 1));
        pb.add(createI18NLabel("LOANRET_AGENT"), cc.xy(3, 1));
        pb.add(agentCBX = createAgentCombobox(), cc.xy(5, 1));
        pb.add(createI18NLabel("ON"), cc.xy(7, 1));
        pb.add(dateClosed, cc.xy(9, 1));

        contentPanel.add(pb.getPanel(), BorderLayout.NORTH);
        contentPanel.add(new JScrollPane(mainPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));

        JPanel p = new JPanel(new BorderLayout());
        p.setBorder(BorderFactory.createEmptyBorder(5, 0, 2, 0));
        p.add(ButtonBarFactory.buildOKCancelApplyBar(okBtn, cancel, selectAllBtn), BorderLayout.CENTER);
        contentPanel.add(p, BorderLayout.SOUTH);
        contentPanel.setBorder(BorderFactory.createEmptyBorder(4, 12, 2, 12));

        setContentPane(contentPanel);

        doEnableOKBtn();

        //setIconImage(IconManager.getIcon("Preparation", IconManager.IconSize.Std16).getImage());
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        doEnableOKBtn();

        okBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                setVisible(false);
                isCancelled = false;
            }
        });

        cancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                setVisible(false);
            }
        });

        selectAllBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                selectAllItems();
            }
        });

        pack();

        Dimension size = getPreferredSize();
        size.width += 20;
        size.height = size.height > 500 ? 500 : size.height;
        setSize(size);

        return true;

    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LoanReturnDlg.class, ex);
        // Error Dialog
        ex.printStackTrace();

    } finally {
        if (session != null) {
            session.close();
        }
    }
    return false;
}

From source file:EdgeLabelDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the label positioning features/* ww w.  ja  va2s .  c  o  m*/
 * 
 */
@SuppressWarnings("serial")
public EdgeLabelDemo() {

    // create a simple graph for the demo
    graph = new SparseMultigraph<Integer, Number>();
    Integer[] v = createVertices(3);
    createEdges(v);

    Layout<Integer, Number> layout = new CircleLayout<Integer, Number>(graph);
    vv = new VisualizationViewer<Integer, Number>(layout, new Dimension(600, 400));
    vv.setBackground(Color.white);

    vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer();
    edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer();

    Transformer<Number, String> stringer = new Transformer<Number, String>() {
        public String transform(Number e) {
            return "Edge:" + graph.getEndpoints(e).toString();
        }
    };
    vv.getRenderContext().setEdgeLabelTransformer(stringer);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));
    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow));
    // add my listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>());

    // create a frome to hold the graph
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    Container content = getContentPane();
    content.add(panel);

    final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(graphMouse);

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    ButtonGroup radio = new ButtonGroup();
    JRadioButton lineButton = new JRadioButton("Line");
    lineButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>());
                vv.repaint();
            }
        }
    });

    JRadioButton quadButton = new JRadioButton("QuadCurve");
    quadButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, Number>());
                vv.repaint();
            }
        }
    });

    JRadioButton cubicButton = new JRadioButton("CubicCurve");
    cubicButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, Number>());
                vv.repaint();
            }
        }
    });
    radio.add(lineButton);
    radio.add(quadButton);
    radio.add(cubicButton);

    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    JCheckBox rotate = new JCheckBox("<html><center>EdgeType<p>Parallel</center></html>");
    rotate.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            AbstractButton b = (AbstractButton) e.getSource();
            edgeLabelRenderer.setRotateEdgeLabels(b.isSelected());
            vv.repaint();
        }
    });
    rotate.setSelected(true);
    MutableDirectionalEdgeValue mv = new MutableDirectionalEdgeValue(.5, .7);
    vv.getRenderContext().setEdgeLabelClosenessTransformer(mv);
    JSlider directedSlider = new JSlider(mv.getDirectedModel()) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };
    JSlider undirectedSlider = new JSlider(mv.getUndirectedModel()) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };

    JSlider edgeOffsetSlider = new JSlider(0, 50) {
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width /= 2;
            return d;
        }
    };
    edgeOffsetSlider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            JSlider s = (JSlider) e.getSource();
            AbstractEdgeShapeTransformer<Integer, Number> aesf = (AbstractEdgeShapeTransformer<Integer, Number>) vv
                    .getRenderContext().getEdgeShapeTransformer();
            aesf.setControlOffsetIncrement(s.getValue());
            vv.repaint();
        }

    });

    Box controls = Box.createHorizontalBox();

    JPanel zoomPanel = new JPanel(new GridLayout(0, 1));
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Scale"));
    zoomPanel.add(plus);
    zoomPanel.add(minus);

    JPanel edgePanel = new JPanel(new GridLayout(0, 1));
    edgePanel.setBorder(BorderFactory.createTitledBorder("EdgeType Type"));
    edgePanel.add(lineButton);
    edgePanel.add(quadButton);
    edgePanel.add(cubicButton);

    JPanel rotatePanel = new JPanel();
    rotatePanel.setBorder(BorderFactory.createTitledBorder("Alignment"));
    rotatePanel.add(rotate);

    JPanel labelPanel = new JPanel(new BorderLayout());
    JPanel sliderPanel = new JPanel(new GridLayout(3, 1));
    JPanel sliderLabelPanel = new JPanel(new GridLayout(3, 1));
    JPanel offsetPanel = new JPanel(new BorderLayout());
    offsetPanel.setBorder(BorderFactory.createTitledBorder("Offset"));
    sliderPanel.add(directedSlider);
    sliderPanel.add(undirectedSlider);
    sliderPanel.add(edgeOffsetSlider);
    sliderLabelPanel.add(new JLabel("Directed", JLabel.RIGHT));
    sliderLabelPanel.add(new JLabel("Undirected", JLabel.RIGHT));
    sliderLabelPanel.add(new JLabel("Edges", JLabel.RIGHT));
    offsetPanel.add(sliderLabelPanel, BorderLayout.WEST);
    offsetPanel.add(sliderPanel);
    labelPanel.add(offsetPanel);
    labelPanel.add(rotatePanel, BorderLayout.WEST);

    JPanel modePanel = new JPanel(new GridLayout(2, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(graphMouse.getModeComboBox());

    controls.add(zoomPanel);
    controls.add(edgePanel);
    controls.add(labelPanel);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
    quadButton.setSelected(true);
}

From source file:brainleg.app.intellij.ui.EForm.java

public EForm(final EData exception, final ContentManager contentManager, long creationTime,
        BLProjectComponent projectComponent) {
    this.projectComponent = projectComponent;
    this.exception = exception;
    exceptionHash = Calculator.calcNoLineMD5ForTracesRecursively(exception);
    numOccurrences = 1;//from  w w  w  .  java2  s . c  o  m
    firstTime = creationTime;
    this.contentManager = contentManager;

    ignoreFromNowOnButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("ignoreFromNowOnButton: " + exception);
            String hash = Calculator.calcNoLineMD5ForTracesRecursively(exception);
            BLSettingsService.getSettings().ignoreFullTracesNoLinesMD5s.add(hash);
            contentManager.removeContent(content, true);
        }
    });
    ignoreFromNowOnButton.setIcon(AllIcons.Actions.Delete);

    feedbackLinkLabel.setHyperlinkTarget("mailto:support@brainleg.com?subject=BrainLeg%20Feedback");
    feedbackLinkLabel.setHyperlinkText("Ideas or suggestions? ", "Let us know", "");

    try {
        BufferedImage logoImage = ImageIO.read(
                AppWeb.class.getResourceAsStream(BLUIUtil.getLightOrDarkResourceName("/brainleg-logo.png")));
        logoLabel.setIcon(new ImageIcon(logoImage));
        logoLabel.setHyperlinkTarget("http://brainleg.com");
        logoLabel.setUseIconAsLink(true);
    } catch (IOException e) {
        e.printStackTrace(System.out);
    }

    manualSearchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (BLSettingsService.getSettings().forManualSearchShowResultsInIdea) {
                //make search in another thread so as not to stall processing of ui events
                BLProjectComponent.executor.execute(new Runnable() {
                    public void run() {
                        sendRequestToServerAndRenderInIDEA(exception, false, false); //don't show notification if invoked from here - the user is already in BL tab
                    }
                });
                markExceptionAsDontShowNotificationFor();
            } else {
                AppWeb.sendQueryAndOpenBrowser(exception);
                markExceptionAsDontShowNotificationFor();
            }
        }
    });
    manualSearchButton.setIcon(AllIcons.Actions.Find);

    openSearchResultsInBrowserButton.setIcon(AllIcons.Xml.Browsers.Chrome16);
    openSearchResultsInBrowserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (requestToken != null) {
                AppWeb.openSearchResultsInBrowser(requestToken);
                markExceptionAsDontShowNotificationFor();
            } else {
                //it is possible we got exception from cache, and so the request token is not known at this point (or the server might not have it).
                //in this case we just have to make a new web browser search
                AppWeb.sendQueryAndOpenBrowser(exception);
                markExceptionAsDontShowNotificationFor();
            }

        }
    });
    //        submitSolutionButton.addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                String userAuthToken = BLSettingsService.getSettings().userAuthToken;
    //                if (userAuthToken != null && !"".equals(userAuthToken)) {
    //                    SubmitSolutionDialog.askUser(exception, submitSolutionButton, submissionCountLabel);
    //                } else {
    //                    Messages.showMessageDialog(
    //                            "<html>In order to post solutions via plugin you have to register " +
    //                                    "at <a href=\"http://www.brainleg.com/register\">http://www.brainleg.com</a> (free and takes 30 sec) <br/>" +
    //                                    "and then copy your 'Plugin user token' from 'My BrainLeg' page into plugin settings</html>",
    //                            "Please configure your user token",
    //                            Messages.getInformationIcon()
    //                    );
    //                }
    //            }
    //        });
    settingsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            BLSettingsDialog.configure();
        }
    });

    showExceptionCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (exceptionViewContainer.isVisible()) {
                exceptionViewContainer.setVisible(false);
            } else {
                exceptionViewContainer.setVisible(true);
            }
        }
    });

    refreshDetailsText();
}

From source file:io.github.jeremgamer.editor.panels.components.ButtonPanel.java

public ButtonPanel(JFrame frame) {

    this.frame = frame;
    this.setSize(new Dimension(395, frame.getHeight() - 27 - 23));
    this.setLocation(300, 0);
    this.setBorder(BorderFactory.createTitledBorder("Edition du bouton"));
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    JLabel nameLabel = new JLabel("Nom : ");
    name.setPreferredSize(new Dimension(this.getWidth() - 285, 30));
    name.setEditable(false);//  www. ja va  2 s  . c om
    JPanel namePanel = new JPanel();
    namePanel.add(nameLabel);
    namePanel.add(name);
    JPanel textPanel = new JPanel();
    JPanel nameAndTextPanel = new JPanel();
    JLabel textLabel = new JLabel("Texte :");
    CaretListener caretUpdateText = new CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent e) {
            JTextField text = (JTextField) e.getSource();
            bs.set("text", text.getText());
            preview.setText(text.getText());
            preview2.setText(text.getText());
        }
    };
    text.addCaretListener(caretUpdateText);
    text.setPreferredSize(new Dimension(this.getWidth() - 283, 30));
    textPanel.add(textLabel);
    textPanel.add(text);
    nameAndTextPanel.setLayout(new BoxLayout(nameAndTextPanel, BoxLayout.PAGE_AXIS));
    nameAndTextPanel.add(namePanel);
    nameAndTextPanel.add(textPanel);

    JPanel policePanel = new JPanel();
    JLabel policeLabel = new JLabel("Police : ");
    police.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) e.getSource();
            fontStyle = (String) combo.getSelectedItem();
            preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize));
            preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize));
            bs.set("police", fontStyle);
        }

    });
    police.setPreferredSize(new Dimension(105, 30));
    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = e.getAllFonts();
    for (Font f : fonts) {
        police.addItem(f.getName());
    }
    police.setSelectedItem("Arial");
    policePanel.add(policeLabel);
    policePanel.add(police);

    JPanel sizePanel = new JPanel();
    size.setPreferredSize(new Dimension(60, 25));
    JLabel sizeLabel = new JLabel("Taille : ");
    sizePanel.add(sizeLabel);
    sizePanel.add(size);
    JButton colorButton = new JButton("Couleur");
    colorButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            colorFrame.setModal(false);
            JButton finish = new JButton("Terminer");
            finish.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    colorFrame.dispose();
                }

            });
            colorFrame.setLayout(new BorderLayout());
            colorFrame.add(color, BorderLayout.CENTER);
            colorFrame.add(finish, BorderLayout.SOUTH);
            colorFrame.pack();
            colorFrame.setLocation(SwingUtilities.windowForComponent(imagedButton).getX() + 325,
                    SwingUtilities.windowForComponent(imagedButton).getY() - colorFrame.getHeight() + 40);
            colorFrame.setVisible(true);
        }

    });
    sizePanel.add(colorButton);
    size.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            fontSize = (int) spinner.getValue();
            preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize));
            preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize));
            bs.set("size", fontSize);
        }
    });

    JPanel policeAndSize = new JPanel();
    policeAndSize.setLayout(new BoxLayout(policeAndSize, BoxLayout.PAGE_AXIS));
    policeAndSize.add(policePanel);
    policeAndSize.add(sizePanel);

    JPanel top = new JPanel();
    top.add(nameAndTextPanel);
    top.add(policeAndSize);
    top.setPreferredSize(new Dimension(395, 20));

    this.add(top);

    JPanel images = new JPanel();
    images.setBorder(BorderFactory.createTitledBorder("Images"));
    images.setLayout(new GridLayout(2, 3));
    images.setPreferredSize(new Dimension(395, this.getHeight() - 320));

    JPanel imaged = new JPanel();
    imaged.setLayout(new BorderLayout());
    imaged.setBorder(BorderFactory.createTitledBorder("Icne interne"));
    imagedButton.setSelected(true);
    imagedButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            if (ev.getStateChange() == ItemEvent.SELECTED) {
                bs.set("strings", true);
                preview.setBorderPainted(true);
            } else if (ev.getStateChange() == ItemEvent.DESELECTED) {
                bs.set("strings", false);
                preview.setBorderPainted(false);
            }
        }
    });
    JButton browseInternal = new JButton("Parcourir");
    browseInternal.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "internal.png");
                nameInternal.setText(new File(path).getName());
                nameInternal.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30));
                preview.setIcon(new ImageIcon(path));
                preview.repaint();
                bs.set("imageInternal", new File(path).getName());
            }
        }

    });
    JPanel northImaged = new JPanel();
    northImaged.setLayout(new BorderLayout());
    northImaged.add(imagedButton, BorderLayout.NORTH);
    northImaged.add(browseInternal, BorderLayout.SOUTH);
    imaged.add(northImaged, BorderLayout.NORTH);
    imaged.add(nameInternal, BorderLayout.CENTER);
    JButton removeInternal = null;
    try {
        removeInternal = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeInternal.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/internal.png");
            file.delete();
            nameInternal.setText("");
            bs.set("imageInternal", "");
            preview.setIcon(null);
        }

    });
    imaged.add(removeInternal, BorderLayout.SOUTH);
    images.add(imaged);

    imgBasic.setBorder(BorderFactory.createTitledBorder("Base"));
    JButton browseBasic = new JButton("Parcourir");
    browseBasic.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "basic.png");
                nameBasic.setText(new File(path).getName());
                nameBasic.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30));
                previewPanel.remove(preview);
                previewPanel.remove(preview2);
                previewPanel.add(preview2);
                color.changePreview(preview2);
                bs.set("imageBasic", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgBasic.setLayout(new BorderLayout());
    imgBasic.add(browseBasic, BorderLayout.NORTH);
    imgBasic.add(nameBasic, BorderLayout.CENTER);
    JButton removeBasic = null;
    try {
        removeBasic = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeBasic.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/basic.png");
            file.delete();
            nameBasic.setText("");
            bs.set("imageBasic", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgBasic.add(removeBasic, BorderLayout.SOUTH);
    images.add(imgBasic);

    imgEntered.setBorder(BorderFactory.createTitledBorder("Survol"));
    JButton browseEntered = new JButton("Parcourir");
    browseEntered.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "entered.png");
                nameEntered.setText(new File(path).getName());
                nameEntered.setPreferredSize(new Dimension(imgEntered.getWidth() - 10, 30));
                bs.set("imageEntered", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgEntered.setLayout(new BorderLayout());
    imgEntered.add(browseEntered, BorderLayout.NORTH);
    imgEntered.add(nameEntered, BorderLayout.CENTER);
    JButton removeEntered = null;
    try {
        removeEntered = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeEntered.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/entered.png");
            file.delete();
            nameEntered.setText("");
            bs.set("imageEntered", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgEntered.add(removeEntered, BorderLayout.SOUTH);
    images.add(imgEntered);

    imgExited.setBorder(BorderFactory.createTitledBorder("Sortie"));
    JButton browseExited = new JButton("Parcourir");
    browseExited.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "exited.png");
                nameExited.setText(new File(path).getName());
                nameExited.setPreferredSize(new Dimension(imgExited.getWidth() - 10, 30));
                bs.set("imageExited", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgExited.setLayout(new BorderLayout());
    imgExited.add(browseExited, BorderLayout.NORTH);
    imgExited.add(nameExited, BorderLayout.CENTER);
    JButton removeExited = null;
    try {
        removeExited = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeExited.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/exited.png");
            file.delete();
            nameExited.setText("");
            bs.set("imageExited", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgExited.add(removeExited, BorderLayout.SOUTH);
    images.add(imgExited);

    imgPressed.setBorder(BorderFactory.createTitledBorder("Clic"));
    JButton browsePressed = new JButton("Parcourir");
    browsePressed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "pressed.png");
                namePressed.setText(new File(path).getName());
                namePressed.setPreferredSize(new Dimension(imgPressed.getWidth() - 10, 30));
                bs.set("imagePressed", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgPressed.setLayout(new BorderLayout());
    imgPressed.add(browsePressed, BorderLayout.NORTH);
    imgPressed.add(namePressed, BorderLayout.CENTER);
    JButton removePressed = null;
    try {
        removePressed = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removePressed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/pressed.png");
            file.delete();
            namePressed.setText("");
            bs.set("imagePressed", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgPressed.add(removePressed, BorderLayout.SOUTH);
    images.add(imgPressed);

    imgReleased.setBorder(BorderFactory.createTitledBorder("Relachement"));
    JButton browseReleased = new JButton("Parcourir");
    browseReleased.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "released.png");
                nameReleased.setText(new File(path).getName());
                nameReleased.setPreferredSize(new Dimension(imgReleased.getWidth() - 10, 30));
                bs.set("imageReleased", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgReleased.setLayout(new BorderLayout());
    imgReleased.add(browseReleased, BorderLayout.NORTH);
    imgReleased.add(nameReleased, BorderLayout.CENTER);
    JButton removeReleased = null;
    try {
        removeReleased = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeReleased.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/released.png");
            file.delete();
            nameReleased.setText("");
            bs.set("imageReleased", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgReleased.add(removeReleased, BorderLayout.SOUTH);
    images.add(imgReleased);

    this.add(images);

    JPanel action = new JPanel();
    action.setPreferredSize(new Dimension(395, -20));
    JLabel labelAction = new JLabel("Action : ");
    action.add(labelAction);
    actionList.removeAllItems();
    actionList.addItem("Aucune");
    for (String s : Actions.getActions()) {
        actionList.addItem(s);
    }
    actionList.setPreferredSize(new Dimension(this.getWidth() - 100, 30));
    actionList.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            bs.set("action", combo.getSelectedItem());
        }

    });
    action.add(actionList);
    this.add(action);

    JScrollPane previewScroll = new JScrollPane(previewPanel);
    previewScroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    previewPanel.setBorder(BorderFactory.createTitledBorder("Aperu"));
    previewPanel.add(preview);
    previewScroll.setPreferredSize(new Dimension(395, 40));
    previewScroll.setBorder(null);

    this.add(previewScroll);
}

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

/**
 * {@inheritDoc}//w ww  .j a va 2s.c  om
 */
@Override
protected void setup() {
    PanelBuilder builder = new PanelBuilder(getFormLayout(), getPanel());
    CellConstraints cc = new CellConstraints();

    Dimension d = maxModifier.getPreferredSize();
    maxModifier.setPreferredSize(new Dimension(d.width + 50, d.height));
    d = minModifier.getPreferredSize();
    minModifier.setPreferredSize(new Dimension(d.width + 50, d.height));

    {
        builder.add(new JLabel("Titre de l'axe :"));
        final JTextField axisTitleField = new JTextField();
        axisTitleField.setText(axis.getLabel());
        builder.nextColumn(2);
        builder.add(axisTitleField, cc.xyw(3, 1, 5));
        addListenerOnSuccess(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String text = axisTitleField.getText();
                if (text != null && !text.equals(""))
                    axis.setLabel(axisTitleField.getText());
            }
        });
    }

    {
        builder.nextLine(2);
        builder.add(new JLabel("Valeur min. :"));
        builder.nextColumn(2);
        builder.add(lowField);
        addListenerOnSuccess(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Double value = Double.valueOf(lowField.getText());
                    if (isApply) {
                        axis.setLowerBound(value);
                    } else if (isCancel && oldLowValue != null)
                        axis.setLowerBound(oldLowValue);
                } catch (NumberFormatException e1) {
                    canClose = false;
                    JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(),
                            "'" + lowField.getText() + "' n'est pas un nombre", "Erreur",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        builder.nextColumn(2);
        builder.add(new JLabel("+"));
        builder.nextColumn(2);
        builder.add(minModifier);
    }

    {
        builder.nextLine(2);
        builder.add(new JLabel("Valeur max. :"));
        builder.nextColumn(2);
        builder.add(maxField);
        addListenerOnSuccess(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Double value = Double.valueOf(maxField.getText());
                    if (isApply) {
                        axis.setUpperBound(value);
                    } else if (isCancel && oldHighValue != null)
                        axis.setUpperBound(oldHighValue);
                } catch (NumberFormatException e1) {
                    canClose = false;
                    JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(),
                            "'" + maxField.getText() + "' n'est pas un nombre", "Erreur",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        builder.nextColumn(2);
        builder.add(new JLabel("+"));
        builder.nextColumn(2);
        builder.add(maxModifier);
    }

    {
        builder.nextLine(2);
        builder.add(new JLabel("<HTML><strong>Sries associes  l'axe</strong></HTML>"), cc.xyw(1, 7, 3));
        String linkedSeries = "<html><ul>";
        for (Series series : Series.getInstances()) {
            if (series.getAxis().equals(axis))
                linkedSeries += "<li>" + series.toString(true) + "</li>";
        }
        linkedSeries += "</ul></html>";

        builder.add(new JLabel(linkedSeries), cc.xyw(1, 8, 3));
    }

    JPanel buttonPanel = new JPanel();
    ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(buttonPanel);
    buttonBuilder.addGlue();
    {
        buttonBuilder.addButton(new AbstractAction() {

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

            @Override
            public void actionPerformed(ActionEvent e) {
                isCancel = true;
                isApply = false;
                canClose = true;
                validateForm();
            }
        });
    }

    {
        buttonBuilder.addButton(new AbstractAction() {

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

            @Override
            public void actionPerformed(ActionEvent e) {
                isCancel = false;
                isApply = true;
                canClose = false;
                validateForm();
            }
        });
    }

    {
        buttonBuilder.addButton(new AbstractAction() {

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

            @Override
            public void actionPerformed(ActionEvent e) {
                isCancel = false;
                isApply = true;
                canClose = true;
                validateForm();
            }
        });
    }

    buttonBuilder.build();
    buttonPanel.setVisible(true);
    builder.add(buttonBuilder.getPanel(), cc.xyw(1, 10, 10));

    {
        translateSlider.setToolTipText("Translation des axes");
        translateSlider.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                int maxValue = -translateSlider.getValue();
                maxModifier.setText(String.valueOf(maxValue));
                int lowValue = -translateSlider.getValue();
                minModifier.setText(String.valueOf(lowValue));
            }
        });
        builder.add(translateSlider, cc.xywh(9, 1, 1, 8));
    }
    {
        homotSlider.setToolTipText("Homothtie sur les axes");
        homotSlider.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                int maxValue = -homotSlider.getValue();
                maxModifier.setText(String.valueOf(maxValue));
                int lowValue = homotSlider.getValue();
                minModifier.setText(String.valueOf(lowValue));
            }
        });
        builder.add(homotSlider, cc.xywh(10, 1, 1, 8));
    }

    builder.build();

    getPanel().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    addListenerOnSuccess(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (canClose)
                setVisible(false);
        }
    });
}

From source file:grupob.TipoProceso.java

public TipoProceso() {
    initComponents();//from  www.  ja  v a 2s . c o m
    initInstitucional();
    //        listaRegiones.add(new Region(1,"Lima",15000));
    //        listaRegiones.add(new Region(1,"Arequipa",10000));
    //        listaRegiones.add(new Region(1,"Junin",12000));
    TipoProcesoVotacion tipoNacional = Manager.queryProcesoById(1);
    TipoProcesoVotacion tipoRegional = Manager.queryProcesoById(2);
    TipoProcesoVotacion tipoDistrital = Manager.queryProcesoById(3);
    Calendar cal = Calendar.getInstance();
    Date dateActual = cal.getTime();
    textConfGeneral.setText(Recorte.rutaGeneral);
    textConfHuellas.setText(Recorte.rutaHuella);
    textConfFirmas.setText(Recorte.rutaFirma);
    /*
    Recorte.rutaGeneral = FramePrincipal.rutaGeneral;
    Recorte.rutaHuella = FramePrincipal.rutaHuella;
    Recorte.rutaFirma = FramePrincipal.rutaFirma;*/

    if (tipoNacional != null && tipoNacional.getId() != 0) {
        if (!tipoNacional.getFechaInicio2().after(dateActual)) {
            fechai1Nacional.setDate(tipoNacional.getFechaInicio1().getTime());
            fechai2Nacional.setDate(tipoNacional.getFechaInicio2().getTime());
            fechaf1Nacional.setDate(tipoNacional.getFechaFin1().getTime());
            fechaf2Nacional.setDate(tipoNacional.getFechaFin2().getTime());
        }
        if ((tipoNacional.getFechaInicio1().before(dateActual)) && (cal.before(tipoNacional.getFechaFin2()))) {
            botonGuardarNacional.setEnabled(false);
        }
        if (tipoNacional.getFechaFin2().before(dateActual)) {
            botonGuardarNacional.setEnabled(true);
        }
    }
    if (tipoRegional != null && tipoRegional.getId() != 0) {
        if (!tipoRegional.getFechaInicio2().after(dateActual)) {
            fechai1Regiones.setDate(tipoRegional.getFechaInicio1().getTime());
            fechai2Regiones.setDate(tipoRegional.getFechaInicio2().getTime());
            fechaf1Regiones.setDate(tipoRegional.getFechaFin1().getTime());
            fechaf2Regiones.setDate(tipoRegional.getFechaFin2().getTime());
            porcentajeRegional.setText("" + tipoRegional.getPorcentajeMinimo() * 100);
        }
        if ((tipoRegional.getFechaInicio1().before(dateActual)) && (cal.before(tipoRegional.getFechaFin2()))) {
            botonGuardarRegional.setEnabled(false);
        }
        if (tipoRegional.getFechaFin2().before(dateActual)) {
            botonGuardarRegional.setEnabled(true);
        }
    }
    if (tipoDistrital != null && tipoDistrital.getId() != 0) {
        if (!tipoRegional.getFechaInicio2().after(dateActual)) {
            fechai1Distritos.setDate(tipoDistrital.getFechaInicio1().getTime());
            fechai2Distritos.setDate(tipoDistrital.getFechaInicio2().getTime());
            fechaf1Distritos.setDate(tipoDistrital.getFechaFin1().getTime());
            fechaf2Distritos.setDate(tipoDistrital.getFechaFin2().getTime());
            porcentajeDistrital.setText("" + tipoDistrital.getPorcentajeMinimo() * 100);
        }
        if ((tipoDistrital.getFechaInicio1().before(dateActual))
                && (cal.before(tipoDistrital.getFechaFin2()))) {
            botonGuardarDistrital.setEnabled(false);
            //                addRowRegional.setEnabled(false);
            //                jTable6.setEnabled(false);
        }
        if (tipoDistrital.getFechaFin2().before(dateActual)) {
            botonGuardarDistrital.setEnabled(true);
            //                addRowRegional.setEnabled(true);
        }
    }
    agregarDatos();
    agregarDatosDistritos();
    if (listaRegiones != null) {
        jTableRegiones.getColumn("Eliminar").setCellRenderer(new ButtonRenderer());
        jTableRegiones.getColumn("Eliminar").setCellEditor(new botonEliminarRegiones());
    }
    if (listaDistritos != null) {
        jTableDistritos.getColumn("Eliminar").setCellRenderer(new ButtonRenderer());
        jTableDistritos.getColumn("Eliminar").setCellEditor(new botonEliminarDistritos());
    }

    TableColumn sColumn = jTableDistritos.getColumnModel().getColumn(2);
    ArrayList<Region> lReg = Manager.queryAllRegion();
    JComboBox comboBox = new JComboBox();
    for (int i = 0; i < lReg.size(); i++) {
        comboBox.addItem(lReg.get(i).getNombre());
    }
    sColumn.setCellEditor(new DefaultCellEditor(comboBox));

    TableColumn instColumn = tblInstitucional.getColumnModel().getColumn(2);
    ArrayList<Local> lLoc = Manager.queryAllLocales();
    JComboBox comboBoxLocal = new JComboBox();
    for (int i = 0; i < lLoc.size(); i++) {
        comboBoxLocal.addItem(lLoc.get(i).getNombre());
    }
    instColumn.setCellEditor(new DefaultCellEditor(comboBoxLocal));

    ChangeListener changeListener = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {

            JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource();
            int index = sourceTabbedPane.getSelectedIndex();
            switch (index) {
            case 3:
                cargarDatosLocal();
                return;

            default:
                return;
            }

        }
    };

    jconfiguracion.addChangeListener(changeListener);

}

From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java

private MindRaiderMainWindow() {
    super(MindRaider.getTitle(), Gfx.getGraphicsConfiguration());
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   www.  ja v a 2 s .c  om
        }
    });
    // catch resize
    addComponentListener(this);

    configuration = new ConfigurationBean();

    // drag & drop registration
    DropTarget dropTarget = new DropTarget(this, (DropTargetListener) this);
    this.setDropTarget(dropTarget);

    // warn on different java version
    // checkJavaVersion();

    singleton = this;

    setIconImage(IconsRegistry.getImage("programIcon.gif"));
    SplashScreen splash = new SplashScreen(this, false);
    splash.showSplashScreen();

    // kernel init
    MindRaider.preSetProfiles();
    // message in here because of locales
    logger.debug(Messages.getString("MindRaiderJFrame.bootingKernel"));

    // master control panel
    MindRaider.setMasterToolBar(new MasterToolBar());
    getContentPane().add(MindRaider.masterToolBar, BorderLayout.NORTH);

    // status bar
    getContentPane().add(StatusBar.getStatusBar(), BorderLayout.SOUTH);

    // build menu
    buildMenu(MindRaider.spidersGraph);
    // profile
    MindRaider.setProfiles();

    // left sidebar: folder/notebooks hierarchy, taxonomies, ...
    final JTabbedPane leftSidebar = new JTabbedPane(SwingConstants.BOTTOM);
    leftSidebar.setTabPlacement(SwingConstants.TOP);
    // TODO add icons to tabs
    leftSidebar.addTab(Messages.getString("MindRaiderJFrame.explorer"), ExplorerJPanel.getInstance());

    // TODO just blank panel
    //leftSidebar.addTab("Tags",new OutlookBarMain());

    leftSidebar.addTab(
            Messages.getString("MindRaiderJFrame.trash"), /* IconsRegistry.getImageIcon("trashFull.png"), */
            TrashJPanel.getInstance());

    leftSidebar.setSelectedIndex(0);
    leftSidebar.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent arg0) {
            if (arg0.getSource() instanceof JTabbedPane) {
                if (leftSidebar.getSelectedIndex() == 1) {
                    // refresh trash
                    TrashJPanel.getInstance().refresh();
                }
            }
        }
    });

    // main panel: (notebook outline & RDF Navigator) + Control panel
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(OutlineJPanel.getInstance(), BorderLayout.CENTER);

    // split: left sidebar/main panel
    leftSidebarSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSidebar, mainPanel);
    leftSidebarSplitPane.setOneTouchExpandable(true);
    leftSidebarSplitPane.setDividerLocation(200);
    leftSidebarSplitPane.setLastDividerLocation(200);
    leftSidebarSplitPane.setDividerSize(6);
    leftSidebarSplitPane.setContinuousLayout(true);
    getContentPane().add(leftSidebarSplitPane, BorderLayout.CENTER);

    Gfx.centerAndShowWindow(this, 1024, 768);

    MindRaider.postSetProfiles();

    if (!configuration.isShowSpidersTagSnailPane()) {
        OutlineJPanel.getInstance().hideSpiders();
    }

    splash.hideSplash();
}

From source file:com.googlecode.logVisualizer.chart.turnrundownGantt.GanttChartBuilder.java

@Override
protected void addChart() {
    super.addChart();

    final int scrollCaretExtend = 20;
    int scrollableAreaIntervals = ((TurnRundownDataset) dataset.getUnderlyingDataset()).getDataset().size()
            - (dataset.getMaximumCategoryCount() - scrollCaretExtend);
    scrollableAreaIntervals = scrollableAreaIntervals > 20 ? scrollableAreaIntervals : 20;
    final JScrollBar scrollBar = new JScrollBar(JScrollBar.VERTICAL, 0, scrollCaretExtend, 0,
            scrollableAreaIntervals);/*w w  w . j av a 2 s.c o  m*/
    scrollBar.getModel().addChangeListener(new ChangeListener() {

        public void stateChanged(final ChangeEvent e) {
            dataset.setFirstCategoryIndex(scrollBar.getValue());
        }
    });

    add(scrollBar, BorderLayout.EAST);
}

From source file:com.rapidminer.gui.graphs.TransitionGraphCreator.java

@Override
public JComponent getOptionComponent(final GraphViewer viewer, int index) {
    if (index == 0) {
        return new JLabel("Source Filter:");
    } else if (index == 1) {
        sourceFilter.addActionListener(new ActionListener() {

            @Override/*w  w w.j  a v  a  2  s  . c  o  m*/
            public void actionPerformed(ActionEvent e) {
                updateGraph();
                viewer.updateLayout();
            }
        });
        return sourceFilter;
    } else if (index == 2) {
        return new JLabel("Number of Hops:");
    } else if (index == 3) {
        this.numberOfHops.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                updateGraph();
                viewer.updateLayout();
            }
        });
        return numberOfHops;

    } else if (index == 4) {
        return new JLabel("Number of Edges:");
    } else if (index == 5) {
        this.edgeSlider.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                if (!edgeSlider.getValueIsAdjusting()) {
                    updateGraph();
                    viewer.updateLayout();
                }
            }
        });
        return edgeSlider;
    } else {
        return null;
    }
}