Example usage for javax.swing JFrame setTitle

List of usage examples for javax.swing JFrame setTitle

Introduction

In this page you can find the example usage for javax.swing JFrame setTitle.

Prototype

public void setTitle(String title) 

Source Link

Document

Sets the title for this frame to the specified string.

Usage

From source file:vteaexploration.plottools.panels.XYChartPanel.java

public void process(int x, int y, int l, String xText, String yText, String lText) {

    chartPanel = createChart(x, y, l, xText, yText, lText, imageGateOutline);
    JFrame f = new JFrame(title);
    f.setTitle(title);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new BorderLayout(0, 5));
    f.add(chartPanel, BorderLayout.CENTER);

    chartPanel.setOpaque(false);//from w  w w  . ja  va2 s.c  o  m
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    chartPanel.setPreferredSize(new Dimension(550, 485));
    chartPanel.setBackground(new Color(0, 0, 0, 0));
    chartPanel.revalidate();
    chartPanel.repaint();
    //chartPanel.set

    chartPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent cme) {
            chartPanel.getParent().repaint();
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
        }
    });

    chartPanel.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseDragged(MouseEvent e) {
            chartPanel.getParent().repaint();

        }

        @Override
        public void mouseMoved(MouseEvent e) {
            chartPanel.getParent().repaint();
        }
    });

    chartPanel.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

    });
    f.pack();
}

From source file:flexflux.analyses.result.PP2DResult.java

public void plot() {

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

    // one chart by group

    Map<Integer, Integer> correspGroup = new HashMap<Integer, Integer>();

    XYSeriesCollection dataset = new XYSeriesCollection();
    int index = 0;
    XYSeries series = new XYSeries("");
    for (double point : fluxValues) {

        series.add(point, resultValues.get(point));
        correspGroup.put(index, pointIndex.get(point));

        index++;/*w  ww  .j av a 2  s . c  o m*/
    }

    dataset.addSeries(series);

    if (!expValues.isEmpty()) {
        XYSeries expSeries = new XYSeries("Experimental values");
        if (!expValues.isEmpty()) {
            for (Double d : expValues.keySet()) {
                for (Double d2 : expValues.get(d)) {
                    expSeries.add(d, d2);
                }
            }
        }

        dataset.addSeries(expSeries);
    }

    final JFreeChart chart = ChartFactory.createXYLineChart("", // chart
            // title
            reacName, // domain axis label
            objName, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.GRAY);

    XYLineAndShapeRenderer renderer = new MyRenderer(true, false, correspGroup);

    plot.setRenderer(0, renderer);

    if (!expValues.isEmpty()) {
        renderer.setSeriesLinesVisible(1, false);
        renderer.setSeriesShapesVisible(1, true);
        renderer.setSeriesPaint(1, Color.BLUE);
    }

    ChartPanel chartPanel = new ChartPanel(chart);

    panel.add(chartPanel);

    JPanel fvaPanel = new JPanel();
    fvaPanel.setLayout(new BoxLayout(fvaPanel, BoxLayout.PAGE_AXIS));

    for (int i = 1; i <= groupIndex.size(); i++) {

        Color color = COLORLIST[i % COLORLIST.length];

        JPanel groupPanel = new JPanel();
        groupPanel.setLayout(new BoxLayout(groupPanel, BoxLayout.PAGE_AXIS));

        List<BioEntity> newEssentialReactions = comparator.getNewEssentialEntities().get(i);

        List<BioEntity> noLongerEssentialReactions = comparator.getNoLongerEssentialEntities().get(i);

        JPanel colorPanel = new JPanel();

        colorPanel.setBackground(color);

        groupPanel.add(colorPanel);
        groupPanel.add(new JLabel(
                "Phenotypic phase " + i + ", " + newEssentialReactions.size() + " new essential reactions"));

        fvaPanel.add(groupPanel);

        if (newEssentialReactions.size() > 0) {
            fvaPanel.add(new JScrollPane(comparator.getNewEssentialEntitiesPanel().get(i)));
        }

        fvaPanel.add(new JLabel("Phenotypic phase " + i + ", " + noLongerEssentialReactions.size()
                + " no longer essential reactions"));

        if (noLongerEssentialReactions.size() > 0) {
            fvaPanel.add(fvaPanel.add(new JScrollPane(comparator.getNoLongerEssentialEntitiesPanel().get(i))));
        }

    }

    JScrollPane fvaScrollPane = new JScrollPane(fvaPanel);

    JFrame frame = new JFrame("Phenotypic phase analysis results");

    if (expValues.size() > 0) {
        frame.setTitle("Pareto analysis two dimensions results");
    }

    if (groupIndex.size() > 0) {

        JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, fvaScrollPane);
        frame.setContentPane(splitPane);
        frame.setSize(600, 1000);

    } else {
        frame.setContentPane(panel);
        frame.setSize(600, 600);
    }

    panel.setPreferredSize(new Dimension(600, 600));
    panel.setMinimumSize(new Dimension(600, 600));

    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);

}

From source file:cc.siara.csv_ml_demo.MultiLevelCSVSwingDemo.java

/**
 * Constructor that adds components to the container, sets layout and opens
 * with window//from  w  ww .j  a v a2  s  .c o  m
 * 
 * @param container
 */
public MultiLevelCSVSwingDemo(Container container) {
    if (container == null)
        container = this;
    if (container instanceof JFrame) {
        JFrame frame = (JFrame) container;
        frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        frame.setLocationByPlatform(true);
        frame.setTitle("Demonstration of Multi-level CSV parsing (csv_ml)");
    }
    container.setSize(800, 600);
    container.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 6));
    container.add(lblInput);
    container.add(cbExamples);
    container.add(lblInputSize);
    container.add(tfInputSize);
    container.add(lblDelimiter);
    container.add(cbDelimiter);
    container.add(tfDelimiter);
    container.add(btnAbout);
    container.add(taInputScroll);
    container.add(lblOutput);
    container.add(btnDDLDML);
    container.add(btnJSON);
    container.add(btnXML);
    container.add(btnXPath);
    container.add(tfXPath);
    container.add(cbPretty);
    container.add(taOutputScroll);
    container.add(lblOutputSize);
    container.add(tfOutputSize);
    container.add(btnToCSV);
    container.add(lblJDBCURL);
    container.add(tfDBURL);
    container.add(btnRunDDL);
    container.add(lblID);
    container.add(tfID);
    container.add(btnGetData);
    JTextField tfID = new JTextField("1", 4);
    taInput.setBorder(BorderFactory.createLineBorder(getForeground()));
    taOutput.setBorder(BorderFactory.createLineBorder(getForeground()));
    setInputText();
    cbExamples.addActionListener(this);
    cbDelimiter.addActionListener(this);
    btnAbout.addActionListener(this);
    btnXML.addActionListener(this);
    btnDDLDML.addActionListener(this);
    btnJSON.addActionListener(this);
    btnToCSV.addActionListener(this);
    btnXPath.addActionListener(this);
    btnRunDDL.addActionListener(this);
    btnGetData.addActionListener(this);
    taInput.addKeyListener(new KeyListener() {
        public void keyTyped(KeyEvent arg0) {
            isInputChanged = true;
        }

        public void keyReleased(KeyEvent arg0) {
        }

        public void keyPressed(KeyEvent arg0) {
        }
    });
    tfInputSize.setEditable(false);
    tfOutputSize.setEditable(false);
    setVisible(true);
}

From source file:view.ResultsPanel.java

public void showHistogram(List<ElementaryMode> modes) {

    //for the JTable
    DefaultTableModel tableModel = new DefaultTableModel();
    JTable tableResult = new JTable();
    tableResult.setModel(tableModel);//from  www  .j  a  va2  s  .  c om

    tableModel.addColumn("Reaction");
    tableModel.addColumn("Presence in the modes");

    tableResult.setAutoCreateRowSorter(true);

    Map<Reaction, Double> stats = new HashMap<Reaction, Double>();

    DecimalFormat df = new DecimalFormat("0.00");

    for (ElementaryMode em : modes) {
        for (Reaction r : em.getContent().keySet()) {
            if (em.getContent().containsKey(r)) {
                if (!stats.containsKey(r)) {
                    stats.put(r, 1.0);
                } else {
                    Reaction key = r;
                    Double value = stats.get(r) + 1;
                    stats.remove(key);
                    stats.put(key, value);
                }
            }
        }
    }

    for (Reaction r : stats.keySet()) {
        tableModel
                .addRow(new Object[] { r, String.valueOf(df.format(stats.get(r) * 100 / modes.size())) + "%" });
    }

    JFrame statisticFrame = new JFrame();
    statisticFrame.add(new JScrollPane(tableResult), BorderLayout.CENTER);
    statisticFrame.setVisible(true);
    statisticFrame.setSize(400, 350);
    statisticFrame.setTitle("Representativeness of each reaction");
    statisticFrame.setLocation(500, 600);

    //histogram
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Map<Integer, Integer> data = new TreeMap<Integer, Integer>();
    int maxSize = 0;
    for (ElementaryMode em : modes) {
        int modeLength = em.getContent().size();
        if (modeLength > maxSize) {
            maxSize = modeLength;
        }
        if (data.containsKey(modeLength)) {
            int value = data.get(modeLength) + 1;
            data.put(modeLength, value);
        } else {
            data.put(modeLength, 1);
        }
    }

    for (int i = 1; i < maxSize; i++) {
        if (!data.containsKey(i)) {
            data.put(i, 0);
        }
    }
    for (int key : data.keySet()) {
        dataset.addValue(Integer.valueOf((data.get(key))), "test", Integer.valueOf(key));
    }

    String plotTitle = "Number of reactions per elementary mode";
    String xaxis = "Reaction number";
    String yaxis = "Elementary mode number";
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createBarChart3D(plotTitle, xaxis, yaxis, dataset, orientation, show,
            toolTips, urls);

    CategoryPlot plot = chart.getCategoryPlot();
    CategoryAxis axis = plot.getDomainAxis();

    plot.getDomainAxis(0).setLabelFont(plot.getDomainAxis().getLabelFont().deriveFont(new Float(11)));

    ChartFrame frame = new ChartFrame("Elementary modes", chart);
    frame.setVisible(true);
    frame.setSize(400, 350);
    frame.setLocation(500, 100);

}

From source file:it.unifi.rcl.chess.traceanalysis.gui.TracePanel.java

private void plotTrace() {
    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries xyBoundsPositive = null;//from  w  w w  . jav  a  2  s.c o  m
    XYSeries xyBoundsNegative = null;
    Trace[] posNeg = null;

    dataset.addSeries(Plotter.traceToSeries(trace));
    dataset.addSeries(Plotter.valueToSeries(trace.getMax(), "Max", trace.getSampleSize()));
    dataset.addSeries(Plotter.valueToSeries(trace.getAverage(), "Average", trace.getSampleSize()));
    dataset.addSeries(Plotter.valueToSeries(trace.getMin(), "Min", trace.getSampleSize()));

    int rows = tableWindowSize.getRowCount();
    double coverage;
    int wsize;
    for (int i = 0; i < rows; i++) {
        try {
            wsize = (Integer) tableWindowSize.getValueAt(i, 0);
            coverage = (Double) tableWindowSize.getValueAt(i, 1);

            if (trace.hasNegativeValues()) {
                posNeg = trace.splitPositiveNegative();
                xyBoundsPositive = Plotter.arrayToSeries(posNeg[0].getDynamicBound(coverage, wsize),
                        "c=" + coverage + ",w=" + wsize, wsize - 1);
                xyBoundsNegative = Plotter.arrayToSeriesInvert(posNeg[1].getDynamicBound(coverage, wsize),
                        "c=" + coverage + ",w=" + wsize + "(neg)", wsize - 1);
                dataset.addSeries(xyBoundsPositive);
                dataset.addSeries(xyBoundsNegative);
            } else {
                dataset.addSeries(Plotter.arrayToSeries(trace.getDynamicBound(coverage, wsize),
                        "c=" + coverage + ",w=" + wsize, wsize - 1));
            }
        } catch (NullPointerException e) {
            //Ignore: cell value is null
            ;
        }
    }

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(trace.getName(),
            // Title
            "Time Point",
            // x-axis Labels
            "Value",
            // y-axis Label
            dataset,
            // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true,
            // Show Legend
            true,
            // Use tooltips
            false
    // Configure chart to generate URLs?
    );

    chart.setBackgroundPaint(Color.WHITE);
    chart.getXYPlot().setBackgroundPaint(ChartColor.VERY_LIGHT_YELLOW);
    chart.getXYPlot().setBackgroundAlpha(0.05f);
    chart.getXYPlot().setRangeGridlinePaint(Color.LIGHT_GRAY);
    chart.getXYPlot().setDomainGridlinePaint(Color.LIGHT_GRAY);

    chart.getTitle().setFont(new Font("Dialog", Font.BOLD, 14));

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setDrawSeriesLineAsPath(true);
    chart.getXYPlot().setRenderer(renderer);

    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesPaint(1, ChartColor.DARK_BLUE);
    renderer.setSeriesPaint(2, ChartColor.DARK_GRAY);
    renderer.setSeriesPaint(3, ChartColor.DARK_BLUE);
    renderer.setSeriesPaint(4, ChartColor.RED);

    int nSeries = chart.getXYPlot().getSeriesCount();
    for (int i = 0; i < nSeries; i++) {
        renderer.setSeriesShapesVisible(i, false);
    }
    if (posNeg != null) {
        renderer.setSeriesVisibleInLegend(5, false);
        renderer.setSeriesPaint(5, renderer.getSeriesPaint(4));
    }

    Stroke plainStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f);

    renderer.setSeriesStroke(0, plainStroke);
    renderer.setSeriesStroke(1, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 3.0f }, 0.0f));
    renderer.setSeriesStroke(2, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 3.0f, 0.5f, 3.0f }, 0.0f));
    renderer.setSeriesStroke(3, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 3.0f }, 0.0f));

    JPanel plotPanel = new ChartPanel(chart);
    JFrame plotFrame = new JFrame();
    plotFrame.add(plotPanel);
    plotFrame.setVisible(true);
    plotFrame.pack();
    plotFrame.setTitle(TracePanel.this.trace.getName());
    plotFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}

From source file:it.unifi.rcl.chess.traceanalysis.gui.TracePanel.java

private void plotCompare() {
    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries xyBoundsPositive = null;//from   w ww  .  ja v a2  s.  c  om
    XYSeries xyBoundsNegative = null;
    Trace[] posNeg = null;

    Component[] siblings = this.getParent().getComponents();
    Trace[] allTraces = new Trace[siblings.length];

    int rows = tableWindowSize.getRowCount();
    double coverage = 0.99;
    int wsize = 100;
    for (int i = 0; i < rows; i++) {
        try {
            wsize = (Integer) tableWindowSize.getValueAt(i, 0);
            coverage = (Double) tableWindowSize.getValueAt(i, 1);
        } catch (NullPointerException e) {
            //Ignore: cell value is null
            ;
        }
    }

    for (int i = 0; i < siblings.length; i++) {
        allTraces[i] = ((TracePanel) siblings[i]).getTrace();

        if (allTraces[i].hasNegativeValues()) {
            posNeg = allTraces[i].splitPositiveNegative();
            xyBoundsPositive = Plotter.arrayToSeries(posNeg[0].getDynamicBound(coverage, wsize),
                    allTraces[i].getName(), wsize - 1);
            xyBoundsNegative = Plotter.arrayToSeriesInvert(posNeg[1].getDynamicBound(coverage, wsize),
                    allTraces[i].getName() + "(neg)", wsize - 1);
            dataset.addSeries(xyBoundsPositive);
            dataset.addSeries(xyBoundsNegative);
        } else {
            dataset.addSeries(Plotter.arrayToSeries(allTraces[i].getDynamicBound(coverage, wsize),
                    allTraces[i].getName(), wsize - 1));
        }
    }

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart("Comparative Plot (c=" + coverage + ",w=" + wsize + ")",
            // Title
            "Time Point",
            // x-axis Labels
            "Value",
            // y-axis Label
            dataset,
            // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true,
            // Show Legend
            true,
            // Use tooltips
            false
    // Configure chart to generate URLs?
    );

    chart.setBackgroundPaint(Color.WHITE);
    chart.getXYPlot().setBackgroundPaint(ChartColor.VERY_LIGHT_YELLOW);
    chart.getXYPlot().setBackgroundAlpha(0.05f);
    chart.getXYPlot().setRangeGridlinePaint(Color.LIGHT_GRAY);
    chart.getXYPlot().setDomainGridlinePaint(Color.LIGHT_GRAY);

    chart.getTitle().setFont(new Font("Dialog", Font.BOLD, 14));

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setDrawSeriesLineAsPath(true);
    chart.getXYPlot().setRenderer(renderer);

    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesPaint(1, ChartColor.DARK_GREEN);
    renderer.setSeriesPaint(2, ChartColor.DARK_BLUE);
    renderer.setSeriesPaint(3, ChartColor.RED);

    int nSeries = chart.getXYPlot().getSeriesCount();
    for (int i = 0; i < nSeries; i++) {
        renderer.setSeriesShapesVisible(i, false);
    }
    if (posNeg != null) {
        renderer.setSeriesVisibleInLegend(5, false);
        renderer.setSeriesPaint(5, renderer.getSeriesPaint(4));
    }

    //      Stroke plainStroke = new BasicStroke(
    //                    1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f
    //                );
    //      
    //      renderer.setSeriesStroke(0, plainStroke);
    //      renderer.setSeriesStroke(1, 
    //            new BasicStroke(
    //                 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 3.0f }, 0.0f
    //             ));
    //      renderer.setSeriesStroke(2, 
    //            new BasicStroke(
    //                 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 3.0f, 0.5f, 3.0f }, 0.0f
    //             ));
    //      renderer.setSeriesStroke(3, 
    //            new BasicStroke(
    //                 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 3.0f }, 0.0f
    //             ));

    JPanel plotPanel = new ChartPanel(chart);
    JFrame plotFrame = new JFrame();
    plotFrame.add(plotPanel);
    plotFrame.setVisible(true);
    plotFrame.pack();
    plotFrame.setTitle(TracePanel.this.trace.getName());
    plotFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}

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

/**
 * Bring up the PPApp demo by showing the frame (only applicable if coming up
 * as an application, not an applet);//from w  ww.j  a va2  s .c  om
 */
public void showApp() {
    JFrame f = getFrame();
    f.setTitle(getTitle());
    f.getContentPane().add(this, BorderLayout.CENTER);
    f.pack();

    f.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            doExit(true);
        }
    });

    UIHelper.centerWindow(f);
    Rectangle r = f.getBounds();
    int x = AppPreferences.getLocalPrefs().getInt("APP.X", r.x);
    int y = AppPreferences.getLocalPrefs().getInt("APP.Y", r.y);
    int w = AppPreferences.getLocalPrefs().getInt("APP.W", r.width);
    int h = AppPreferences.getLocalPrefs().getInt("APP.H", r.height);
    UIHelper.positionAndFitToScreen(f, x, y, w, h);

    f.setVisible(true);
}

From source file:edu.harvard.i2b2.eclipse.LoginView.java

/**
 * This is a callback that will allow us
 * to create the viewer and initialize it.
 *///from   w ww . j  av  a 2 s .co m
@Override
public void createPartControl(final Composite parent) {
    log.info(Messages.getString("LoginView.PluginVersion")); //$NON-NLS-1$

    parent.getShell();
    userInfoBean = UserInfoBean.getInstance();
    if (userInfoBean == null) {
        log.debug("user info bean is null"); //$NON-NLS-1$
        return;
    }

    // local variable to get system fonts and colors
    final Display display = parent.getDisplay();

    /* TODO disabled screensaver */

    user = userInfoBean.getUserName();
    //password = userInfoBean.getOrigPassword();
    project = Application.project;
    new Thread() {
        public void run() {
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (Throwable th) {
                }
                if (display.isDisposed())
                    return;
                display.asyncExec(new Runnable() {
                    public void run() {
                        checkSessionExpired();
                        try {
                            checkScreenSaver(parent.getShell(), Application.getLastUsed()); //display.getActiveShell());
                        } catch (Exception e) {
                            return;
                        }
                    }
                });
            }
        }
    }.start();

    final Font headerFont = new Font(display, "Tahoma", 12, SWT.BOLD); //$NON-NLS-1$
    final Font normalFont = new Font(display, "Tahoma", 12, SWT.NORMAL); //$NON-NLS-1$
    final Font buttonFont = new Font(display, "Tahoma", 9, SWT.NORMAL); //$NON-NLS-1$

    String environment = userInfoBean.getEnvironment();
    if (UserInfoBean.selectedProject().getWiki() != null
            && !UserInfoBean.selectedProject().getWiki().equals("")) //$NON-NLS-1$
        helpURL = UserInfoBean.selectedProject().getWiki();
    //if (userInfoBean.getHelpURL()!=null && !userInfoBean.getHelpURL().equals(""))
    //   helpURL=userInfoBean.getHelpURL();
    // set banner color
    // if environment not specified defaults to development (dark gray)
    APP_CURRENT = environment.toUpperCase();
    if (APP_CURRENT.equals(APP_PROD)) {
        backColor = display.getSystemColor(SWT.COLOR_WHITE);
    } else if (APP_CURRENT.equals(APP_TEST)) {
        backColor = display.getSystemColor(SWT.COLOR_GRAY);
    } else {
        // default to development
        backColor = display.getSystemColor(SWT.COLOR_DARK_GRAY);
    }

    log.info("Currently running in: " + APP_CURRENT); //$NON-NLS-1$
    final Color foreColor = display.getSystemColor(SWT.COLOR_BLACK);
    warningColor = display.getSystemColor(SWT.COLOR_YELLOW);

    goColor = display.getSystemColor(SWT.COLOR_GREEN);
    badColor = display.getSystemColor(SWT.COLOR_RED);

    // create top composite
    top = new Composite(parent, SWT.NONE);

    FormLayout topCompositeLayout = new FormLayout();
    top.setLayout(topCompositeLayout);

    // BannerC composite
    banner = new Composite(top, SWT.NONE);

    FormData bannerData = new FormData();
    bannerData.left = new FormAttachment(0);
    bannerData.right = new FormAttachment(100);
    banner.setLayoutData(bannerData);

    // The Banner itself is configured and layout is set
    FormLayout bannerLayout = new FormLayout();
    bannerLayout.marginWidth = 2;
    if (OS.startsWith("windows")) //$NON-NLS-1$
        bannerLayout.marginHeight = 8;
    else
        bannerLayout.marginHeight = 18;
    bannerLayout.spacing = 5;
    banner.setLayout(bannerLayout);

    banner.setBackground(backColor);
    banner.setForeground(foreColor);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(banner, LOGIN_VIEW_CONTEXT_ID);

    // add banner components and then configure layout
    // the label on the left is added
    titleLabel = new CLabel(banner, SWT.NO_FOCUS);
    titleLabel.setBackground(backColor);
    msTitle = System.getProperty("applicationName") + Messages.getString("LoginView.StatusTitle") //$NON-NLS-1$//$NON-NLS-2$
            + UserInfoBean.selectedProject().getName();
    titleLabel.setText(msTitle);
    titleLabel.setFont(headerFont);
    titleLabel.setForeground(foreColor);
    titleLabel.setImage(new Image(display, LoginView.class.getResourceAsStream("big-hive.gif"))); //$NON-NLS-1$

    // the general application area toolbar is added
    titleToolBar = new ToolBar(banner, SWT.FLAT);
    titleToolBar.setBackground(backColor);
    titleToolBar.setFont(headerFont);

    menu = new Menu(banner.getShell(), SWT.POP_UP);

    // Authorization label is made
    authorizationLabel = new Label(banner, SWT.NO_FOCUS);
    authorizationLabel.setBackground(backColor);
    authorizationLabel.setText(userInfoBean.getUserFullName());
    authorizationLabel.setAlignment(SWT.RIGHT);
    authorizationLabel.setFont(normalFont);
    authorizationLabel.setForeground(foreColor);
    ArrayList<String> roles = (ArrayList<String>) UserInfoBean.selectedProject().getRole();

    String rolesStr = ""; //$NON-NLS-1$
    if (roles != null) {
        for (String param : roles)
            rolesStr += param + "\n"; //$NON-NLS-1$
        if (rolesStr.length() > 1)
            rolesStr = rolesStr.substring(0, rolesStr.length() - 1);
    }
    authorizationLabel.setToolTipText(rolesStr);

    // the staus indicator is shown
    statusLabel = new Label(banner, SWT.NO_FOCUS);
    statusLabel.setBackground(backColor);
    statusLabel.setText(Messages.getString("LoginView.StatusStatus")); //$NON-NLS-1$
    statusLabel.setAlignment(SWT.RIGHT);
    statusLabel.setFont(normalFont);
    statusLabel.setForeground(foreColor);

    statusOvalLabel = new Label(banner, SWT.NO_FOCUS);
    statusOvalLabel.setBackground(backColor);

    statusOvalLabel.setSize(20, 20);
    statusOvalLabel.setForeground(foreColor);
    statusOvalLabel.redraw();

    statusOvalLabel.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event arg0) {
            statusOvalLabel.setSize(20, 20);
            statusOvalLabel.redraw();
        }
    });

    // add selection listener so that clicking on status oval label shows error log
    // dialog
    statusOvalLabel.addListener(SWT.MouseDown, new Listener() {

        public void handleEvent(Event arg0) {
            //log.info(getNow() + "Status Listener Clicked");
            Display display = statusOvalLabel.getDisplay();
            final Shell shell = statusOvalLabel.getShell();
            // run asyncExec so that other pending ui events finished first
            display.asyncExec(new Runnable() {

                public void run() {
                    File file = new File(logFileName);
                    URL url = null;
                    // Convert the file object to a URL with an absolute path
                    try {
                        url = file.toURL();
                    } catch (MalformedURLException e) {
                        log.error(e.getMessage());
                    }
                    final URL myurl = url;
                    new HelpBrowser().run(myurl.toString(), shell);
                }
            });

        }
    });

    // add status label paint listener so that it changes color
    statusLabelPaintListener = new StatusLabelPaintListener();
    statusOvalLabel.addPaintListener(statusLabelPaintListener);
    statusLabelPaintListener.setOvalColor(goColor);

    getCellStatus(statusLabelPaintListener, statusOvalLabel);
    //if (cellStatus == null)
    //   {
    //   statusLabelPaintListener.setOvalColor(goColor);
    //}
    //else
    //   {
    //   statusOvalLabel.setToolTipText(Messages.getString("LoginView.TooltipCellUnavailable") + cellStatus); //$NON-NLS-1$
    //   statusLabelPaintListener.setOvalColor(warningColor);
    //   }

    statusOvalLabel.setSize(20, 20);
    statusOvalLabel.redraw();

    // Help button is made
    final Button rightButton = new Button(banner, SWT.PUSH | SWT.LEFT);
    rightButton.setFont(buttonFont);
    rightButton.setText(Messages.getString("LoginView.StatusWiki")); //$NON-NLS-1$
    if (helpURL.equals("")) { //$NON-NLS-1$
        rightButton.setEnabled(false);
    }
    rightButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            final Button myButton = (Button) event.widget;
            Display display = myButton.getDisplay();
            final Shell myShell = myButton.getShell();
            display.asyncExec(new Runnable() {

                public void run() {
                    new HelpBrowser().run(helpURL, myShell);
                }
            });
        }
    });

    final Button passwordButton = new Button(banner, SWT.PUSH | SWT.LEFT);
    passwordButton.setFont(buttonFont);
    passwordButton.setText("Password");
    passwordButton.setToolTipText("Display Set Password Dialog");
    passwordButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            final Button myButton = (Button) event.widget;
            Display display = myButton.getDisplay();
            //final Shell myShell=myButton.getShell();
            display.asyncExec(new Runnable() {
                public void run() {
                    java.awt.EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            SetPasswordJDialog dialog = new SetPasswordJDialog(new javax.swing.JFrame(), true);
                            dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                                @Override
                                public void windowClosing(java.awt.event.WindowEvent e) {
                                    //System.exit(0);
                                }
                            });
                            dialog.setSize(304, 237);
                            dialog.setLocation(400, 200);
                            dialog.setVisible(true);
                        }
                    });
                }
            });
        }
    });

    // attach titlelabel to left and align vertically with tool bar
    FormData titleLabelFormData = new FormData();

    titleLabelFormData.top = new FormAttachment(titleToolBar, 0, SWT.CENTER);
    titleLabelFormData.left = new FormAttachment(0, 10);
    titleLabel.setLayoutData(titleLabelFormData);

    // attach left of tool bar to title label, attach top to banner
    // attach right to authorization label so that it will resize and remain
    // visible when tool bar text changes
    FormData titleToolBarFormData = new FormData();
    titleToolBarFormData.left = new FormAttachment(titleLabel);
    titleToolBarFormData.top = new FormAttachment(0);
    titleToolBarFormData.right = new FormAttachment(authorizationLabel, 0, 0);

    titleToolBar.setLayoutData(titleToolBarFormData);

    // attach authorization label on right to status label and center
    // vertically

    FormData authorizationLabelFormData = new FormData();
    authorizationLabelFormData.right = new FormAttachment(passwordButton, -10);
    authorizationLabelFormData.top = new FormAttachment(passwordButton, 0, SWT.CENTER);
    authorizationLabel.setLayoutData(authorizationLabelFormData);

    FormData passwordButtonFormData = new FormData();
    passwordButtonFormData.right = new FormAttachment(statusLabel, -10);
    passwordButtonFormData.top = new FormAttachment(statusLabel, 0, SWT.CENTER);
    passwordButton.setLayoutData(passwordButtonFormData);

    FormData statusLabelFormData = new FormData();
    // statusLabelFormData.right = new FormAttachment(rightButton,0);
    statusLabelFormData.right = new FormAttachment(statusOvalLabel, 0);
    statusLabelFormData.top = new FormAttachment(statusOvalLabel, 0, SWT.CENTER);
    statusLabel.setLayoutData(statusLabelFormData);

    // attach status label on right to loginbutton and center vertically

    FormData statusOvalLabelFormData = new FormData();
    //add offset 
    statusOvalLabelFormData.right = new FormAttachment(rightButton, -25);
    statusOvalLabelFormData.top = new FormAttachment(rightButton, 0, SWT.CENTER);
    statusOvalLabel.setLayoutData(statusOvalLabelFormData);

    // attach right button to right of banner and center vertically on
    // toolbar
    FormData rightButtonFormData = new FormData();
    rightButtonFormData.right = new FormAttachment(100, -10);
    rightButtonFormData.top = new FormAttachment(titleToolBar, 0, SWT.CENTER);
    rightButton.setLayoutData(rightButtonFormData);

    //property action
    IAction propertyAction = new Action("Property") { //$NON-NLS-1$
        @Override
        public void run() {
            log.info("[Login view] PM response: " + UserInfoBean.pmResponse()); //$NON-NLS-1$
            JFrame frame = new DisplayXmlMessageDialog(UserInfoBean.pmResponse());
            frame.setTitle(Messages.getString("LoginView.PMXMLResponse")); //$NON-NLS-1$
            frame.setVisible(true);
        }
    };

    getViewSite().getActionBars().setGlobalActionHandler("properties", propertyAction); //$NON-NLS-1$
}

From source file:edu.snu.leader.discrete.simulator.SimulatorLauncherGUI.java

JFrame createJFrameErrorMessages(ErrorPacketContainer errorPackets, JTabbedPane theTabbedPane) {
    JFrame errorMessages = new JFrame();
    JPanel errorMessagesContentPane = new JPanel();

    errorMessages.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    errorMessages.setTitle("Error Messages");
    errorMessages.setBounds(this.getX() + this.getWidth() + 5, this.getY(), 350, 300);
    errorMessagesContentPane = new JPanel();
    errorMessagesContentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    errorMessagesContentPane.setLayout(new BorderLayout(0, 0));
    errorMessages.setContentPane(errorMessagesContentPane);

    JPanel panel = new JPanel();
    errorMessagesContentPane.add(panel, BorderLayout.NORTH);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    for (int i = 0; i < errorPackets.errorMessages.size(); i++) {
        JTextPane temp = createErrorPane(errorPackets.errorMessages.get(i),
                errorPackets.erroredComponents.get(i), theTabbedPane, errorPackets.tabIndexes.get(i));
        panel.add(temp);/*from   ww  w. j  a v  a  2  s  .  c  o m*/
    }

    return errorMessages;
}

From source file:ca.nengo.plot.impl.DefaultPlotter.java

public void doPlotMSE(NEFEnsemble ensemble, DecodedOrigin origin, String name) {
    float[] error = new float[origin.getDimensions()];
    float mseAvg; //MSE for all of the dimensions of the origin together

    JPanel panel = new JPanel();
    JFrame frame = createFrame();
    frame.setVisible(true);// w  w  w. j  a v  a2  s .  c om
    long time = System.currentTimeMillis() - 21;

    //plot MSE on continuously updating graph as more samples are used in the calculation
    for (int i = 1; i == 1 || frame.isVisible(); i++) { //will crash if runtime exceeds 4.1 years
        //synchronized(ensemble){
        error = MU.sum(MU.prod(error, ((i - 1f) / i)), MU.prod(origin.getError(1), 1f / i));
        //}
        mseAvg = MU.mean(error);
        if ((System.currentTimeMillis() - time) > 20l) { //frame limiter
            panel = getBarChart(error, "MSE per Dimension for Origin: " + origin.getName());
            frame.getContentPane().removeAll();
            frame.getContentPane().add(panel, BorderLayout.CENTER);
            frame.setTitle("Origin MSE Plot (Overall MSE=" + mseAvg + ")");
            frame.validate();

            time = System.currentTimeMillis();
        }
        if (i == 1) {
            frame.pack();
            frame.setVisible(true);
        }
    }
}