Example usage for javax.swing JDialog setBackground

List of usage examples for javax.swing JDialog setBackground

Introduction

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

Prototype

@Override
public void setBackground(Color bgColor) 

Source Link

Usage

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

private void inicializar(final String texto) {
    log.trace("inicializar(" + texto + ")");
    final Message message_ = this;

    SwingUtilities.invokeLater(new Runnable() {

        @Override/*from w  ww.  jav a  2 s.  com*/
        public void run() {
            log.trace("Sacamos un nuevo mensaje: " + texto);
            JDialog frame = new JDialog(window.getFrame(), true);
            frame.setUndecorated(true);
            frame.getContentPane().setBackground(Color.WHITE);
            frame.setLocation(150, window.getHeight() - 140);
            frame.setSize(new Dimension(window.getWidth() - 160, 130));
            frame.setName("Incoming Message");
            frame.setBackground(Color.WHITE);
            frame.getRootPane().setBorder(new MatteBorder(4, 4, 4, 4, color));

            frame.setLayout(new BorderLayout());
            if (font != null)
                frame.setFont(font);

            JLabel icon = new JLabel(new ImageIcon(this.getClass().getResource("/images/button-ok.png")));
            icon.setToolTipText("Cerrar");

            icon.removeMouseListener(null);
            icon.addMouseListener(new Cerrar(frame, message_));

            JLabel text = new JLabel(texto);
            text.setBackground(Color.WHITE);
            text.setForeground(Color.BLACK);
            frame.add(text, BorderLayout.WEST);
            frame.add(icon, BorderLayout.EAST);

            frame.setVisible(true);
        }
    });
}

From source file:ro.nextreports.designer.action.chart.PreviewChartAction.java

public void actionPerformed(ActionEvent event) {

    executorThread = new Thread(new Runnable() {

        public void run() {

            if (ChartUtil.chartUndefined(chart)) {
                return;
            }//from w  w w  . j  a  v a 2 s.com

            ParametersBean pBean = NextReportsUtil.selectParameters(chart.getReport(), null);
            if (pBean == null) {
                return;
            }

            UIActivator activator = new UIActivator(Globals.getMainFrame(),
                    I18NSupport.getString("preview.chart.execute"));
            activator.start(new PreviewStopAction());

            ChartWebServer webServer = ChartWebServer.getInstance();
            String webRoot = webServer.getWebRoot();

            ChartRunner runner = new ChartRunner();
            runner.setFormat(chartRunnerType);
            runner.setGraphicType(chartGraphicType);
            runner.setChart(chart);
            runner.setQueryTimeout(Globals.getQueryTimeout());
            runner.setParameterValues(pBean.getParamValues());
            I18nLanguage language = I18nUtil.getDefaultLanguage(chart);
            if (language != null) {
                runner.setLanguage(language.getName());
            }
            if (ChartRunner.IMAGE_FORMAT.equals(runner.getFormat())) {
                runner.setImagePath(Globals.USER_DATA_DIR + "/reports");
            }
            Connection con = null;
            try {
                DataSource runDS = Globals.getChartLayoutPanel().getRunDataSource();
                boolean csv = runDS.getDriver().equals(CSVDialect.DRIVER_CLASS);
                con = Globals.createTempConnection(runDS);
                runner.setConnection(con, csv);
                if (ChartRunner.IMAGE_FORMAT.equals(runner.getFormat())) {
                    runner.run();
                    JDialog dialog = new JDialog(Globals.getMainFrame(), "");
                    dialog.setBackground(Color.WHITE);
                    dialog.setLayout(new BorderLayout());
                    ShowImagePanel panel = new ShowImagePanel(runner.getChartImageAbsolutePath());
                    dialog.add(panel, BorderLayout.CENTER);
                    dialog.pack();
                    dialog.setResizable(false);
                    Show.centrateComponent(Globals.getMainFrame(), dialog);
                    dialog.setVisible(true);
                } else {
                    String jsonFile = "data.json";
                    if (ChartRunner.HTML5_TYPE == runner.getGraphicType()) {
                        jsonFile = "data-html5.json";
                    }
                    OutputStream outputStream = new FileOutputStream(webRoot + File.separatorChar + jsonFile);
                    boolean result = runner.run(outputStream);
                    outputStream.close();
                    if (result) {
                        if (!webServer.isStarted()) {
                            webServer.start();
                        }
                        if (ChartRunner.HTML5_TYPE == runner.getGraphicType()) {
                            FileUtil.openUrl(
                                    "http://localhost:" + Globals.getChartWebServerPort() + "/chart-html5.html",
                                    PreviewChartAction.class);
                        } else {
                            FileUtil.openUrl("http://localhost:" + Globals.getChartWebServerPort()
                                    + "/chart.html?ofc=data.json", PreviewChartAction.class);
                        }
                    }
                }

            } catch (NoDataFoundException e) {
                Show.info(I18NSupport.getString("run.nodata"));
            } catch (InterruptedException e) {
                Show.dispose(); // close a possible previous dialog message
                Show.info(I18NSupport.getString("preview.cancel"));
            } catch (Exception e) {
                e.printStackTrace();
                Show.error(e);
            } finally {
                if (con != null) {
                    try {
                        con.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                        LOG.error(e.getMessage(), e);
                    }
                }
                stop = false;
                if (activator != null) {
                    activator.stop();
                    activator = null;
                }

                // restore old parameters if chart was runned from tree
                if (oldParameters != null) {
                    ParameterManager.getInstance().setParameters(oldParameters);
                }
            }
        }
    }, "NEXT : " + getClass().getSimpleName());
    executorThread.setPriority(EngineProperties.getRunPriority());
    executorThread.start();
}

From source file:ro.nextreports.designer.wizpublish.SelectEntityWizardPanel.java

private void add() {
    // ignore double click listener for tree (which opens the query)
    // and create our own listener (which just selects the path)
    final DBBrowserTree dbBrowserTree = new DBBrowserTree(type, false);
    dbBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    dbBrowserTree.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            job(e, true);/*  ww  w .ja v a  2s .  c  o m*/
        }

        public void mouseReleased(MouseEvent e) {
            job(e, false);
        }

        private void job(MouseEvent e, boolean pressed) {
            TreePath[] paths = dbBrowserTree.getSelectionPaths();
            if (paths == null) {
                return;
            }
            dbBrowserTree.setSelectionPaths(paths);
        }
    });
    JScrollPane scroll = new JScrollPane(dbBrowserTree);
    scroll.setPreferredSize(scrTreeDim);

    JPanel panel = new JPanel();
    panel.add(scroll);

    JDialog dialog = new BaseDialog(panel, I18NSupport.getString("wizard.publish.entities.select"), true) {
        protected boolean ok() {
            TreePath[] paths = dbBrowserTree.getSelectionPaths();
            if (paths == null) {
                return false;
            }
            for (TreePath selPath : paths) {
                final DBBrowserNode selectedNode = (DBBrowserNode) selPath.getLastPathComponent();
                if (!selectedNode.getDBObject().isFolder()) {
                    String path = selectedNode.getDBObject().getAbsolutePath();
                    if (!listModel.contains(path)) {
                        // convert xml if needed before add to list
                        if (selectedNode.getDBObject().getType() == DBObject.REPORTS) {
                            byte result = ConverterUtil.convertIfNeeded(path);
                            if (result != ConverterUtil.TYPE_CONVERSION_EXCEPTION) {
                                listModel.addElement(path);
                            }
                        } else {
                            listModel.addElement(path);
                        }
                    }
                }
            }
            return true;
        }
    };
    dialog.setBackground(Color.WHITE);
    dialog.pack();
    Show.centrateComponent(Globals.getMainFrame(), dialog);
    dialog.setVisible(true);
}