Example usage for javax.swing JPanel setOpaque

List of usage examples for javax.swing JPanel setOpaque

Introduction

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

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:es.emergya.ui.base.LoginWindow.java

private void initialize() {
    ventana.getContentPane().removeAll();
    ventana.setLayout(new BorderLayout());
    ventana.setSize(new Dimension(800, 600));

    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBackground(Color.WHITE);

    JPanel logos = new JPanel(new GridLayout(2, 1));
    logos.add(new JLabel(LogicConstants.getIcon("login_logo_cliente")));
    logos.add(new JLabel(LogicConstants.getIcon("login_logo")));
    logos.setBackground(Color.WHITE);

    JLabel label = new JLabel();
    label.setText(i18n.getString("11")); //$NON-NLS-1$

    JLabel labelUsuario = new JLabel();
    labelUsuario.setText(i18n.getString("12")); //$NON-NLS-1$

    JLabel lablep = new JLabel();
    lablep.setText(i18n.getString("13")); //$NON-NLS-1$

    panel.add(logos, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(error, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(labelUsuario, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(usuario, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(lablep, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(pass, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(conectando, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(login, new GridBagConstraints(1, 6, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));

    panel.setBorder(new EmptyBorder(100, 100, 100, 100));

    ventana.add(panel, BorderLayout.CENTER);

    JPanel abajo = new JPanel();

    abajo.setLayout(new FlowLayout(FlowLayout.RIGHT));
    abajo.add(version);//from   w  ww .jav a 2s  .c  o  m
    abajo.setOpaque(false);
    ventana.add(abajo, BorderLayout.SOUTH);

    try {
        label.setFont(LogicConstants.deriveBoldFont(20.0f));
        labelUsuario.setFont(LogicConstants.deriveBoldFont(20.0f));
        lablep.setFont(LogicConstants.deriveBoldFont(20.0f));
        login.setFont(LogicConstants.deriveBoldFont(20.0f));
        error.setFont(LogicConstants.getBoldFont());
    } catch (Exception e) {
        LOG.error("Error al inicializar el login", e);
    }
    ventana.setLocationRelativeTo(null);
    // ventana.pack();

}

From source file:JSplash.java

private void init() {
    JPanel pnlImage = new JPanel();
    ImageIcon image = new ImageIcon(getClass().getResource("img/logo.jpg"));
    JLabel lblBack = new JLabel(image);
    Border raisedbevel = BorderFactory.createRaisedBevelBorder();
    Border loweredbevel = BorderFactory.createLoweredBevelBorder();

    lblBack.setBounds(0, 0, image.getIconWidth(), image.getIconHeight());
    getLayeredPane().add(lblBack, new Integer(Integer.MIN_VALUE));

    pnlImage.setLayout(null);//  w w w  .  j av a2  s  .  c om
    pnlImage.setOpaque(false);
    pnlImage.setBorder(BorderFactory.createCompoundBorder(raisedbevel, loweredbevel));

    pnlImage.add(this.lblVersion);

    this.lblVersion.setForeground(Color.white);
    this.lblVersion.setFont(new Font("Dialog", Font.PLAIN, 12));
    this.lblVersion.setBounds(15, 69, 120, 20);

    setContentPane(pnlImage);
    setSize(image.getIconWidth(), image.getIconHeight());
}

From source file:gui.WikiCorpusClusteringView.java

/**
 *
 * @param br/* w  w w  . j a va 2 s .c o  m*/
 * @throws IOException
 */
private void setUpView(Graph graph) throws IOException {

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

    //layout = new TreeLayout<String,Integer>(graph);
    Layout<Number, Number> layout = new KKLayout<Number, Number>(graph);
    layout.setSize(new Dimension(900, 900));

    vv = new VisualizationViewer<Number, Number>(layout);
    vv.setBackground(Color.white);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()
            .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() {
        public Paint transform(Number 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:de.main.sessioncreator.ReportingHelper.java

public void addReport(JPanel jp) {
    jp.removeAll();/*from w w w  .  ja v a  2s . c  o  m*/
    PieDataset dataset = createDataset();
    // based on the dataset we create the chart
    JFreeChart chart = createChart(dataset, "Sessions by Tester");
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.updateUI();
    chartPanel.setSize(490, 350);

    jp.revalidate();
    jp.setOpaque(true);
    jp.add(chartPanel);
    jp.revalidate();
    jp.setVisible(true);
    jp.setSize(700, 500);
    jp.revalidate();
    jp.repaint();
}

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

public SummaryDialog(Recurso r) {

    super();/*from ww  w. j  a v a 2s  . c o  m*/
    r = (r == null) ? null : RecursoConsultas.getByIdentificador(r.getIdentificador());
    setAlwaysOnTop(true);
    setResizable(false);
    setName(r.getIdentificador());
    setBackground(Color.WHITE);
    setSize(600, 400);
    setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador());
    try {
        setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame()
                .getIconImage());
    } catch (Throwable e) {
        LOG.error("There is no icon image", e);
    }
    JPanel base = new JPanel();
    base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));
    base.setBackground(Color.WHITE);

    r = RecursoConsultas.getByIdentificador(r.getIdentificador());

    // Icono del titulo
    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING));

    final JLabel labelTitle = new JLabel(i18n.getString("Resources.summary.title") + " " + r.getIdentificador(),
            LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);
    labelTitle.setFont(LogicConstants.deriveBoldFont(12f));

    title.setBackground(Color.WHITE);

    title.add(labelTitle);

    base.add(title);

    // Nombre
    JPanel mid = new JPanel(new SpringLayout());
    mid.setBackground(Color.WHITE);
    mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT));
    JTextField name = new JTextField(25);
    if (r != null)
        name.setText(r.getIdentificador());
    name.setEditable(false);
    mid.add(name);
    // Patrulla
    mid.add(new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT));
    // JComboBox squads = new
    // JComboBox(PatrullaConsultas.getAll().toArray());
    JTextField squads = new JTextField(r.getPatrullas() == null ? null : r.getPatrullas().getNombre());
    // squads.setSelectedItem(r.getPatrullas());
    squads.setEditable(false);
    squads.setColumns(21);
    // squads.setEnabled(false);
    mid.add(squads);

    // Tipo
    mid.add(new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT));
    JTextField types = new JTextField(r.getTipo());
    types.setEditable(false);
    mid.add(types);

    // Estado Eurocop
    mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT));
    JTextField status = new JTextField();
    if (r.getEstadoEurocop() != null)
        status.setText(r.getEstadoEurocop().getIdentificador());
    status.setEditable(false);
    mid.add(status);

    // Subflota
    mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT));
    JTextField subfleets = new JTextField(r.getFlotas() == null ? null : r.getFlotas().getNombre());
    subfleets.setEditable(false);
    mid.add(subfleets);

    // Referencia Humana
    mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT));
    JTextField rHumana = new JTextField();
    // if (r.getIncidencias() != null)
    // rHumana.setText(r.getIncidencias().getReferenciaHumana());
    rHumana.setEditable(false);
    mid.add(rHumana);
    // dispositivo
    mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT));
    JTextField issi = new JTextField();
    issi.setEditable(false);
    mid.add(issi);
    mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT));
    JCheckBox enabled = new JCheckBox("", true);
    enabled.setEnabled(false);
    enabled.setOpaque(false);
    if (r.getDispositivo() != null) {
        final String valueOf = String.valueOf(r.getDispositivo());
        try {
            issi.setText(String.format(FORMAT, r.getDispositivo()));
        } catch (Throwable t) {
            issi.setText(valueOf);
        }
        enabled.setSelected(r.getHabilitado());
    }
    mid.add(enabled);

    // Fecha ultimo gps
    mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT));
    JTextField lastGPS = new JTextField();

    final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r);
    if (lastGPSDateForRecurso != null) {
        lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso));
    }
    lastGPS.setEditable(false);
    mid.add(lastGPS);

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18);
    base.add(mid);

    // informacion adicional
    JPanel infoPanel = new JPanel(new SpringLayout());
    JTextField info = new JTextField(25);
    info.setText(r.getInfoAdicional());
    info.setEditable(false);
    infoPanel.setOpaque(false);
    infoPanel.add(new JLabel(i18n.getString("Resources.info")));
    infoPanel.add(info);
    SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18);
    base.add(infoPanel);

    JPanel buttons = new JPanel();

    buttons.setBackground(Color.WHITE);
    JButton accept = new JButton(i18n.getString("Buttons.ok"), LogicConstants.getIcon("button_accept"));

    accept.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    buttons.add(accept);
    base.add(buttons);

    getContentPane().add(base);
    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);
    }
}

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

private RouteDialog() {
    super();//from   w  ww  . j av a 2 s  .com
    setAlwaysOnTop(true);
    setResizable(false);
    iconTransparente = LogicConstants.getIcon("48x48_transparente");
    iconEnviando = LogicConstants.getIcon("anim_calculando");
    try {
        route = new OsmDataLayer(new DataSet(), "route", File.createTempFile("route", "route"));
    } catch (IOException e) {
        log.error(e.getMessage(), e);
    }
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            clear.doClick();
            setVisible(false);
        }
    });
    setTitle(i18n.getString("window.route.titleBar"));
    setMinimumSize(new Dimension(400, 200));
    try {
        setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame()
                .getIconImage());
    } catch (Throwable e) {
        LOG.error("There is no icon image", e);
    }

    JPanel base = new JPanel();
    base.setBackground(Color.WHITE);
    base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

    // Icono del titulo
    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING));
    title.setOpaque(false);
    final JLabel labelTitle = new JLabel(i18n.getString("window.route.title"),
            LogicConstants.getIcon("tittleventana_icon_calcularruta"), JLabel.LEFT);
    labelTitle.setFont(LogicConstants.deriveBoldFont(12.0f));
    title.add(labelTitle);
    base.add(title);

    JPanel content = new JPanel(new SpringLayout());
    content.setOpaque(false);

    // Coordenadas
    content.add(new JLabel(i18n.getString("window.route.origen"), JLabel.LEFT));
    JPanel coords = new JPanel(new GridLayout(1, 2));
    coords.setOpaque(false);
    fx = new JTextField(8);
    fx.setEditable(false);
    fy = new JTextField(8);
    fy.setEditable(false);
    coords.add(fy);
    coords.add(fx);
    content.add(coords);
    content.add(new JLabel(i18n.getString("window.route.destino"), JLabel.LEFT));
    JPanel coords2 = new JPanel(new GridLayout(1, 2));
    coords2.setOpaque(false);
    tx = new JTextField(8);
    tx.setEditable(false);
    ty = new JTextField(8);
    ty.setEditable(false);
    coords2.add(ty);
    coords2.add(tx);
    content.add(coords2);

    SpringUtilities.makeCompactGrid(content, 2, 2, 6, 6, 6, 6);
    base.add(content);

    // Area para mensajes
    JPanel notificationArea = new JPanel();
    notificationArea.setOpaque(false);
    notification = new JLabel("PLACEHOLDER");
    notification.setForeground(Color.WHITE);
    notificationArea.add(notification);
    base.add(notificationArea);

    JPanel buttons = new JPanel();
    buttons.setOpaque(false);
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
    search = new JButton(i18n.getString("window.route.calcular"),
            LogicConstants.getIcon("ventanacontextual_button_calcularruta"));
    search.addActionListener(this);
    buttons.add(search);
    clear = new JButton(i18n.getString("window.route.limpiar"), LogicConstants.getIcon("button_limpiar"));
    clear.addActionListener(this);
    buttons.add(clear);
    buttons.add(Box.createHorizontalGlue());
    progressIcon = new JLabel(iconTransparente);
    buttons.add(progressIcon);
    buttons.add(Box.createHorizontalGlue());
    JButton cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel"));
    cancel.addActionListener(this);
    buttons.add(cancel);
    base.add(buttons);
    getContentPane().add(base);
    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);
    }
}

From source file:es.emergya.ui.gis.ControlPanel.java

public ControlPanel(final CustomMapView view) {
    super(new FlowLayout(FlowLayout.LEADING, 12, 0));
    this.view = view;
    // Posicion: panel con un label de icono y un textfield
    JPanel posPanel = new JPanel();
    posPanel.setOpaque(true);
    posPanel.setVisible(true);/* www .ja v a 2 s. co m*/
    JLabel mouseLocIcon = new JLabel(LogicConstants.getIcon("map_icon_coordenadas"));
    posPanel.add(mouseLocIcon);
    final JTextField posField = new JTextField(15);
    posField.setEditable(false);
    posField.setBorder(null);
    posField.setForeground(UIManager.getColor("Label.foreground"));
    posField.setFont(UIManager.getFont("Label.font"));
    posPanel.add(posField);
    view.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
            LatLon ll = ((ICustomMapView) e.getSource()).getLatLon(e.getX(), e.getY());
            String position = "";
            String format = LogicConstants.get("FORMATO_COORDENADAS_MAPA", "UTM");
            if (format.equals(LogicConstants.COORD_UTM)) {
                UTM u = new UTM(LogicConstants.getInt("ZONA_UTM"));
                EastNorth en = u.latlon2eastNorth(ll);
                position = String.format("x: %.1f y: %.1f", en.getX(), en.getY());
            } else {
                position = String.format("Lat: %.4f Lon: %.4f", ll.lat(), ll.lon());
            }

            posField.setText(position);
            validate();
        }

        @Override
        public void mouseDragged(MouseEvent e) {
        }
    });
    posPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    add(posPanel);

    // Panel de centrado: label, desplegable y parte cambiante
    JPanel centerPanel = new JPanel();
    centerPanel.add(new JLabel(i18n.getString("map.centerIn")));
    centerOptions = new JComboBox(new String[] { i18n.getString("map.street"), i18n.getString("map.resource"),
            i18n.getString("map.incidence"), i18n.getString("map.location") });
    centerPanel.add(centerOptions);

    centerData = new JPanel(new CardLayout());
    centerPanel.add(centerData);

    JPanel centerStreet = new JPanel();
    street = new JTextField(30);
    street.setName(i18n.getString("map.street"));
    autocompleteKeyListener = new AutocompleteKeyListener(street);
    street.addKeyListener(autocompleteKeyListener);
    street.addActionListener(this);
    centerStreet.add(street);
    centerData.add(centerStreet, i18n.getString("map.street"));

    JPanel centerResource = new JPanel();
    resources = new JComboBox(avaliableResources);
    resources.setName(i18n.getString("map.resource"));
    resources.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    resources.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            isComboResourcesShowing = true;
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            isComboResourcesShowing = false;
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // view.repaint();
        }
    });
    centerResource.add(resources);
    centerData.add(centerResource, i18n.getString("map.resource"));

    centerResource = new JPanel();
    incidences = new JComboBox(avaliableIncidences);
    incidences.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    incidences.setName(i18n.getString("map.incidence"));
    incidences.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            isComboIncidencesShowing = true;
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            isComboIncidencesShowing = false;
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {

        }
    });
    centerResource.add(incidences);
    centerData.add(centerResource, i18n.getString("map.incidence"));

    JPanel centerLocation = new JPanel();
    cx = new JTextField(10);
    cx.setName("x");
    cx.addActionListener(this);
    centerLocation.add(cx);
    cy = new JTextField(10);
    cy.setName("y");
    cy.addActionListener(this);
    centerLocation.add(cy);
    centerData.add(centerLocation, i18n.getString("map.location"));

    centerOptions.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            ((CardLayout) centerData.getLayout()).show(centerData, (String) e.getItem());
        }
    });

    JButton centerButton = new JButton(i18n.getString("map.center"));
    centerButton.addActionListener(this);
    centerPanel.add(centerButton);
    add(centerPanel);

}

From source file:aurelienribon.gdxsetupui.ui.panels.LibrarySelectionPanel.java

private void buildLibraryPanel(final String libraryName) {
    ActionListener nameChkAL = new ActionListener() {
        @Override//w  w  w  .j  a  va  2s  .  c  om
        public void actionPerformed(ActionEvent e) {
            if (((CompactCheckBox) e.getSource()).isSelected()) {
                if (!Ctx.cfgSetup.libraries.contains(libraryName))
                    Ctx.cfgSetup.libraries.add(libraryName);
                if (!Ctx.cfgUpdate.libraries.contains(libraryName))
                    Ctx.cfgUpdate.libraries.add(libraryName);
            } else {
                Ctx.cfgSetup.libraries.remove(libraryName);
                Ctx.cfgUpdate.libraries.remove(libraryName);
            }

            Ctx.fireCfgSetupChanged();
            Ctx.fireCfgUpdateChanged();
        }
    };

    Action infoAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showInfo(libraryName);
        }
    };
    Action browseAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            browse(libraryName);
        }
    };
    Action getStableAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getStable(libraryName);
        }
    };
    Action getLatestAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getLatest(libraryName);
        }
    };

    LibraryDef def = Ctx.libs.getDef(libraryName);

    CompactCheckBox nameChk = new CompactCheckBox(def.name + " ");
    JLabel html5Label = new JLabel(Res.getImage("gfx/ic_html5.png"));
    JButton infoBtn = new JButton(infoAction);
    JButton browseBtn = new JButton(browseAction);
    JButton getStableBtn = new JButton(getStableAction);
    JButton getLatestBtn = new JButton(getLatestAction);

    nameChk.addActionListener(nameChkAL);
    nameChk.setForeground(LIB_NOTFOUND_COLOR);
    html5Label.setToolTipText("Compatible with HTML backend");
    infoBtn.setIcon(Res.getImage("gfx/ic_info.png"));
    browseBtn.setIcon(Res.getImage("gfx/ic_browse.png"));
    getStableBtn.setIcon(Res.getImage("gfx/ic_download_stable.png"));
    getLatestBtn.setIcon(Res.getImage("gfx/ic_download_nightlies.png"));
    infoBtn.setFocusable(false);
    browseBtn.setFocusable(false);
    getStableBtn.setFocusable(false);
    getLatestBtn.setFocusable(false);

    JToolBar toolBar = new JToolBar();
    toolBar.setOpaque(false);
    toolBar.setFloatable(false);
    toolBar.add(Box.createHorizontalGlue());
    toolBar.add(infoBtn);
    toolBar.add(browseBtn);
    if (def.stableUrl != null)
        toolBar.add(getStableBtn);
    else
        toolBar.add(Box.createHorizontalStrut(libgdxGetStableBtn.getPreferredSize().width));
    if (def.latestUrl != null)
        toolBar.add(getLatestBtn);
    else
        toolBar.add(Box.createHorizontalStrut(libgdxGetNightliesBtn.getPreferredSize().width));

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.setOpaque(false);
    leftPanel.add(nameChk, BorderLayout.CENTER);
    if (def.gwtModuleName != null)
        leftPanel.add(html5Label, BorderLayout.EAST);

    JPanel panel = new JPanel(new BorderLayout());
    panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
    panel.setOpaque(false);
    panel.add(leftPanel, BorderLayout.WEST);
    panel.add(toolBar, BorderLayout.CENTER);

    librariesPanel.add(panel);

    Style.apply(librariesPanel, style);
    libsNamesCmps.put(libraryName, nameChk);
}

From source file:livecanvas.mesheditor.MeshEditor.java

private JToolBar createToolBar() {
    JToolBar toolbar = new JToolBar();
    JButton button;// ww w.  j  a  v  a 2s  .c  o m
    toolbar.add(Utils.createToolBarButton("New mesh", new ImageIcon(clazz.getResource("res/new.png")),
            ButtonType.ICON_ONLY, NEW, "New", this));
    toolbar.add(Utils.createToolBarButton("Open", new ImageIcon(clazz.getResource("res/open.png")),
            ButtonType.ICON_ONLY, OPEN, "Open a saved mesh", this));
    toolbar.add(Utils.createToolBarButton("Save", new ImageIcon(clazz.getResource("res/save.png")),
            ButtonType.ICON_ONLY, SAVE, "Save mesh", this));
    toolbar.addSeparator();
    toolbar.add(Utils.createToolBarButton("Cut", new ImageIcon(clazz.getResource("res/cut.png")),
            ButtonType.ICON_ONLY, CUT, "Cut selection to clipboard", this));
    toolbar.add(Utils.createToolBarButton("Copy", new ImageIcon(clazz.getResource("res/copy.png")),
            ButtonType.ICON_ONLY, COPY, "Copy selection to clipboard", this));
    toolbar.add(Utils.createToolBarButton("Paste", new ImageIcon(clazz.getResource("res/paste.png")),
            ButtonType.ICON_ONLY, PASTE, "Paste content from clipboard", this));
    toolbar.addSeparator();
    toolbar.add(Utils.createToolBarButton("Undo", new ImageIcon(clazz.getResource("res/undo.png")),
            ButtonType.ICON_ONLY, UNDO, "Undo last action", this));
    toolbar.add(Utils.createToolBarButton("Redo", new ImageIcon(clazz.getResource("res/redo.png")),
            ButtonType.ICON_ONLY, REDO, "Redo last undone action", this));
    toolbar.addSeparator();
    JPanel rendererSelectContainer = new JPanel();
    rendererSelectContainer.setOpaque(false);
    rendererSelectContainer.setMaximumSize(new Dimension(150, 40));
    rendererSelectContainer.add(rendererSelect = new JComboBox(Style.Styles));
    rendererSelect.setSelectedIndex(Style.Styles.length - 1);
    toolbar.add(rendererSelectContainer);
    toolbar.add(Utils.createToolBarButton("Render Settings",
            new ImageIcon(clazz.getResource("res/render_settings.png")), ButtonType.ICON_ONLY, RENDER_SETTINGS,
            "Render Settings", this));
    toolbar.add(Utils.createToolBarButton("Render", new ImageIcon(clazz.getResource("res/render.png")),
            ButtonType.ICON_ONLY, RENDER, "Render mesh using current style", this));
    return toolbar;
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapImgGenerator.java

private JPanel initCell(String color, int x, int y) {
    JPanel cell = new JPanel();
    cell.setSize(50, 50);/*w  w  w .  java 2s  .c  om*/
    Color c;
    if (color.contains("#")) {
        c = Color.decode(color);
    } else if (color.toLowerCase().contains("rgb")) {
        String rgb = color.toLowerCase().replace("rgb", "").replace("(", "").replace(")", "").replace(" ", "");
        String[] stringRGBArr = rgb.split(",");
        c = new Color(Integer.valueOf(stringRGBArr[0]), Integer.valueOf(stringRGBArr[1]),
                Integer.valueOf(stringRGBArr[2]));
    } else {
        c = Color.RED;
    }

    cell.setBackground(c);
    cell.setOpaque(true);
    cell.setLocation(x, y);
    cell.setBorder(new LineBorder(Color.WHITE));
    return cell;

}