Example usage for javax.swing JPanel setBorder

List of usage examples for javax.swing JPanel setBorder

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:es.emergya.ui.gis.popups.SaveGPXDialog.java

private SaveGPXDialog(final List<Layer> capas) {
    super("Consulta de Posiciones GPS");
    setResizable(false);/*www .  j  a v a  2s. c  om*/
    setAlwaysOnTop(true);
    try {
        setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame()
                .getIconImage());
    } catch (Throwable e) {
        LOG.error("There is no icon image", e);
    }

    this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    JPanel dialogo = new JPanel(new BorderLayout());
    dialogo.setBackground(Color.WHITE);
    dialogo.setBorder(new EmptyBorder(10, 10, 10, 10));

    JPanel central = new JPanel(new FlowLayout());
    central.setOpaque(false);
    final JTextField nombre = new JTextField(15);
    nombre.setEditable(false);
    central.add(nombre);
    final JButton button = new JButton("Examinar...", LogicConstants.getIcon("button_nuevo"));
    central.add(button);
    final JButton aceptar = new JButton("Guardar", LogicConstants.getIcon("button_save"));
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            if (fileChooser.showSaveDialog(SaveGPXDialog.this) == JFileChooser.APPROVE_OPTION) {
                nombre.setText(fileChooser.getSelectedFile().getAbsolutePath());
                aceptar.setEnabled(true);
            }
        }
    });

    dialogo.add(central, BorderLayout.CENTER);

    JPanel botones = new JPanel(new FlowLayout());
    botones.setOpaque(false);

    aceptar.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String base_url = nombre.getText() + "_";
            for (Layer layer : capas) {
                if (layer instanceof GpxLayer) {
                    GpxLayer gpxLayer = (GpxLayer) layer;
                    File f = new File(base_url + gpxLayer.name + ".gpx");

                    boolean sobreescribir = !f.exists();

                    try {
                        while (!sobreescribir) {
                            String original = f.getCanonicalPath();
                            f = checkFileOverwritten(nombre, f);
                            sobreescribir = !f.exists() || original.equals(f.getCanonicalPath());
                        }
                    } catch (NullPointerException t) {
                        log.debug("Cancelando creacion de fichero: " + t);
                        sobreescribir = false;
                    } catch (Throwable t) {
                        log.error("Error comprobando la sobreescritura", t);
                        sobreescribir = false;
                    }

                    if (sobreescribir) {
                        try {
                            f.createNewFile();
                        } catch (IOException e1) {
                            log.error(e1, e1);
                        }
                        if (!(f.isFile() && f.canWrite()))
                            JOptionPane.showMessageDialog(SaveGPXDialog.this,
                                    "No tengo permiso para escribir en " + f.getAbsolutePath());
                        else {
                            try {
                                OutputStream out = new FileOutputStream(f);
                                GpxWriter writer = new GpxWriter(out);
                                writer.write(gpxLayer.data);
                                out.close();
                            } catch (Throwable t) {
                                log.error("Error al escribir el gpx", t);
                                JOptionPane.showMessageDialog(SaveGPXDialog.this,
                                        "Ocurri un error al escribir en " + f.getAbsolutePath());
                            }
                        }
                    } else
                        log.error("Por errores anteriores no se escribio el fichero");
                } else
                    log.error("Una de las capas no era gpx: " + layer.name);
            }
            SaveGPXDialog.this.dispose();

        }

        private File checkFileOverwritten(final JTextField nombre, File f) throws Exception {
            String nueva = JOptionPane.showInputDialog(nombre, i18n.getString("savegpxdialog.overwrite"),
                    "Sobreescribir archivo", JOptionPane.QUESTION_MESSAGE, null, null, f.getCanonicalPath())
                    .toString();
            log.debug("Nueva ruta: " + nueva);
            return new File(nueva);
        }
    });

    JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel"));

    cancelar.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SaveGPXDialog.this.dispose();
        }
    });

    aceptar.setEnabled(false);
    botones.add(aceptar);
    botones.add(cancelar);
    dialogo.add(botones, BorderLayout.SOUTH);

    add(dialogo);
    setPreferredSize(new Dimension(300, 200));
    pack();

    int x;
    int y;

    Container myParent;
    try {
        myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame()
                .getContentPane();
        java.awt.Point topLeft = myParent.getLocationOnScreen();
        Dimension parentSize = myParent.getSize();

        Dimension mySize = getSize();

        if (parentSize.width > mySize.width)
            x = ((parentSize.width - mySize.width) / 2) + topLeft.x;
        else
            x = topLeft.x;

        if (parentSize.height > mySize.height)
            y = ((parentSize.height - mySize.height) / 2) + topLeft.y;
        else
            y = topLeft.y;

        setLocation(x, y);
    } catch (Throwable e1) {
        LOG.error("There is no basic window!", e1);
    }

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            nombre.setText("");
            nombre.repaint();
        }

        @Override
        public void windowClosing(WindowEvent e) {
            nombre.setText("");
            nombre.repaint();
        }
    });
}

From source file:fuel.gui.stats.MotorStatsPanel.java

private void refreshGraphs(Motorcycle motor) {
    graphContainer.removeAll();/*from w  ww. ja va2  s  .  co m*/
    if (motor != null) {
        DefaultPieDataset usageDataset = new DefaultPieDataset();
        try {
            ResultSet thisMotor = database
                    .Query("SELECT SUM(distance) FROM fuelrecords WHERE motorcycleId = " + motor.getId(), true);
            ResultSet otherMotors = database.Query(
                    "SELECT SUM(distance) FROM fuelrecords WHERE NOT motorcycleId = " + motor.getId(), true);
            thisMotor.next();
            otherMotors.next();

            usageDataset.setValue(motor.toString(), thisMotor.getInt("1"));
            usageDataset.setValue("Andere motoren", otherMotors.getInt("1"));

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause());
        }
        JFreeChart usagePiechart = ChartFactory.createPieChart3D("", usageDataset, true, true, false);
        PiePlot3D plot3 = (PiePlot3D) usagePiechart.getPlot();
        plot3.setForegroundAlpha(0.6f);
        //plot3.setCircular(true);

        JPanel usagePiechartPanel = new ChartPanel(usagePiechart);
        usagePiechartPanel
                .setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Motorgebruik")));
        usagePiechartPanel.setPreferredSize(new java.awt.Dimension(240, 240));
        usagePiechartPanel.setLayout(new BorderLayout());

        DefaultPieDataset stationDataset = new DefaultPieDataset();
        try {
            for (Station station : database.getStations()) {
                ResultSet numberStations = database.Query(
                        "SELECT DISTINCT stationId FROM fuelrecords WHERE stationId = " + station.getId(),
                        true);
                if (numberStations.next()) {
                    ResultSet otherMotors = database.Query("SELECT COUNT(*) FROM fuelrecords WHERE stationId = "
                            + station.getId() + " AND motorcycleId = " + motor.getId(), true);
                    otherMotors.next();
                    if (otherMotors.getInt("1") > 0) {
                        stationDataset.setValue(station.toString(), otherMotors.getInt("1"));
                    }
                }
            }

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause());
        }
        JFreeChart stationPiechart = ChartFactory.createPieChart3D("", stationDataset, true, true, false);
        PiePlot3D plot2 = (PiePlot3D) stationPiechart.getPlot();
        plot2.setForegroundAlpha(0.6f);
        //plot3.setCircular(true);

        JPanel stationPiechartPanel = new ChartPanel(stationPiechart);
        stationPiechartPanel.setBorder(
                BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Tankstation verhouding")));
        stationPiechartPanel.setPreferredSize(new java.awt.Dimension(240, 240));
        stationPiechartPanel.setLayout(new BorderLayout());

        DefaultPieDataset fuelDataset = new DefaultPieDataset();
        try {
            ResultSet numberResults = database.Query("SELECT DISTINCT typeOfGas FROM fuelrecords", true);
            while (numberResults.next()) {
                ResultSet thisStation = database.Query(
                        "SELECT SUM(liter) FROM fuelrecords WHERE typeOfGas = '"
                                + numberResults.getString("typeOfGas") + "'AND motorcycleId = " + motor.getId(),
                        true);
                thisStation.next();
                if (thisStation.getDouble("1") > 0) {
                    fuelDataset.setValue(numberResults.getString("TYPEOFGAS"), thisStation.getDouble("1"));
                }
            }

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause());
        }
        JFreeChart fuelPieChart = ChartFactory.createPieChart3D("", fuelDataset, true, true, false);
        PiePlot3D plot1 = (PiePlot3D) fuelPieChart.getPlot();
        plot1.setForegroundAlpha(0.6f);
        //plot3.setCircular(true);

        JPanel fuelPieChartPanel = new ChartPanel(fuelPieChart);
        fuelPieChartPanel.setBorder(
                BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Brandstof verhouding")));
        fuelPieChartPanel.setPreferredSize(new java.awt.Dimension(240, 240));

        DefaultCategoryDataset barDataset = new DefaultCategoryDataset();
        try {
            ResultSet motorThing = database
                    .Query("SELECT distance/liter,date FROM fuelrecords WHERE motorcycleId = " + motor.getId()
                            + " ORDER BY date ASC", true);
            while (motorThing.next()) {
                barDataset.addValue(motorThing.getDouble("1"), motorThing.getString("DATE"), "Verbruik");
            }

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause());
        }

        JFreeChart barChart = ChartFactory.createBarChart3D("", // chart title
                "", // domain axis label
                "Aantal", // range axis label
                barDataset, // data
                PlotOrientation.VERTICAL, false, // include legend
                true, // tooltips?
                false // URLs?
        );
        CategoryPlot plot = barChart.getCategoryPlot();
        BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
        renderer.setDrawBarOutline(false);

        ChartPanel barChartPanel = new ChartPanel(barChart);
        barChartPanel.getChartRenderingInfo().setEntityCollection(null);
        barChartPanel.setBorder(BorderFactory.createTitledBorder("Verbruik"));
        barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240));
        barChartPanel.setLayout(new BorderLayout());

        JPanel piePanel = new JPanel(new GridLayout(0, 3));
        piePanel.add(usagePiechartPanel);
        piePanel.add(stationPiechartPanel);
        piePanel.add(fuelPieChartPanel);

        //uitgaven
        DefaultPieDataset expensesDataset = new DefaultPieDataset();
        try {
            Map<String, ResultSet> allCosts = new HashMap<String, ResultSet>();
            ResultSet fuelCosts = database
                    .Query("SELECT SUM(cost) FROM fuelrecords WHERE motorcycleId = " + motor.getId(), true);
            allCosts.put("Brandstof", fuelCosts);
            ResultSet expenses = database.Query("SELECT DISTINCT categoryid FROM expenses", true);
            while (expenses.next()) {
                ResultSet set = database.Query("SELECT SUM(costs) FROM expenses WHERE categoryid = "
                        + expenses.getInt("categoryid") + " AND motorcycleid = " + motor.getId(), true);
                ResultSet set2 = database
                        .Query("SELECT name FROM categories WHERE id = " + expenses.getInt("categoryid"), true);
                set2.next();
                allCosts.put(set2.getString("name"), set);
            }

            for (Map.Entry<String, ResultSet> element : allCosts.entrySet()) {
                element.getValue().next();
                if (element.getValue().getInt("1") > 0) {
                    expensesDataset.setValue(element.getKey(), element.getValue().getInt("1"));
                }
            }

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause());
        }
        JFreeChart expensesPiechart = ChartFactory.createPieChart3D("", expensesDataset, true, true, false);
        PiePlot3D plot4 = (PiePlot3D) expensesPiechart.getPlot();
        plot4.setForegroundAlpha(0.6f);

        JPanel expensesPiePanel = new ChartPanel(expensesPiechart);
        expensesPiePanel
                .setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Uitgaven")));
        expensesPiePanel.setPreferredSize(new java.awt.Dimension(240, 240));
        expensesPiePanel.setLayout(new BorderLayout());

        graphContainer.add(piePanel);
        graphContainer.add(barChartPanel);
        graphContainer.add(expensesPiePanel);
    }
    revalidate();
    repaint();
}

From source file:EdgeLabelDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the label positioning features/*ww w  . ja  v a 2s. 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:de.rub.syssec.saaf.gui.frame.CfgSelectorFrame.java

/**
 * A frame to generate and open Control Flow Graphs. CFGs are created using mxGraph
 * and are saved as PNGs.//w w  w  .ja  v  a2 s.co  m
 * 
 * @param smaliClass the smali class to select methods from
 */
public CfgSelectorFrame(ClassInterface smaliClass) {
    super(smaliClass.getFullClassName(true), true, true, true, true);
    this.smaliClass = smaliClass;

    listModel = new MethodTableModel(smaliClass);
    list.setModel(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            int viewRow = list.getSelectedRow();
            if (viewRow <= 0) {
                showButton.setEnabled(false);
            } else {
                showButton.setEnabled(true);
            }
        }
    });

    JScrollPane listScrollPane = new JScrollPane(list);

    ActionListener al = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals(SHOW_OPERATION)) {
                generateAndShowCfg(true);
            } else if (e.getActionCommand().equals(GENERATE_OPERATION)) {
                generateAndShowCfg(false);
            }
        }
    };

    generateButton = new JButton(GENERATE_OPERATION);
    generateButton.setActionCommand(GENERATE_OPERATION);
    generateButton.addActionListener(al);
    showButton = new JButton(SHOW_OPERATION);
    showButton.setEnabled(false);
    showButton.addActionListener(al);

    saveCfgCheckBox = new JCheckBox("Save a copy");
    saveCfgCheckBox.setToolTipText("Save a copy in the configured CFG folder upon generation.");

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.add(generateButton);
    buttonPane.add(saveCfgCheckBox);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JPanel filler = new JPanel();
    filler.setPreferredSize(new Dimension(10, 10));
    buttonPane.add(filler);
    buttonPane.add(showButton);

    add(listScrollPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);

    this.setPreferredSize(new Dimension(500, 250));
    this.pack();
    this.setVisible(true);
}

From source file:GeometryByReferenceTest.java

JPanel createGeometryByReferencePanel() {
    JPanel panel = new JPanel();
    panel.setBorder(new TitledBorder("Geometry Type"));

    String values[] = { "Array", "Strip", "Indexed", "IndexedStrip" };
    geomType = new JComboBox(values);
    geomType.setLightWeightPopupEnabled(false);
    geomType.addActionListener(this);
    geomType.setSelectedIndex(0);/*from ww  w .  ja  v a  2s  .  c o m*/
    panel.add(new JLabel("Geometry Type"));
    panel.add(geomType);

    String vertex_types[] = { "Float", "P3F" };

    vertexType = new JComboBox(vertex_types);
    vertexType.setLightWeightPopupEnabled(false);
    vertexType.addActionListener(this);
    vertexType.setSelectedIndex(0);
    panel.add(new JLabel("VertexType"));
    panel.add(vertexType);

    String color_types[] = { "Float", "C3F" };

    colorType = new JComboBox(color_types);
    colorType.setLightWeightPopupEnabled(false);
    colorType.addActionListener(this);
    colorType.setSelectedIndex(0);
    panel.add(new JLabel("ColorType"));
    panel.add(colorType);

    return panel;
}

From source file:VoteDialog.java

public VoteDialog(JFrame frame) {
    this.frame = frame;
    JLabel title;/* w  w w.j  a  v a  2s .  co m*/

    // Create the components.
    JPanel choicePanel = createSimpleDialogBox();

    System.out.println("passed createSimpleDialogBox");

    title = new JLabel("Click the \"Vote\" button" + " once you have selected a candidate.", JLabel.CENTER);

    label = new JLabel("Vote now!", JLabel.CENTER);
    label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    choicePanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 5, 20));

    // Set the layout.
    setLayout(new BorderLayout());
    add(title, BorderLayout.NORTH);
    add(label, BorderLayout.SOUTH);
    add(choicePanel, BorderLayout.CENTER);
}

From source file:com.att.aro.ui.view.videotab.VideoTab.java

/**
 * TopPanel contains summaries/* www. ja  va2s  . co  m*/
 */
private JPanel buildSummariesGroup() {

    JPanel topPanel;
    topPanel = new JPanel(new GridBagLayout());

    topPanel.setOpaque(false);
    topPanel.setBorder(new RoundedBorder(new Insets(20, 20, 20, 20), Color.WHITE));
    int section = 0;

    // Trace Summary, common with Best Practices and Statistics
    DateTraceAppDetailPanel dateTraceAppDetailPanel = new DateTraceAppDetailPanel();
    topPanel.add(dateTraceAppDetailPanel, new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insets, 0, 0));
    bpObservable.registerObserver(dateTraceAppDetailPanel);

    // Separator
    topPanel.add(UIComponent.getInstance().getSeparator(), new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 10, 0), 0, 0));

    topPanel.add(getTitle(), new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    // VideoSummaryPanel
    VideoSummaryPanel videoSummaryPanel = new VideoSummaryPanel();
    localRefreshList.add(videoSummaryPanel);
    topPanel.add(videoSummaryPanel, new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insets, 0, 0));
    bpObservable.registerObserver(videoSummaryPanel);

    return topPanel;
}

From source file:FontChooser.java

private JPanel createPreviewPanel() {
    final JPanel pnl = new JPanel(new BorderLayout());
    pnl.setBorder(BorderFactory.createTitledBorder("PreviewTitle"));
    Dimension prefSize = _previewLbl.getPreferredSize();
    prefSize.height = 50;/*from w w  w. jav  a 2  s  .c  o  m*/
    _previewLbl.setPreferredSize(prefSize);
    pnl.add(_previewLbl, BorderLayout.CENTER);
    setupPreviewLabel();

    return pnl;
}

From source file:com.google.code.facebook.graph.sna.applet.VertexCollapseDemo.java

public VertexCollapseDemo() {

    // create a simple graph for the demo
    graph = TestGraphs.getOneComponentGraph();
    collapser = new GraphCollapser(graph);

    layout = new FRLayout(graph);

    Dimension preferredSize = new Dimension(400, 400);
    final VisualizationModel visualizationModel = new DefaultVisualizationModel(layout, preferredSize);
    vv = new VisualizationViewer(visualizationModel, preferredSize);

    vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());

    final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance();
    final Set exclusions = new HashSet();
    eif.setPredicate(new Predicate() {

        public boolean evaluate(Object e) {

            return exclusions.contains(e);
        }// ww  w . jav  a  2s  .com
    });

    vv.getRenderContext().setParallelEdgeIndexFunction(eif);

    vv.setBackground(Color.white);

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller() {

        /* (non-Javadoc)
         * @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object)
         */
        @Override
        public String transform(Object v) {
            if (v instanceof Graph) {
                return ((Graph) v).getVertices().toString();
            }
            return super.transform(v);
        }
    });

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

    Container content = getContentPane();
    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
    content.add(gzsp);

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);

    final ScalingControl scaler = new CrossoverScalingControl();

    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());
        }
    });

    JButton collapse = new JButton("Collapse");
    collapse.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
            if (picked.size() > 1) {
                Graph inGraph = layout.getGraph();
                Graph clusterGraph = collapser.getClusterGraph(inGraph, picked);

                Graph g = collapser.collapse(layout.getGraph(), clusterGraph);
                double sumx = 0;
                double sumy = 0;
                for (Object v : picked) {
                    Point2D p = (Point2D) layout.transform(v);
                    sumx += p.getX();
                    sumy += p.getY();
                }
                Point2D cp = new Point2D.Double(sumx / picked.size(), sumy / picked.size());
                vv.getRenderContext().getParallelEdgeIndexFunction().reset();
                layout.setGraph(g);
                layout.setLocation(clusterGraph, cp);
                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JButton compressEdges = new JButton("Compress Edges");
    compressEdges.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = vv.getPickedVertexState().getPicked();
            if (picked.size() == 2) {
                Pair pair = new Pair(picked);
                Graph graph = layout.getGraph();
                Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst()));
                edges.retainAll(graph.getIncidentEdges(pair.getSecond()));
                exclusions.addAll(edges);
                vv.repaint();
            }

        }
    });

    JButton expandEdges = new JButton("Expand Edges");
    expandEdges.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = vv.getPickedVertexState().getPicked();
            if (picked.size() == 2) {
                Pair pair = new Pair(picked);
                Graph graph = layout.getGraph();
                Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst()));
                edges.retainAll(graph.getIncidentEdges(pair.getSecond()));
                exclusions.removeAll(edges);
                vv.repaint();
            }

        }
    });

    JButton expand = new JButton("Expand");
    expand.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
            for (Object v : picked) {
                if (v instanceof Graph) {

                    Graph g = collapser.expand(layout.getGraph(), (Graph) v);
                    vv.getRenderContext().getParallelEdgeIndexFunction().reset();
                    layout.setGraph(g);
                }
                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JButton reset = new JButton("Reset");
    reset.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            layout.setGraph(graph);
            exclusions.clear();
            vv.repaint();
        }
    });

    JButton help = new JButton("Help");
    help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog((JComponent) e.getSource(), instructions, "Help",
                    JOptionPane.PLAIN_MESSAGE);
        }
    });

    JPanel controls = new JPanel();
    JPanel zoomControls = new JPanel(new GridLayout(2, 1));
    zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    zoomControls.add(plus);
    zoomControls.add(minus);
    controls.add(zoomControls);
    JPanel collapseControls = new JPanel(new GridLayout(3, 1));
    collapseControls.setBorder(BorderFactory.createTitledBorder("Picked"));
    collapseControls.add(collapse);
    collapseControls.add(expand);
    collapseControls.add(compressEdges);
    collapseControls.add(expandEdges);
    collapseControls.add(reset);
    controls.add(collapseControls);
    controls.add(modeBox);
    controls.add(help);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:com.floreantpos.customer.DefaultCustomerListView.java

public void initUI() {
    setLayout(new MigLayout("fill", "[grow]", "[grow][grow][grow]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JPanel searchPanel = new JPanel(new MigLayout());

    JLabel lblByPhone = new JLabel(Messages.getString("CustomerSelectionDialog.1")); //$NON-NLS-1$
    JLabel lblByLoyality = new JLabel(Messages.getString("CustomerSelectionDialog.16")); //$NON-NLS-1$
    JLabel lblByName = new JLabel(Messages.getString("CustomerSelectionDialog.19")); //$NON-NLS-1$

    tfMobile = new POSTextField(16);
    tfLoyaltyNo = new POSTextField(16);
    tfName = new POSTextField(16);

    tfName.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSearchCustomer();/* w  w w  .j  a v a  2  s.co m*/
        }
    });
    tfLoyaltyNo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSearchCustomer();
        }
    });
    tfMobile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSearchCustomer();
        }
    });

    PosButton btnSearch = new PosButton(Messages.getString("CustomerSelectionDialog.15")); //$NON-NLS-1$
    btnSearch.setFocusable(false);
    btnSearch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSearchCustomer();
        }
    });

    PosButton btnKeyboard = new PosButton(IconFactory.getIcon("/images/", "keyboard.png")); //$NON-NLS-1$ //$NON-NLS-2$
    btnKeyboard.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            qwertyKeyPad.setCollapsed(!qwertyKeyPad.isCollapsed());
        }
    });

    searchPanel.add(lblByPhone, "growy"); //$NON-NLS-1$
    searchPanel.add(tfMobile, "growy"); //$NON-NLS-1$
    searchPanel.add(lblByLoyality, "growy"); //$NON-NLS-1$
    searchPanel.add(tfLoyaltyNo, "growy"); //$NON-NLS-1$
    searchPanel.add(lblByName, "growy"); //$NON-NLS-1$
    searchPanel.add(tfName, "growy"); //$NON-NLS-1$
    searchPanel.add(btnKeyboard,
            "growy,w " + PosUIManager.getSize(80) + "!,h " + PosUIManager.getSize(35) + "!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    searchPanel.add(btnSearch, ",growy,h " + PosUIManager.getSize(35) + "!"); //$NON-NLS-1$ //$NON-NLS-2$

    add(searchPanel, "cell 0 1"); //$NON-NLS-1$

    JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.setBorder(new TitledBorder(null, POSConstants.SELECT_CUSTOMER.toUpperCase(),
            TitledBorder.LEADING, TitledBorder.TOP, null, null)); //$NON-NLS-1$

    JPanel customerListPanel = new JPanel(new BorderLayout(0, 0));
    customerListPanel.setBorder(new EmptyBorder(5, 5, 0, 5));

    customerTable = new CustomerTable();
    customerTable.setModel(new CustomerListTableModel());
    customerTable.setFocusable(false);
    customerTable.setRowHeight(60);
    customerTable.getTableHeader().setPreferredSize(new Dimension(100, 35));
    customerTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    customerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            selectedCustomer = customerTable.getSelectedCustomer();
            if (selectedCustomer != null) {
                //btnInfo.setEnabled(true);
            } else {
                btnInfo.setEnabled(false);
            }
        }
    });
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setFocusable(false);
    scrollPane.setViewportView(customerTable);

    customerListPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel panel = new JPanel(new MigLayout("hidemode 3,al center", "sg", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    btnInfo = new PosButton(Messages.getString("CustomerSelectionDialog.23")); //$NON-NLS-1$
    btnInfo.setFocusable(false);
    panel.add(btnInfo, "grow"); //$NON-NLS-1$
    btnInfo.setEnabled(false);

    PosButton btnHistory = new PosButton(Messages.getString("CustomerSelectionDialog.24")); //$NON-NLS-1$
    btnHistory.setEnabled(false);
    panel.add(btnHistory, "grow"); //$NON-NLS-1$

    btnCreateNewCustomer = new PosButton(Messages.getString("CustomerSelectionDialog.25")); //$NON-NLS-1$
    btnCreateNewCustomer.setFocusable(false);
    panel.add(btnCreateNewCustomer, "grow"); //$NON-NLS-1$
    btnCreateNewCustomer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doCreateNewCustomer();
        }
    });

    btnRemoveCustomer = new PosButton(Messages.getString("CustomerSelectionDialog.26")); //$NON-NLS-1$
    btnRemoveCustomer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doRemoveCustomerFromTicket();
        }
    });
    panel.add(btnRemoveCustomer, "grow"); //$NON-NLS-1$

    PosButton btnSelect = new PosButton(Messages.getString("CustomerSelectionDialog.28")); //$NON-NLS-1$
    btnSelect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (isCreateNewTicket()) {
                doCreateNewTicket();
            } else {
                closeDialog(false);
            }
        }
    });
    panel.add(btnSelect, "grow"); //$NON-NLS-1$

    btnCancel = new PosButton(Messages.getString("CustomerSelectionDialog.29")); //$NON-NLS-1$
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeDialog(true);
        }
    });
    panel.add(btnCancel, "grow"); //$NON-NLS-1$

    customerListPanel.add(panel, BorderLayout.SOUTH);
    centerPanel.add(customerListPanel, BorderLayout.CENTER); //$NON-NLS-1$

    add(centerPanel, "cell 0 2,grow"); //$NON-NLS-1$

    qwertyKeyPad = new com.floreantpos.swing.QwertyKeyPad();
    qwertyKeyPad.setCollapsed(false);
    add(qwertyKeyPad, "cell 0 3,grow"); //$NON-NLS-1$
}