Example usage for javax.swing BorderFactory createLineBorder

List of usage examples for javax.swing BorderFactory createLineBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createLineBorder.

Prototype

public static Border createLineBorder(Color color) 

Source Link

Document

Creates a line border with the specified color.

Usage

From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java

/**
 * @param fi//from   w  w  w.  j a v  a 2s . c om
 * @return
 */
protected FormPanelInfo createPanel(final FormInfo formInfo) {
    CellConstraints cc = new CellConstraints();

    JPanel panel = new JPanel(null);
    int maxWidth = 0;
    int maxHeight = 0;
    int maxCellWidth = 0;
    int maxCellHeight = 0;
    for (FormFieldInfo fi : formInfo.getFields()) {
        System.out.println(fi.getCaption());
        boolean addLbl = true;
        JComponent comp = null;
        switch (fi.getControlTypeNum()) {
        case 4:
            comp = createComboBox(); // 'Picklist'
            break;

        case 5: {
            JComboBox cbx = createComboBox(); //new ValComboBoxFromQuery(DBTableIdMgr.getInstance().getInfoById(1), "catalogNumber","CatalogNumber","CatalogNumber"," "," "," "," "," ",ValComboBoxFromQuery.CREATE_ALL);// 'QueryCombo'
            cbx.setEditable(true);
            cbx.getEditor().setItem(fi.getCaption());
            JPanel cPanel = new JPanel(new BorderLayout());
            cPanel.add(cbx, BorderLayout.CENTER);
            cPanel.add(createElipseBtn(), BorderLayout.EAST);
            comp = cPanel;
            addLbl = false;
            break;
        }

        case 7: {
            String uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", fi.getParent().getFormType());
            FormInfo subForm = formHash.get(uniqueKey);
            if (subForm == null) {
                uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", null);
                subForm = formHash.get(uniqueKey);
            }
            if (subForm != null) {
                Vector<String> headers = new Vector<String>();
                for (int i = 0; i < subForm.getFields().size(); i++) {
                    headers.add(subForm.getFields().get(i).getCaption());
                }
                JPanel p = new JPanel(new BorderLayout());
                p.add(UIHelper.createScrollPane(new JTable(new Vector<Vector<Object>>(), headers)),
                        BorderLayout.CENTER); // 'Grid'
                comp = p;
                addLbl = false;
            }
            break;
        }

        case 8: // 'EmbeddedForm'
        {
            String uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", fi.getParent().getFormType());
            FormInfo subForm = formHash.get(uniqueKey);
            if (subForm == null) {
                uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", null);
                subForm = formHash.get(uniqueKey);
            }
            comp = (subForm != null ? createPanel(subForm).getPanel() : new JPanel());
            addLbl = fi.getControlTypeNum() != 8;
            break;
        }
        case 9: {
            comp = createElipseBtn();
            break;
        }

        case 20:
            comp = createScrollPane(createTextArea()); // 'Memo'
            break;

        case 21:
            comp = null;//createComboBox(); // 'MenuItem'
            break;

        case 46:
            comp = createTextField("URL"); // 'URL'
            break;

        default:
            if (fi.getDataTypeNum() == 4) {
                comp = createCheckBox(" ");
            } else {
                comp = createTextField();
            }
        } // switch

        if (comp != null) {
            String toolTip = "Field: " + fi.getSp5FieldName()
                    + (StringUtils.isNotEmpty(fi.getSp6FieldName())
                            && fi.getSp6FieldName().equalsIgnoreCase(fi.getSp5FieldName())
                                    ? " Sp6: " + fi.getSp6FieldName()
                                    : "");
            comp.setToolTipText(toolTip);

            PanelBuilder pb = new PanelBuilder(new FormLayout("p,1px,f:p:g", "f:p:g,p,f:p:g"));

            pb.getPanel().setToolTipText(toolTip);
            pb.getPanel().setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
            if (addLbl) {
                pb.add(createLabel(fi.getCaption()), cc.xy(1, 2));
            }
            pb.add(comp, cc.xy(3, 2));
            panel.add(pb.getPanel());

            maxWidth = Math.max(maxWidth, fi.getLeft() + fi.getWidth());
            maxHeight = Math.max(maxHeight, fi.getTop() + fi.getHeight());

            maxCellWidth = Math.max(maxWidth, fi.getCellX() + fi.getCellWidth());
            maxCellHeight = Math.max(maxHeight, fi.getCellY() + fi.getCellHeight());

            boolean newWay = false;
            if (newWay) {
                Rectangle r = fi.getBoundsFromCellDim();
                pb.getPanel().setLocation(r.x, r.y);
                pb.getPanel().setSize(r.width, r.height);

            } else {
                pb.getPanel().setLocation(fi.getLeft(), fi.getTop());
                pb.getPanel().setSize(fi.getWidth(), fi.getHeight());
            }

            System.out.println("MaxW: " + maxWidth + "  " + maxCellWidth);
            System.out.println("MaxH: " + maxHeight + "  " + maxCellHeight);
        }
    }

    boolean newWay = false;
    if (newWay) {
        int cw = FormFieldInfo.getSegWidth();
        panel.setPreferredSize(new Dimension(maxCellWidth * cw, maxCellHeight * cw));
        panel.setSize(new Dimension(maxCellWidth * cw, maxCellHeight * cw));
    } else {
        panel.setPreferredSize(new Dimension(maxWidth, maxHeight));
        panel.setSize(new Dimension(maxWidth, maxHeight));
    }

    System.out.println("MaxW: " + maxWidth + "  " + maxCellWidth);
    System.out.println("MaxH: " + maxHeight + "  " + maxCellHeight);

    return new FormPanelInfo(formInfo.getTitle(), panel, maxWidth, maxHeight);
}

From source file:AtomPanel.java

private void initJFreeChart() {
    this.numOfStream = numOfStream;

    datasets = new TimeSeriesCollection();
    trend = new TimeSeriesCollection();
    projpcs = new TimeSeriesCollection();
    spe = new TimeSeriesCollection();

    for (int i = 0; i < MaxNumOfStream; i++) {
        //add streams
        TimeSeries timeseries = new TimeSeries("Stream " + i, Millisecond.class);
        datasets.addSeries(timeseries);/*  w w  w .ja  v  a2s  . com*/
        timeseries.setHistoryCount(historyRange);
        //add trend variables
        TimeSeries trendSeries = new TimeSeries("Trend " + i, Millisecond.class);
        trend.addSeries(trendSeries);
        trendSeries.setHistoryCount(historyRange);
        //add proj onto PCs variables
        TimeSeries PC = new TimeSeries("Projpcs " + i, Millisecond.class);
        projpcs.addSeries(PC);
        PC.setHistoryCount(historyRange);
        //add spe streams
        TimeSeries speSeries = new TimeSeries("Spe " + i, Millisecond.class);
        spe.addSeries(speSeries);
        speSeries.setHistoryCount(historyRange);
    }
    combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Time"));
    //data stream  plot
    DateAxis domain = new DateAxis("Time");
    NumberAxis range = new NumberAxis("Streams");
    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));

    XYItemRenderer renderer = new DefaultXYItemRenderer();
    renderer.setItemLabelsVisible(false);
    renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot = new XYPlot(datasets, domain, range, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);

    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot);

    //Trend captured by pca
    DateAxis domain0 = new DateAxis("Time");
    NumberAxis range0 = new NumberAxis("PCA Trend");
    domain0.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range0.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain0.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range0.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    XYItemRenderer renderer0 = new DefaultXYItemRenderer();
    renderer0.setItemLabelsVisible(false);
    renderer0.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    renderer0.setSeriesPaint(0, Color.blue);
    renderer0.setSeriesPaint(1, Color.red);
    renderer0.setSeriesPaint(2, Color.magenta);
    XYPlot plot0 = new XYPlot(trend, domain0, range0, renderer0);
    plot0.setBackgroundPaint(Color.lightGray);
    plot0.setDomainGridlinePaint(Color.white);
    plot0.setRangeGridlinePaint(Color.white);
    plot0.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain0.setAutoRange(true);
    domain0.setLowerMargin(0.0);
    domain0.setUpperMargin(0.0);
    domain0.setTickLabelsVisible(false);

    range0.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot0);

    //proj on PCs plot
    DateAxis domain1 = new DateAxis("Time");
    NumberAxis range1 = new NumberAxis("Proj on PCs");
    domain1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain1.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range1.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    XYItemRenderer renderer1 = new DefaultXYItemRenderer();
    renderer1.setItemLabelsVisible(false);
    renderer1.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.blue);
    renderer1.setSeriesPaint(1, Color.red);
    renderer1.setSeriesPaint(2, Color.magenta);
    plot1 = new XYPlot(projpcs, domain1, range1, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);
    plot1.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain1.setAutoRange(true);
    domain1.setLowerMargin(0.0);
    domain1.setUpperMargin(0.0);
    domain1.setTickLabelsVisible(false);

    range1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot1);

    //spe  plot
    DateAxis domain2 = new DateAxis("Time");
    NumberAxis range2 = new NumberAxis("SPE");
    domain2.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range2.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain2.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range2.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));

    XYItemRenderer renderer2 = new DefaultXYItemRenderer();
    renderer2.setItemLabelsVisible(false);
    renderer2.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot2 = new XYPlot(spe, domain2, range2, renderer);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);
    plot2.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain2.setAutoRange(true);
    domain2.setLowerMargin(0.0);
    domain2.setUpperMargin(0.0);
    domain2.setTickLabelsVisible(true);

    range2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot2);

    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(historyRange); // 60 seconds
    JFreeChart chart;
    if (this.pcaType == AtomUtils.PCAType.pca)
        chart = new JFreeChart("CloudWatch-ATOM with Exact Data", new Font("SansSerif", Font.BOLD, 18),
                combineddomainxyplot, false);
    else if (this.pcaType == AtomUtils.PCAType.pcaTrack)
        chart = new JFreeChart("CloudWatch-ATOM with Fixed Tracking Threshold",
                new Font("SansSerif", Font.BOLD, 18), combineddomainxyplot, false);
    else
        chart = new JFreeChart("CloudWatch-ATOM with Dynamic Tracking Threshold",
                new Font("SansSerif", Font.BOLD, 18), combineddomainxyplot, false);
    chart.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    AtomPanel.this.add(chartPanel, BorderLayout.CENTER);
}

From source file:net.rptools.maptool.client.ui.MapToolFrame.java

public MapToolFrame(JMenuBar menuBar) {
    // Set up the frame
    super(AppConstants.APP_NAME);

    this.menuBar = menuBar;

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(this);
    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    SwingUtil.centerOnScreen(this);
    setFocusTraversalPolicy(new MapToolFocusTraversalPolicy());

    try {//ww  w .ja va 2 s .co  m
        setIconImage(ImageUtil.getImage(MINILOGO_IMAGE));
    } catch (IOException ioe) {
        String msg = I18N.getText("msg.error.loadingIconImage");
        log.error(msg, ioe);
        System.err.println(msg);
    }
    // Notify duration
    initializeNotifyDuration();

    // Components
    glassPane = new GlassPane();
    assetPanel = createAssetPanel();
    connectionPanel = createConnectionPanel();
    toolbox = new Toolbox();
    initiativePanel = createInitiativePanel();

    zoneRendererList = new CopyOnWriteArrayList<ZoneRenderer>();
    pointerOverlay = new PointerOverlay();
    colorPicker = new ColorPicker(this);
    textureChooserPanel = new TextureChooserPanel(colorPicker.getPaintChooser(), assetPanel.getModel(),
            "imageExplorerTextureChooser");
    colorPicker.getPaintChooser().addPaintChooser(textureChooserPanel);

    String credits = "";
    String version = "";
    Image logo = null;
    try {
        credits = new String(FileUtil.loadResource(CREDITS_HTML), "UTF-8"); // 2nd param of type Charset is Java6+
        version = MapTool.getVersion();
        credits = credits.replace("%VERSION%", version);
        logo = ImageUtil.getImage(MAPTOOL_LOGO_IMAGE);
    } catch (Exception ioe) {
        log.error(I18N.getText("msg.error.credits"), ioe);
        ioe.printStackTrace();
    }
    aboutDialog = new AboutDialog(this, logo, credits);
    aboutDialog.setSize(354, 400);

    statusPanel = new StatusPanel();
    statusPanel.addPanel(getCoordinateStatusBar());
    statusPanel.addPanel(getZoomStatusBar());
    statusPanel.addPanel(MemoryStatusBar.getInstance());
    // statusPanel.addPanel(progressBar);
    statusPanel.addPanel(connectionStatusPanel);
    statusPanel.addPanel(activityMonitor);
    statusPanel.addPanel(new SpacerStatusBar(25));

    zoneMiniMapPanel = new ZoneMiniMapPanel();
    zoneMiniMapPanel.setSize(100, 100);

    zoneRendererPanel = new JPanel(new PositionalLayout(5));
    zoneRendererPanel.setBackground(Color.black);
    //      zoneRendererPanel.add(zoneMiniMapPanel, PositionalLayout.Position.SE);
    //      zoneRendererPanel.add(getChatTypingLabel(), PositionalLayout.Position.NW);
    zoneRendererPanel.add(getChatTypingPanel(), PositionalLayout.Position.NW);
    zoneRendererPanel.add(getChatActionLabel(), PositionalLayout.Position.SW);

    commandPanel = new CommandPanel();
    MapTool.getMessageList().addObserver(commandPanel);

    rendererBorderPanel = new JPanel(new GridLayout());
    rendererBorderPanel.setBorder(BorderFactory.createLineBorder(Color.darkGray));
    rendererBorderPanel.add(zoneRendererPanel);

    // Put it all together
    setJMenuBar(menuBar);
    add(BorderLayout.NORTH, new ToolbarPanel(toolbox));
    add(BorderLayout.SOUTH, statusPanel);

    JLayeredPane glassPaneComposite = new JLayeredPane();
    glassPaneComposite.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1;
    constraints.weighty = 1;

    glassPaneComposite.add(glassPane, constraints);
    glassPaneComposite.add(dragImageGlassPane, constraints);

    setGlassPane(glassPane);
    //      setGlassPane(glassPaneComposite);

    glassPaneComposite.setVisible(true);

    if (!MapTool.MAC_OS_X)
        removeWindowsF10();
    else
        registerForMacOSXEvents();

    MapTool.getEventDispatcher().addListener(this, MapTool.ZoneEvent.Activated);

    restorePreferences();
    updateKeyStrokes();

    // This will cause the frame to be set to visible (BAD jide, BAD! No cookie for you!)
    configureDocking();

    new WindowPreferences(AppConstants.APP_NAME, "mainFrame", this);
    chatTyperObserver = new ChatTyperObserver();
    chatTyperTimers = new ChatNotificationTimers();
    chatTyperTimers.addObserver(chatTyperObserver);
    chatTimer = getChatTimer();
    setChatTypingLabelColor(AppPreferences.getChatNotificationColor());
}

From source file:lol.search.RankedStatsPage.java

private JPanel statsPanel() {
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    panel.setOpaque(false);// w w w . ja  v  a 2 s.com
    panel.setLayout(new FlowLayout());
    panel.setPreferredSize(new Dimension(910, 464));
    JPanel statsPanelTotals = new JPanel();
    statsPanelTotals.setLayout(new BoxLayout(statsPanelTotals, BoxLayout.X_AXIS));
    statsPanelTotals.setOpaque(false);
    //statsPanelTotals.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    //totals
    statsPanelTotals.setPreferredSize(new Dimension(910, 45));
    totalJLabel(winsLabel, "   W: ", Color.WHITE);
    winsLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    totalJLabel(totalWins, "" + this.wins, valueOrange);
    totalJLabel(lossesLabel, "   L: ", Color.WHITE);
    totalJLabel(totalLosses, "" + this.losses, valueOrange);
    totalJLabel(winPercentLabel, "   Win Ratio: ", Color.WHITE);
    totalJLabel(winPercent, winPercentage + "%", valueOrange);
    totalJLabel(totalGames, "   Total Games Played: ", Color.WHITE);
    totalJLabel(this.totalGamesPlayed, String.valueOf(totalGamesInt), valueOrange);
    statsPanelTotals.add(winsLabel);
    statsPanelTotals.add(totalWins);
    statsPanelTotals.add(lossesLabel);
    statsPanelTotals.add(totalLosses);
    statsPanelTotals.add(winPercentLabel);
    statsPanelTotals.add(winPercent);
    statsPanelTotals.add(totalGames);
    statsPanelTotals.add(totalGamesPlayed);
    JPanel totalsAndAverages = new JPanel();
    totalsAndAverages.setOpaque(false);
    totalsAndAverages.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    totalsAndAverages.setPreferredSize(new Dimension(910, 405));
    totalsAndAverages.setLayout(new GridLayout());
    JPanel leftSide = new JPanel();
    leftSide.setOpaque(false);
    leftSide.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JPanel leftSideHeader = new JPanel();
    leftSideHeader.setOpaque(false);
    leftSideHeader.setLayout(new FlowLayout());
    leftSideHeader.setPreferredSize(new Dimension(455, 35));
    //leftSideHeader.setBorder(BorderFactory.createLineBorder(Color.CYAN));
    totalJLabel(this.leftSideHeaderLabel, "   Per Game Averages:", Color.WHITE);
    leftSideHeader.add(this.leftSideHeaderLabel);
    JPanel leftSideBody = new JPanel();
    leftSideBody.setOpaque(false);
    leftSideBody.setLayout(new FlowLayout(FlowLayout.LEFT));
    leftSideBody.setPreferredSize(new Dimension(250, 360));
    //leftSideBody.setBorder(BorderFactory.createLineBorder(Color.RED));
    JPanel avgKillsPanel = new JPanel();
    avgKillsPanel.setOpaque(false);
    //avgKillsPanel.setBorder(BorderFactory.createLineBorder(Color.CYAN));
    JPanel avgDeathsPanel = new JPanel();
    avgDeathsPanel.setOpaque(false);
    JPanel avgAssistsPanel = new JPanel();
    avgAssistsPanel.setOpaque(false);
    JPanel avgMinionsPanel = new JPanel();
    avgMinionsPanel.setOpaque(false);
    JPanel avgDoubleKillsPanel = new JPanel();
    avgDoubleKillsPanel.setOpaque(false);
    JPanel avgTripleKillsPanel = new JPanel();
    avgTripleKillsPanel.setOpaque(false);
    JPanel avgQuadKillsPanel = new JPanel();
    avgQuadKillsPanel.setOpaque(false);
    JPanel avgPentaKillsPanel = new JPanel();
    avgPentaKillsPanel.setOpaque(false);
    totalJLabel(this.avgKillsLabel, "   Avg. Kills: ", Color.WHITE);
    totalJLabel(this.avgDeathsLabel, "   Avg. Deaths: ", Color.WHITE);
    totalJLabel(this.avgAssistsLabel, "   Avg. Assists: ", Color.WHITE);
    totalJLabel(this.avgMinionKillsLabel, "   Avg. Minion Kills: ", Color.WHITE);
    totalJLabel(this.avgDoubleKillsLabel, "   Avg. Double Kills: ", Color.WHITE);
    totalJLabel(this.avgTripleKillsLabel, "   Avg. Triple Kills: ", Color.WHITE);
    totalJLabel(this.avgQuadKillsLabel, "   Avg. Quadra Kills: ", Color.WHITE);
    totalJLabel(this.avgPentaKillsLabel, "   Avg. Penta Kills: ", Color.WHITE);
    double totalKills = 00000;
    double totalDeaths = 00000;
    double totalAssists = 00000;
    double totalMinions = 00000;
    double totalDoubleKills = 00000;
    double totalTripleKills = 00000;
    double totalQuadraKills = 00000;
    double totalPentaKills = 00000;
    double avgKills = 99999;
    double avgAssists = 99999;
    double avgDeaths = 99999;
    double avgMinions = 99999;
    double avgDoubleKills = 99999;
    double avgTripleKills = 99999;
    double avgQuadraKills = 99999;
    double avgPentaKills = 99999;
    try {
        double totalGamesPlayed = this.objChampRankedList.get(0).getJSONObject("stats")
                .getInt("totalSessionsPlayed");
        //operations
        totalKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalChampionKills");
        avgKills = totalKills / totalGamesPlayed;
        totalDeaths = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalDeathsPerSession");
        avgDeaths = totalDeaths / totalGamesPlayed;
        totalAssists = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalAssists");
        avgAssists = totalAssists / totalGamesPlayed;
        totalMinions = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalMinionKills");
        avgMinions = totalMinions / totalGamesPlayed;
        totalDoubleKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalDoubleKills");
        avgDoubleKills = totalDoubleKills / totalGamesPlayed;
        totalTripleKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalTripleKills");
        avgTripleKills = totalTripleKills / totalGamesPlayed;
        totalQuadraKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalQuadraKills");
        avgQuadraKills = totalQuadraKills / totalGamesPlayed;
        totalPentaKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalPentaKills");
        avgPentaKills = totalPentaKills / totalGamesPlayed;
    } catch (JSONException ex) {
        Logger.getLogger(RankedStatsPage.class.getName()).log(Level.SEVERE, null, ex);
    }
    String avgKillsString = new DecimalFormat("##.##").format(avgKills);
    String avgDeathsString = new DecimalFormat("##.##").format(avgDeaths);
    String avgAssistsString = new DecimalFormat("##.##").format(avgAssists);
    String avgMinionsString = new DecimalFormat("##.##").format(avgMinions);
    String avgDoubleKillsString = new DecimalFormat("##.##").format(avgDoubleKills);
    String avgTripleKillsString = new DecimalFormat("##.##").format(avgTripleKills);
    String avgQuadraKillsString = new DecimalFormat("##.##").format(avgQuadraKills);
    String avgPentaKillsString = new DecimalFormat("##.##").format(avgPentaKills);
    totalJLabel(this.avgKillsLabelValue, avgKillsString, valueOrange);
    totalJLabel(this.avgDeathsLabelValue, avgDeathsString, valueOrange);
    totalJLabel(this.avgAssistsLabelValue, avgAssistsString, valueOrange);
    totalJLabel(this.avgMinionKillsLabelValue, avgMinionsString, valueOrange);
    totalJLabel(this.avgDoubleKillsLabelValue, avgDoubleKillsString, valueOrange);
    totalJLabel(this.avgTripleKillsLabelValue, avgTripleKillsString, valueOrange);
    totalJLabel(this.avgQuadKillsLabelValue, avgQuadraKillsString, valueOrange);
    totalJLabel(this.avgPentaKillsLabelValue, avgPentaKillsString, valueOrange);
    avgKillsPanel.add(avgKillsLabel);
    avgKillsPanel.add(avgKillsLabelValue);
    avgDeathsPanel.add(avgDeathsLabel);
    avgDeathsPanel.add(avgDeathsLabelValue);
    avgAssistsPanel.add(avgAssistsLabel);
    avgAssistsPanel.add(avgAssistsLabelValue);
    avgMinionsPanel.add(avgMinionKillsLabel);
    avgMinionsPanel.add(avgMinionKillsLabelValue);
    avgDoubleKillsPanel.add(avgDoubleKillsLabel);
    avgDoubleKillsPanel.add(avgDoubleKillsLabelValue);
    avgTripleKillsPanel.add(avgTripleKillsLabel);
    avgTripleKillsPanel.add(avgTripleKillsLabelValue);
    avgQuadKillsPanel.add(avgQuadKillsLabel);
    avgQuadKillsPanel.add(avgQuadKillsLabelValue);
    avgPentaKillsPanel.add(avgPentaKillsLabel);
    avgPentaKillsPanel.add(avgPentaKillsLabelValue);
    leftSideBody.add(avgKillsPanel);
    leftSideBody.add(avgDeathsPanel);
    leftSideBody.add(avgAssistsPanel);
    leftSideBody.add(avgMinionsPanel);
    leftSideBody.add(avgDoubleKillsPanel);
    leftSideBody.add(avgTripleKillsPanel);
    leftSideBody.add(avgQuadKillsPanel);
    leftSideBody.add(avgPentaKillsPanel);
    leftSide.add(leftSideHeader);
    leftSide.add(leftSideBody);
    JPanel rightSide = new JPanel();
    /**/
    rightSide.setOpaque(false);
    rightSide.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JPanel rightSideHeader = new JPanel();
    rightSideHeader.setOpaque(false);
    rightSideHeader.setLayout(new FlowLayout());
    rightSideHeader.setPreferredSize(new Dimension(455, 35));
    //rightSideHeader.setBorder(BorderFactory.createLineBorder(Color.MAGENTA));
    totalJLabel(this.rightSideHeaderLabel, "   Season Totals:", Color.WHITE);
    rightSideHeader.add(this.rightSideHeaderLabel);
    JPanel rightSideBody = new JPanel();
    rightSideBody.setOpaque(false);
    rightSideBody.setLayout(new FlowLayout(FlowLayout.LEFT));
    rightSideBody.setPreferredSize(new Dimension(270, 360));
    //rightSideBody.setBorder(BorderFactory.createLineBorder(Color.MAGENTA));
    JPanel totalKillsPanel = new JPanel();
    totalKillsPanel.setOpaque(false);
    JPanel totalDeathsPanel = new JPanel();
    totalDeathsPanel.setOpaque(false);
    JPanel totalAssistsPanel = new JPanel();
    totalAssistsPanel.setOpaque(false);
    JPanel totalMinionsPanel = new JPanel();
    totalMinionsPanel.setOpaque(false);
    JPanel totalDoubleKillsPanel = new JPanel();
    totalDoubleKillsPanel.setOpaque(false);
    JPanel totalTripleKillsPanel = new JPanel();
    totalTripleKillsPanel.setOpaque(false);
    JPanel totalQuadKillsPanel = new JPanel();
    totalQuadKillsPanel.setOpaque(false);
    JPanel totalPentaKillsPanel = new JPanel();
    totalPentaKillsPanel.setOpaque(false);
    totalJLabel(this.totalKillsLabel, "   Total Kills: ", Color.WHITE);
    totalJLabel(this.totalKillsLabelValue, new DecimalFormat("#######").format(totalKills), valueOrange);
    totalJLabel(this.totalDeathsLabel, "   Total Deaths: ", Color.WHITE);
    totalJLabel(this.totalDeathsLabelValue, new DecimalFormat("#######").format(totalDeaths), valueOrange);
    totalJLabel(this.totalAssistsLabel, "   Total Assists: ", Color.WHITE);
    totalJLabel(this.totalAssistsLabelValue, new DecimalFormat("#######").format(totalAssists), valueOrange);
    totalJLabel(this.totalMinionsLabel, "   Total Minion Kills: ", Color.WHITE);
    totalJLabel(this.totalMinionsLabelValue, new DecimalFormat("#######").format(totalMinions), valueOrange);
    totalJLabel(this.totalDoubleKillsLabel, "   Total Double Kills: ", Color.WHITE);
    totalJLabel(this.totalDoubleKillsLabelValue, new DecimalFormat("#######").format(totalDoubleKills),
            valueOrange);
    totalJLabel(this.totalTripleKillsLabel, "   Total Triple Kills: ", Color.WHITE);
    totalJLabel(this.totalTripleKillsLabelValue, new DecimalFormat("#######").format(totalTripleKills),
            valueOrange);
    totalJLabel(this.totalQuadKillsLabel, "   Total Quadra Kills: ", Color.WHITE);
    totalJLabel(this.totalQuadKillsLabelValue, new DecimalFormat("#######").format(totalQuadraKills),
            valueOrange);
    totalJLabel(this.totalPentaKillsLabel, "   Total Penta Kills: ", Color.WHITE);
    totalJLabel(this.totalPentaKillsLabelValue, new DecimalFormat("#######").format(totalPentaKills),
            valueOrange);
    totalKillsPanel.add(totalKillsLabel);
    totalKillsPanel.add(totalKillsLabelValue);
    totalDeathsPanel.add(totalDeathsLabel);
    totalDeathsPanel.add(totalDeathsLabelValue);
    totalAssistsPanel.add(totalAssistsLabel);
    totalAssistsPanel.add(totalAssistsLabelValue);
    totalMinionsPanel.add(totalMinionsLabel);
    totalMinionsPanel.add(totalMinionsLabelValue);
    totalDoubleKillsPanel.add(totalDoubleKillsLabel);
    totalDoubleKillsPanel.add(totalDoubleKillsLabelValue);
    totalTripleKillsPanel.add(totalTripleKillsLabel);
    totalTripleKillsPanel.add(totalTripleKillsLabelValue);
    totalQuadKillsPanel.add(totalQuadKillsLabel);
    totalQuadKillsPanel.add(totalQuadKillsLabelValue);
    totalPentaKillsPanel.add(totalPentaKillsLabel);
    totalPentaKillsPanel.add(totalPentaKillsLabelValue);
    rightSideBody.add(totalKillsPanel);
    rightSideBody.add(totalDeathsPanel);
    rightSideBody.add(totalAssistsPanel);
    rightSideBody.add(totalMinionsPanel);
    rightSideBody.add(totalDoubleKillsPanel);
    rightSideBody.add(totalTripleKillsPanel);
    rightSideBody.add(totalQuadKillsPanel);
    rightSideBody.add(totalPentaKillsPanel);
    //rightSideBody.setBorder(BorderFactory.createLineBorder(Color.RED));
    rightSide.add(rightSideHeader);
    rightSide.add(rightSideBody);
    totalsAndAverages.add(rightSide);
    totalsAndAverages.add(leftSide);
    panel.add(statsPanelTotals);
    panel.add(totalsAndAverages);
    return panel;
}

From source file:ome.formats.importer.gui.GuiCommonElements.java

/**
 * Add a button with an icon in it//  www. j  a  v a 2  s  .c  o  m
 * 
 * @param container - parent container
 * @param label - button label
 * @param image - button image
 * @param width - button width
 * @param height - button height
 * @param mnemonic - button mnemonic
 * @param tooltip - tool tip for button
 * @param placement - TableLayout placement in parent container
 * @param debug - turn on/off red debug borders
 * @return JButton with image
 */
public static JButton addIconButton(Container container, String label, String image, Integer width,
        Integer height, Integer mnemonic, String tooltip, String placement, boolean debug) {
    JButton button = null;

    if (image == null) {
        button = new JButton(label);
    } else {
        java.net.URL imgURL = GuiImporter.class.getResource(image);
        if (imgURL != null && label.length() > 0) {
            button = new JButton(label, new ImageIcon(imgURL));
        } else if (imgURL != null) {
            button = new JButton(null, new ImageIcon(imgURL));
        } else {
            button = new JButton(label);
            log.error("Couldn't find icon: " + image);
        }
    }

    if (width != null && height != null && width > 0 && height > 0) {
        button.setMaximumSize(new Dimension(width, height));
        button.setPreferredSize(new Dimension(width, height));
        button.setMinimumSize(new Dimension(width, height));
        button.setSize(new Dimension(width, height));
    }

    if (mnemonic != null)
        button.setMnemonic(mnemonic);
    button.setOpaque(!getIsMac());
    button.setToolTipText(tooltip);
    container.add(button, placement);
    if (isMotif() == true) {
        Border b = BorderFactory.createLineBorder(Color.gray);
        button.setMargin(new Insets(0, 0, 0, 0));
        button.setBorder(b);
    }

    if (debug == true)
        button.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                button.getBorder()));

    return button;
}

From source file:net.sf.firemox.DeckBuilder.java

/**
 * Creates new form DeckBuilder/*from   w w  w.j av a2 s .  co m*/
 */
private DeckBuilder() {
    super("DeckBuilder");
    form = this;
    timerPanel = new TimerGlassPane();
    cardLoader = new CardLoader(timerPanel);
    timer = new Timer(200, cardLoader);
    setGlassPane(timerPanel);
    try {
        setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif"));
    } catch (Exception e) {
        // IGNORING
    }

    // Load settings
    loadSettings();

    // Initialize components
    final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this);
    newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

    final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this);
    loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));

    final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this);
    saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0));

    final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this);
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));

    final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this);
    quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));

    final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this);
    deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));

    final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this);
    aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK));

    final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this);

    final JMenu mainMenu = UIHelper.buildMenu("menu_file");
    mainMenu.add(newItem);
    mainMenu.add(loadItem);
    mainMenu.add(saveAsItem);
    mainMenu.add(saveItem);
    mainMenu.add(new JSeparator());
    mainMenu.add(quitItem);

    super.optionMenu = new JMenu("Options");

    final JMenu convertMenu = UIHelper.buildMenu("menu_convert");
    convertMenu.add(convertDCK);

    final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this);
    helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));

    final JMenu helpMenu = new JMenu("?");
    helpMenu.add(helpItem);
    helpMenu.add(deckConstraintsItem);
    helpMenu.add(aboutItem);

    final JMenuBar menuBar = new JMenuBar();
    menuBar.add(mainMenu);
    initAbstractMenu();
    menuBar.add(optionMenu);
    menuBar.add(convertMenu);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    addWindowListener(this);

    // Build the panel containing amount of available cards
    final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT);

    // Build the left list
    allListModel = new MListModel<MCardCompare>(amountLeft, false);
    leftList = new ThreadSafeJList(allListModel);
    leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    leftList.setLayoutOrientation(JList.VERTICAL);
    leftList.getSelectionModel().addListSelectionListener(this);
    leftList.addMouseListener(this);
    leftList.setVisibleRowCount(10);

    // Initialize the text field containing the amount to add
    addQtyTxt = new JTextField("1");

    // Build the "Add" button
    addButton = new JButton(LanguageManager.getString("db_add"));
    addButton.setMnemonic('a');
    addButton.setEnabled(false);

    // Build the panel containing : "Add" amount and "Add" button
    final Box addPanel = Box.createHorizontalBox();
    addPanel.add(addButton);
    addPanel.add(addQtyTxt);
    addPanel.setMaximumSize(new Dimension(32010, 26));

    // Build the panel containing the selected card name
    cardNameTxt = new JTextField();
    new HireListener(cardNameTxt, addButton, this, leftList);

    final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : ");
    searchLabel.setLabelFor(cardNameTxt);

    // Build the panel containing search label and card name text field
    final Box searchPanel = Box.createHorizontalBox();
    searchPanel.add(searchLabel);
    searchPanel.add(cardNameTxt);
    searchPanel.setMaximumSize(new Dimension(32010, 26));

    listScrollerLeft = new JScrollPane(leftList);
    MToolKit.addOverlay(listScrollerLeft);

    // Build the left panel containing : list, available amount, "Add" panel
    final JPanel srcPanel = new JPanel(null);
    srcPanel.add(searchPanel);
    srcPanel.add(listScrollerLeft);
    srcPanel.add(amountLeft);
    srcPanel.add(addPanel);
    srcPanel.setMinimumSize(new Dimension(220, 200));
    srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS));

    // Initialize constraints
    constraintsChecker = new ConstraintsChecker();
    constraintsChecker.setBorder(new EtchedBorder());
    final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker);
    MToolKit.addOverlay(constraintsCheckerScroll);

    // create a pane with the oracle text for the present card
    oracleText = new JLabel();
    oracleText.setPreferredSize(new Dimension(180, 200));
    oracleText.setVerticalAlignment(SwingConstants.TOP);

    final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(oracle);

    // build some Pie Charts and a panel to display it
    initSets();
    datasets = new ChartSets();
    final JTabbedPane tabbedPane = new JTabbedPane();
    for (ChartFilter filter : ChartFilter.values()) {
        final Dataset dataSet = filter.createDataSet(this);
        final JFreeChart chart = new JFreeChart(null, null,
                filter.createPlot(dataSet, painterMapper.get(filter)), false);
        datasets.addDataSet(filter, dataSet);
        ChartPanel pieChartPanel = new ChartPanel(chart, true);
        tabbedPane.add(pieChartPanel, filter.getTitle());
    }
    // add the Constraints scroll panel and Oracle text Pane to the tabbedPane
    tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints"));
    tabbedPane.add(oracle, LanguageManager.getString("db_text"));
    tabbedPane.setSelectedComponent(oracle);

    // The toollBar for color filtering
    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    final JButton clearButton = UIHelper.buildButton("clear");
    clearButton.addActionListener(this);
    toolBar.add(clearButton);
    final JToggleButton toggleColorlessButton = new JToggleButton(
            UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true);
    toggleColorlessButton.setActionCommand("0");
    toggleColorlessButton.addActionListener(this);
    toolBar.add(toggleColorlessButton);
    for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) {
        final JToggleButton toggleButton = new JToggleButton(
                UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true);
        toggleButton.setActionCommand(String.valueOf(index));
        toggleButton.addActionListener(this);
        toolBar.add(toggleButton);
    }

    // sorted card type combobox creation
    final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames));
    Collections.sort(idCards);
    final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") },
            idCards.toArray());
    idCardComboBox = new JComboBox(cardTypes);
    idCardComboBox.setSelectedIndex(0);
    idCardComboBox.addActionListener(this);
    idCardComboBox.setActionCommand("cardTypeFilter");

    // sorted card properties combobox creation
    final List<String> properties = new ArrayList<String>(
            CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty()));
    Collections.sort(properties);
    final Object[] cardProperties = ArrayUtils
            .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray());
    propertiesComboBox = new JComboBox(cardProperties);
    propertiesComboBox.setSelectedIndex(0);
    propertiesComboBox.addActionListener(this);
    propertiesComboBox.setActionCommand("propertyFilter");

    final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : ");
    final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : ");
    final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : ");

    // filter Panel with colors toolBar and card type combobox
    final Box filterPanel = Box.createHorizontalBox();
    filterPanel.add(colors);
    filterPanel.add(toolBar);
    filterPanel.add(types);
    filterPanel.add(idCardComboBox);
    filterPanel.add(property);
    filterPanel.add(propertiesComboBox);

    getContentPane().add(filterPanel, BorderLayout.NORTH);

    // Destination section :

    // Build the panel containing amount of available cards
    final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT);
    rightAmount.setMaximumSize(new Dimension(220, 26));

    // Build the right list
    rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true));
    rightListModel.addTableModelListener(this);
    rightList = new JTable(rightListModel);
    rightList.setShowGrid(false);
    rightList.setTableHeader(null);
    rightList.getSelectionModel().addListSelectionListener(this);
    rightList.getColumnModel().getColumn(0).setMaxWidth(25);
    rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    // Build the panel containing the selected deck
    deckNameTxt = new JTextField("loading...");
    deckNameTxt.setEditable(false);
    deckNameTxt.setBorder(null);
    final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : ");
    deckLabel.setLabelFor(deckNameTxt);
    final Box deckNamePanel = Box.createHorizontalBox();
    deckNamePanel.add(deckLabel);
    deckNamePanel.add(deckNameTxt);
    deckNamePanel.setMaximumSize(new Dimension(220, 26));

    // Initialize the text field containing the amount to remove
    removeQtyTxt = new JTextField("1");

    // Build the "Remove" button
    removeButton = new JButton(LanguageManager.getString("db_remove"));
    removeButton.setMnemonic('r');
    removeButton.addMouseListener(this);
    removeButton.setEnabled(false);

    // Build the panel containing : "Remove" amount and "Remove" button
    final Box removePanel = Box.createHorizontalBox();
    removePanel.add(removeButton);
    removePanel.add(removeQtyTxt);
    removePanel.setMaximumSize(new Dimension(220, 26));

    // Build the right panel containing : list, available amount, constraints
    final JScrollPane deskListScroller = new JScrollPane(rightList);
    MToolKit.addOverlay(deskListScroller);
    deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    deskListScroller.setMinimumSize(new Dimension(220, 200));
    deskListScroller.setMaximumSize(new Dimension(220, 32000));

    final Box destPanel = Box.createVerticalBox();
    destPanel.add(deckNamePanel);
    destPanel.add(deskListScroller);
    destPanel.add(rightAmount);
    destPanel.add(removePanel);
    destPanel.setMinimumSize(new Dimension(220, 200));
    destPanel.setMaximumSize(new Dimension(220, 32000));

    // Build the panel containing the name of card in picture
    cardPictureNameTxt = new JLabel("<html><i>no selected card</i>");
    final Box cardPictureNamePanel = Box.createHorizontalBox();
    cardPictureNamePanel.add(cardPictureNameTxt);
    cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26));

    // Group the detail panels
    final JPanel viewCard = new JPanel(null);
    viewCard.add(cardPictureNamePanel);
    viewCard.add(CardView.getInstance());
    viewCard.add(tabbedPane);
    viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS));

    final Box mainPanel = Box.createHorizontalBox();
    mainPanel.add(destPanel);
    mainPanel.add(viewCard);

    // Add the main panel
    getContentPane().add(srcPanel, BorderLayout.WEST);
    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // Size this frame
    getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
    getRootPane().setMinimumSize(getRootPane().getPreferredSize());
    pack();
}

From source file:org.drugis.addis.gui.builder.NetworkMetaAnalysisView.java

private JComponent createRankProbChart() {
    final CategoryDataset dataset = d_pm.getRankProbabilityDataset();
    final JFreeChart chart = ChartFactory.createBarChart("Rank Probability", "Treatment", "Probability",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    chart.addSubtitle(new org.jfree.chart.title.ShortTextTitle(d_pm.getRankProbabilityRankChartNote()));

    final FormLayout layout = new FormLayout("fill:0:grow", "p, 3dlu, p");
    final PanelBuilder builder = new PanelBuilder(layout);
    final CellConstraints cc = new CellConstraints();

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setSize(chartPanel.getPreferredSize().width, chartPanel.getPreferredSize().height + 1);
    chartPanel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));

    builder.add(chartPanel, cc.xy(1, 1));

    final ButtonBarBuilder2 bbuilder = new ButtonBarBuilder2();
    bbuilder.addButton(createSaveImageButton(chart));
    builder.add(bbuilder.getPanel(), cc.xy(1, 3));

    return builder.getPanel();
}

From source file:Citas.FrameCita.java

public void setCitas()
        throws IOException, ClientProtocolException, JSONException, ParseException, java.text.ParseException {

    JSONArray citasporfecha;//  ww  w  . ja  va  2s. co  m
    JSONArray pacienteporid;
    JSONObject paciente;
    jCalendar1.setTodayButtonVisible(false);
    jCalendar1.setForeground(Color.BLUE);//Pinta todas las fechas en azul, las que estan ocupadas se pintaran de rojo abajo
    jCalendar1.getDayChooser().addDateEvaluator(new DJFechasEspInv());//Pinta las Fechas ocupadas en rojo
    BorrarTextFields();
    PanelCita.removeAll();
    PanelCita.revalidate();
    PanelCita.repaint();
    PanelCita.setLayout(new GridBagLayout());
    SimpleDateFormat formato = new SimpleDateFormat("yyyy-MM-dd");
    FechaLbl.setText(formato.format(jCalendar1.getDate()));
    dibujarPanelCita(medico);//Dibuja la "libreta" de las citas

    font = font = font.deriveFont(Font.BOLD, 17);
    disenoLabel(FechaLbl);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 0.5;
    gbc.weighty = 0.5;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.NONE;
    PanelCita.add(FechaLbl, gbc);
    //Aqui se busca esta fecha (jCalendar1.getDate()) en la base de datos y se traen las citas 
    citasporfecha = rutasLeer
            .leer("http://localhost/API_Citas/public/Citas/porFecha/" + formato.format(jCalendar1.getDate()));

    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    int total = 0;
    for (int i = 0; i < citasporfecha.length(); i++) {
        JSONObject obj = (JSONObject) citasporfecha.get(i);
        System.out.println("ENTRE EN EL FOR " + i + ": " + obj.toString());

        for (int j = 0; j < citas.length; j++) {

            if (citas[j].getHora().equals(obj.get("hora"))) {
                pacienteporid = rutasLeer
                        .leer("http://localhost/API_Citas/public/Pacientes/porId/" + obj.get("paciente"));
                paciente = (JSONObject) pacienteporid.get(0);
                citas[j].setText(citas[j].getText() + " " + obj.get("paciente") + " " + paciente.get("cedula"));
                total++;
            }
        }
        //if(citas [i].getHora() == citasporfecha.get("id"))
        System.out.println("voy a agregar las citas");
        //citas [i] = new Citas (i);  
        citas[i].setBorder(BorderFactory.createLineBorder(Color.black));
        citas[i].setOpaque(true);

        citas[i].addMouseListener(new MouseListener() {
            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {

                Citas seleccion = new Citas();
                seleccion = (Citas) e.getComponent();
                System.out.println("Label  clickeado" + seleccion.getText());
                acciones(seleccion);
            }
        });

        gbc.gridy = i + 1;
        PanelCita.add(citas[i], gbc);

    }
    if (total == medico.getCitasPorDia()) {
        JSONObject fecha = new org.json.JSONObject();
        fecha.put("diasOcupados", formato.format(jCalendar1.getDate()));
        //rutasAdd.add("http://localhost/API_Citas/public/Diasocupados/insertarfecha", fecha);
        jCalendar1.getDayChooser().addDateEvaluator(new DJFechasEspInv());//Pinta las Fechas ocupadas en rojo 
    }
    jCalendar1.setDate(jCalendar1.getDate());
    jCalendar1.revalidate();
    jCalendar1.repaint();
    PanelCita.revalidate();
    PanelCita.repaint();
}

From source file:de.codesourcery.eve.skills.ui.components.impl.AssetListComponent.java

@Override
protected JPanel createPanel() {

    // Merge controls.
    final JPanel mergeControlsPanel = new JPanel();
    mergeControlsPanel.setLayout(new GridBagLayout());
    mergeControlsPanel.setBorder(BorderFactory.createTitledBorder("Merging"));

    int y = 0;/* w w w . j  av  a2s.co  m*/

    // merge by type
    mergeAssetsByType.setSelected(true);
    mergeAssetsByType.addActionListener(actionListener);

    mergeControlsPanel.add(mergeAssetsByType, constraints(0, y).anchorWest().end());
    mergeControlsPanel.add(new JLabel("Merge assets by type", SwingConstants.LEFT),
            constraints(1, y++).width(2).end());

    // "ignore different packaging"
    ignorePackaging.setSelected(true);
    ignorePackaging.addActionListener(actionListener);

    mergeControlsPanel.add(new JLabel(""), constraints(0, y).anchorWest().end());
    mergeControlsPanel.add(ignorePackaging, constraints(1, y).anchorWest().end());
    final JLabel label1 = new JLabel("Merge different packaging", SwingConstants.RIGHT);
    mergeControlsPanel.add(label1, constraints(2, y++).end());

    // "ignore different locations"
    ignoreLocations.setSelected(true);
    ignoreLocations.addActionListener(actionListener);

    mergeControlsPanel.add(new JLabel(""), constraints(0, y).anchorWest().end());
    mergeControlsPanel.add(ignoreLocations, constraints(1, y).anchorWest().end());
    final JLabel label2 = new JLabel("Merge different locations", SwingConstants.RIGHT);
    mergeControlsPanel.add(label2, constraints(2, y++).end());

    linkComponentEnabledStates(mergeAssetsByType, ignoreLocations, ignorePackaging, label1, label2);

    /*
     * Filter controls.
     */

    final JPanel filterControlsPanel = new JPanel();
    filterControlsPanel.setLayout(new GridBagLayout());
    filterControlsPanel.setBorder(BorderFactory.createTitledBorder("Filters"));

    y = 0;
    // filter by location combo box
    filterByLocation.addActionListener(actionListener);
    locationComboBox.addActionListener(actionListener);

    filterByLocation.setSelected(false);
    linkComponentEnabledStates(filterByLocation, locationComboBox);

    locationComboBox.setRenderer(new LocationRenderer());
    locationComboBox.setPreferredSize(new Dimension(150, 20));
    locationComboBox.setModel(locationModel);

    filterControlsPanel.add(filterByLocation, constraints(0, y).end());
    filterControlsPanel.add(locationComboBox, constraints(1, y++).end());

    // filter by type combo box
    filterByType.addActionListener(actionListener);
    typeComboBox.addActionListener(actionListener);

    filterByType.setSelected(false);

    linkComponentEnabledStates(filterByType, typeComboBox);

    typeComboBox.setPreferredSize(new Dimension(150, 20));
    typeComboBox.setModel(typeModel);

    filterControlsPanel.add(filterByType, constraints(0, y).end());
    filterControlsPanel.add(typeComboBox, constraints(1, y++).end());

    // filter by item category combobox
    filterByCategory.addActionListener(actionListener);
    categoryComboBox.addActionListener(actionListener);
    categoryComboBox.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {

            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

            setText(getDisplayName((InventoryCategory) value));
            setEnabled(categoryComboBox.isEnabled());
            return this;
        }
    });

    filterByCategory.setSelected(false);
    linkComponentEnabledStates(filterByCategory, categoryComboBox);

    categoryComboBox.setPreferredSize(new Dimension(150, 20));
    categoryComboBox.setModel(categoryModel);

    filterControlsPanel.add(filterByCategory, constraints(0, y).end());
    filterControlsPanel.add(categoryComboBox, constraints(1, y++).end());

    // filter by item group combobox
    filterByGroup.addActionListener(actionListener);
    groupComboBox.addActionListener(actionListener);

    filterByGroup.setSelected(false);

    linkComponentEnabledStates(filterByGroup, groupComboBox);

    groupComboBox.setPreferredSize(new Dimension(150, 20));
    groupComboBox.setModel(groupModel);

    filterControlsPanel.add(filterByGroup, constraints(0, y).end());
    filterControlsPanel.add(groupComboBox, constraints(1, y++).end());

    /*
     * Table panel.
     */

    table = new JTable() {

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {

            // subclassing hack is needed because table
            // returns different renderes depending on column type
            final TableCellRenderer result = super.getCellRenderer(row, column);

            return new TableCellRenderer() {

                @Override
                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                        boolean hasFocus, int row, int column) {

                    final Component comp = result.getTableCellRendererComponent(table, value, isSelected,
                            hasFocus, row, column);

                    final int modelRow = table.convertRowIndexToModel(row);
                    final Asset asset = model.getRow(modelRow);

                    final StringBuilder label = new StringBuilder("<HTML><BODY>");
                    label.append(asset.getItemId() + " - flags: " + asset.getFlags() + "<BR>");
                    if (asset.hasMultipleLocations()) {
                        label.append("<BR>");
                        for (ILocation loc : asset.getLocations()) {
                            label.append(loc.getDisplayName()).append("<BR>");
                        }
                    }

                    label.append("</BODY></HTML>");
                    ((JComponent) comp).setToolTipText(label.toString());

                    return comp;
                }
            };
        }
    };

    model.setViewFilter(this.viewFilter);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateSelectedVolume();
        }
    });

    FixedBooleanTableCellRenderer.attach(table);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setModel(model);
    table.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    table.setRowSorter(model.getRowSorter());

    popupMenuBuilder.addItem("Refine...", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final List<Asset> assets = getSelectedAssets();
            if (assets == null || assets.isEmpty()) {
                return;
            }

            final ICharacter c = selectionProvider.getSelectedItem();
            final RefiningComponent comp = new RefiningComponent(c);
            comp.setItemsToRefine(assets);
            ComponentWrapper.wrapComponent("Refining", comp).setVisible(true);
        }

        @Override
        public boolean isEnabled() {
            return table.getSelectedRow() != -1;
        }
    });

    popupMenuBuilder.addItem("Copy selection to clipboard (text)", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final List<Asset> assets = getSelectedAssets();
            if (assets == null || assets.isEmpty()) {
                return;
            }

            new PlainTextTransferable(toPlainText(assets)).putOnClipboard();
        }

        @Override
        public boolean isEnabled() {
            return table.getSelectedRow() != -1;
        }
    });

    popupMenuBuilder.addItem("Copy selection to clipboard (CSV)", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final List<Asset> assets = getSelectedAssets();
            if (assets == null || assets.isEmpty()) {
                return;
            }

            final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

            clipboard.setContents(new PlainTextTransferable(toCsv(assets)), null);
        }

        @Override
        public boolean isEnabled() {
            return table.getSelectedRow() != -1;
        }
    });

    table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    this.popupMenuBuilder.attach(table);

    final JScrollPane scrollPane = new JScrollPane(table);

    /*
     * Name filter
     */

    final JPanel nameFilterPanel = new JPanel();
    nameFilterPanel.setLayout(new GridBagLayout());
    nameFilterPanel.setBorder(BorderFactory.createTitledBorder("Filter by name"));
    nameFilterPanel.setPreferredSize(new Dimension(150, 70));
    nameFilter.setColumns(10);
    nameFilter.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void changedUpdate(DocumentEvent e) {
            model.viewFilterChanged();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            model.viewFilterChanged();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            model.viewFilterChanged();
        }
    });

    nameFilterPanel.add(nameFilter, constraints(0, 0).resizeHorizontally().end());
    final JButton clearButton = new JButton("Clear");
    clearButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            nameFilter.setText(null);
        }
    });
    nameFilterPanel.add(clearButton, constraints(1, 0).noResizing().end());

    // Selected volume
    final JPanel selectedVolumePanel = this.selectedVolume.getPanel();

    // add control panels to result panel
    final JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridBagLayout());

    topPanel.add(mergeControlsPanel, constraints(0, 0).height(2).weightX(0).anchorWest().end());
    topPanel.add(filterControlsPanel, constraints(1, 0).height(2).anchorWest().weightX(0).end());
    topPanel.add(nameFilterPanel, constraints(2, 0).height(1).anchorWest().useRemainingWidth().end());
    topPanel.add(selectedVolumePanel, constraints(2, 1).height(1).anchorWest().useRemainingWidth().end());

    final JSplitPane splitPane = new ImprovedSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, scrollPane);

    splitPane.setDividerLocation(0.3d);

    final JPanel content = new JPanel();
    content.setLayout(new GridBagLayout());
    content.add(splitPane, constraints().resizeBoth().useRemainingSpace().end());

    return content;
}

From source file:view.FramePrincipal.java

private void setaImagensPrincipais() {
    String aux = "";
    String tipoImgs[] = { "png", "jpg", "jpeg" };
    aux = retornaDiretorioArquivo(tipoImgs);
    if (!"".equals(aux)) {
        dirImagemPrincipal = aux;/*  w w  w.  ja va  2s.  co  m*/

        inputImage = createBufferedImage(dirImagemPrincipal);
        JLabelImagem lblInput = new JLabelImagem(inputImage);
        lblInput.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        jPanelImagem1.setBounds(3, 5, 479, 532);
        lblInput.setBounds(jPanelImagem1.getBounds());
        jPanelImagem1.add(lblInput, BorderLayout.BEFORE_LINE_BEGINS);
    }
}