Example usage for java.awt Color gray

List of usage examples for java.awt Color gray

Introduction

In this page you can find the example usage for java.awt Color gray.

Prototype

Color gray

To view the source code for java.awt Color gray.

Click Source Link

Document

The color gray.

Usage

From source file:CustomIconDemo.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    if (c.isEnabled()) {
        g.setColor(c.getForeground());/*from  www.j  a v a2  s .  com*/
    } else {
        g.setColor(Color.gray);
    }

    g.translate(x, y);
    g.fillPolygon(xPoints, yPoints, xPoints.length);
    g.translate(-x, -y); // Restore graphics object
}

From source file:edu.ucla.stat.SOCR.chart.SuperValueChart.java

/**
 * reset dataTable to default (demo data), and refesh chart
 *///from  w  ww  .  j a  v  a  2s  .  c  o m
public void resetExample() {

    ValueDataset dataset = createDataset(true);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();

    hasExample = true;
    convertor.dataset2Table(dataset);
    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(tempDataTable.getColumnCount());

    for (int i = 0; i < tempDataTable.getColumnCount(); i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);
    dataTable.doLayout();
    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping

    setMapping();

    updateStatus(url);
}

From source file:visualizer.datamining.dataanalysis.NeighborhoodHit.java

private JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("Neighborhood Hit", "Number Neighbors", "Precision",
            xydataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.WHITE);

    XYPlot xyplot = (XYPlot) chart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);

    xyplot.setDomainGridlinePaint(Color.BLACK);
    xyplot.setRangeGridlinePaint(Color.BLACK);

    xyplot.setOutlinePaint(Color.BLACK);
    xyplot.setOutlineStroke(new BasicStroke(1.0f));
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    xyplot.setDrawingSupplier(new DefaultDrawingSupplier(
            new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE,
                    Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW },
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    xylineandshaperenderer.setDrawOutlines(true);

    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo4.java

/**
 * reset dataTable to default (demo data), and refesh chart
 *///from w ww.j  a v a2s . co m
public void resetExample() {
    isDemo = true;

    IntervalXYDataset dataset = createDataset(isDemo);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();

    hasExample = true;

    convertor.dataset2Table(dataset);
    JTable tempDataTable = convertor.getTable();
    int seriesCount = tempDataTable.getColumnCount() / 2;
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(seriesCount * 2);

    //correct the column name
    columnModel.getColumn(0).setHeaderValue("Data");
    columnModel.getColumn(1).setHeaderValue("Frequency");
    domainLabel = "Data";
    rangeLabel = "Frequency";

    /*   for(int i=0;i<seriesCount*2;i++) {
    columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }*/

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    for (int i = 0; i < seriesCount; i++) {
        addButtonIndependent();
        addButtonDependent();
    }

    updateStatus(url);
}

From source file:org.jfree.chart.demo.StackedXYAreaChartDemo.java

/**
 * Creates a chart./*ww w .  j a va 2s  .  c  o  m*/
 *
 * @param dataset  the dataset.
 *
 * @return A chart.
 */
private JFreeChart createChart(final TableXYDataset dataset) {

    final StandardXYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd-MMM-yyyy", Locale.UK),
            NumberFormat.getInstance());
    final DateAxis xAxis = new DateAxis("Domain (X)");
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    final NumberAxis yAxis = new NumberAxis("Range (Y)");
    yAxis.setAutoRangeIncludesZero(true);
    final StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES,
            toolTipGenerator, null);
    renderer.setOutline(true);
    renderer.setSeriesPaint(0, new Color(255, 255, 206));
    renderer.setSeriesPaint(1, new Color(206, 230, 255));
    renderer.setSeriesPaint(2, new Color(255, 230, 230));
    renderer.setShapePaint(Color.gray);
    renderer.setShapeStroke(new BasicStroke(0.5f));
    renderer.setShape(new Ellipse2D.Double(-3, -3, 6, 6));
    final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    return chart;
}

From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java

/**
 * Helper method for updateModel(). Adds the gray line at x=0.
 */// ww  w. ja  v  a  2  s .c  o m
private void addLineX(XYSeriesCollection dataset, XYLineAndShapeRenderer renderer) {
    XYSeries line = new XYSeries("");
    line.add(0.5, 0.0);
    line.add(project.getPeriods() + 0.5, 0.0);

    int series = dataset.getSeriesCount();
    dataset.addSeries(line);
    renderer.setSeriesPaint(series, Color.GRAY);
    renderer.setSeriesShapesVisible(series, false);
    renderer.setSeriesLinesVisible(series, true);
    renderer.setSeriesVisibleInLegend(series, false);
}

From source file:org.tap4j.plugin.util.GraphHelper.java

/**
 * Creates the graph displayed on Method results page to compare execution
 * duration and status of a test method across builds.
 * /*from   www.j a v  a2s  .  c o m*/
 * At max, 9 older builds are displayed.
 * 
 * @param req
 *            request
 * @param dataset
 *            data set to be displayed on the graph
 * @param statusMap
 *            a map with build as key and the test methods execution status
 *            (result) as the value
 * @param methodUrl
 *            URL to get to the method from a build test result page
 * @return the chart
 */
public static JFreeChart createMethodChart(StaplerRequest req, final CategoryDataset dataset,
        final Map<NumberOnlyBuildLabel, String> statusMap, final String methodUrl) {

    final JFreeChart chart = ChartFactory.createBarChart(null, // chart
            // title
            null, // unused
            " Duration (secs)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            true // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer br = new BarRenderer() {

        private static final long serialVersionUID = 961671076462240008L;
        Map<String, Paint> statusPaintMap = new HashMap<String, Paint>();

        {
            statusPaintMap.put("PASS", ColorPalette.BLUE);
            statusPaintMap.put("SKIP", ColorPalette.YELLOW);
            statusPaintMap.put("FAIL", ColorPalette.RED);
        }

        /**
         * Returns the paint for an item. Overrides the default behavior
         * inherited from AbstractSeriesRenderer.
         * 
         * @param row
         *            the series.
         * @param column
         *            the category.
         * 
         * @return The item color.
         */
        public Paint getItemPaint(final int row, final int column) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
            Paint paint = statusPaintMap.get(statusMap.get(label));
            // when the status of test method is unknown, use gray color
            return paint == null ? Color.gray : paint;
        }
    };

    br.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
            if ("UNKNOWN".equals(statusMap.get(label))) {
                return "unknown";
            }
            // values are in seconds
            return dataset.getValue(row, column) + " secs";
        }
    });

    br.setBaseItemURLGenerator(new CategoryURLGenerator() {
        public String generateURL(CategoryDataset dataset, int series, int category) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(category);
            if ("UNKNOWN".equals(statusMap.get(label))) {
                // no link when method result doesn't exist
                return null;
            }
            // return label.build.getUpUrl() + label.build.getNumber() + "/" + PluginImpl.URL + "/" + methodUrl;
            return label.build.getUpUrl() + label.build.getNumber() + "/tap/" + methodUrl;
        }
    });

    br.setItemMargin(0.0);
    br.setMinimumBarLength(5);
    // set the base to be 1/100th of the maximum value displayed in the
    // graph
    br.setBase(br.findRangeBounds(dataset).getUpperBound() / 100);
    plot.setRenderer(br);

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));
    return chart;
}

From source file:Main_Window.java

public Main_Window() {
    super("Google Places Application"); //First call Constructor of JFrame

    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //We do not want our application to terminate when a JFrame is closed
    this.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override//from  w w w  .  j  a  v  a  2s . c  o m
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {
            int Answer = JOptionPane.showConfirmDialog(null, "Exit Application ? ", "Exit ? ",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (Answer == JOptionPane.YES_OPTION) {
                if (POI_List.isEmpty()) {
                    POI_List.clear();
                }
                if (Distances_List.isEmpty()) {
                    Distances_List.clear();
                }
                if (Temp_List.isEmpty()) {
                    Temp_List.clear();
                }
                if (Distances_List_2.isEmpty()) {
                    Distances_List_2.clear();
                }
                System.exit(1);
            } else {
                setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
            }
        }
    });
    //The listener object created from that class is then registered with a Window using the window's addWindowListener method.

    //
    this.setSize(1100, 700); // Size of Window
    this.setLocationRelativeTo(null); // Display Window in center of Screen
    this.setVisible(true);
    this.getContentPane().setBackground(Color.LIGHT_GRAY);
    //

    //Initialization of J Components
    POIS_Label = new JLabel("Points of Interest:");
    POIS_Label.setForeground(Color.black);
    POIS_Label.setFont(new Font("Courier New", Font.BOLD, 25));
    POIS_Label.setBounds(600, 30, 350, 150);

    Retrieve_POIs_Button = new JButton("Retrieve POIs");
    Retrieve_POIs_Button.setForeground(Color.black);
    Retrieve_POIs_Button.setFont(new Font("Courier New", Font.BOLD, 35));
    Retrieve_POIs_Button.setBounds(25, 450, 350, 150);

    Open_Status = new JRadioButton(" Open Now?");
    Open_Status.setForeground(Color.black);
    Open_Status.setBackground(Color.LIGHT_GRAY);
    Open_Status.setBounds(20, 380, 100, 30);

    Welcome_Label = new JLabel("Welcome to Google Places");
    Welcome_Label.setForeground(Color.BLUE);
    Welcome_Label.setFont(new Font("Courier New", Font.BOLD, 35));
    Welcome_Label.setBounds(240, 20, 600, 60);

    Latitude_Label = new JLabel("Latitude:");
    Latitude_Label.setForeground(Color.BLACK);
    Latitude_Label.setFont(new Font("Courier New", Font.PLAIN, 25));
    Latitude_Label.setBounds(15, 80, 200, 100);

    Longitude_Label = new JLabel("Longitude:");
    Longitude_Label.setForeground(Color.BLACK);
    Longitude_Label.setFont(new Font("Courier New", Font.PLAIN, 25));
    Longitude_Label.setBounds(15, 130, 250, 100);

    Radius_Label = new JLabel("Radius:");
    Radius_Label.setForeground(Color.BLACK);
    Radius_Label.setFont(new Font("Courier New", Font.PLAIN, 25));
    Radius_Label.setBounds(15, 180, 250, 100);

    Category_Label = new JLabel("Category:");
    Category_Label.setForeground(Color.BLACK);
    Category_Label.setFont(new Font("Courier New", Font.PLAIN, 25));
    Category_Label.setBounds(15, 250, 250, 100);

    Latitude_TextField = new JTextField(7);
    Latitude_TextField.setForeground(Color.BLACK);
    Latitude_TextField.setBounds(165, 116, 180, 30);

    Longitude_TextField = new JTextField(7);
    Longitude_TextField.setForeground(Color.BLACK);
    Longitude_TextField.setBounds(170, 168, 180, 30);

    Radius_TextField = new JTextField(7);
    Radius_TextField.setForeground(Color.BLACK);
    Radius_TextField.setBounds(125, 215, 180, 30);

    Categories = new JComboBox(Categories_Names);
    Categories.setForeground(Color.BLACK);
    Categories.setBackground(Color.white);
    Categories.setBounds(15, 320, 180, 30);

    POI_List = new ArrayList();

    pane = getContentPane(); //Manager
    pane.setLayout(null); // Deactivate Manager Layout

    //JPANEL
    P = new JPanel();
    P.setBackground(Color.GRAY);
    P.setBounds(600, 120, 450, 180);
    P.setBackground(Color.GRAY);

    pane.add(P);
    pane.add(POIS_Label);
    pane.add(Retrieve_POIs_Button);
    pane.add(Welcome_Label);
    pane.add(Longitude_Label);
    pane.add(Latitude_Label);
    pane.add(Radius_Label);
    pane.add(Category_Label);
    pane.add(Latitude_TextField);
    pane.add(Longitude_TextField);
    pane.add(Radius_TextField);
    pane.add(Categories);
    pane.add(Open_Status);

    Retrieve_POIs_Button.addActionListener(this);

    setContentPane(pane);

}

From source file:org.simbrain.plot.projection.ProjectionGui.java

/**
 * Construct the Projection GUI.//from  w w  w  . ja v  a2  s  .  c  o m
 */
public ProjectionGui(final GenericFrame frame, final ProjectionComponent component) {
    super(frame, component);
    setPreferredSize(new Dimension(500, 400));
    actionManager = new PlotActionManager(this);
    setLayout(new BorderLayout());

    // Generate the graph
    chart = ChartFactory.createScatterPlot("High Dimensional Projection", "Projection X", "Projection Y",
            getWorkspaceComponent().getProjectionModel().getDataset(), PlotOrientation.VERTICAL, false, true,
            false);
    // chart.getXYPlot().getDomainAxis().setRange(-100, 100);
    // chart.getXYPlot().getRangeAxis().setRange(-100, 100);
    chart.getXYPlot().setBackgroundPaint(Color.white);
    chart.getXYPlot().setDomainGridlinePaint(Color.gray);
    chart.getXYPlot().setRangeGridlinePaint(Color.gray);
    chart.getXYPlot().getDomainAxis().setAutoRange(true);
    chart.getXYPlot().getRangeAxis().setAutoRange(true);
    panel = new ChartPanel(chart);

    // Custom render points as dots (not squares) and use custom tooltips
    // that show high-d point
    CustomRenderer renderer = new CustomRenderer();
    chart.getXYPlot().setRenderer(renderer);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-5, -5, 5, 5));
    CustomToolTipGenerator generator = new CustomToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, generator);

    // Toolbar
    openBtn.setToolTipText("Open high-dimensional data");
    saveBtn.setToolTipText("Save data");
    projectionList.setMaximumSize(new java.awt.Dimension(200, 100));
    iterateBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getWorkspaceComponent().getProjector().iterate();
            update();
        }
    });
    clearBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getWorkspaceComponent().getWorkspace().stop();
            Executors.newSingleThreadExecutor().execute(new Runnable() {
                @Override
                public void run() {
                    getWorkspaceComponent().clearData();
                }
            });
        }
    });
    playBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (getWorkspaceComponent().getProjectionModel().isRunning()) {
                playBtn.setIcon(ResourceManager.getImageIcon("Stop.png"));
                playBtn.setToolTipText("Stop iterating projection algorithm");
                getWorkspaceComponent().getProjectionModel().setRunning(false);
                Executors.newSingleThreadExecutor().execute(new ProjectionUpdater(getWorkspaceComponent()));
            } else {
                playBtn.setIcon(ResourceManager.getImageIcon("Play.png"));
                playBtn.setToolTipText("Start iterating projection algorithm");
                getWorkspaceComponent().getProjectionModel().setRunning(true);
            }
        }
    });
    prefsBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // TODO (Still working out overall dialog structure).
        }
    });
    randomBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getWorkspaceComponent().getProjector().randomize(100);
        }
    });
    theToolBar.add(projectionList);
    playBtn.setToolTipText("Iterate projection algorithm");
    theToolBar.add(playBtn);
    iterateBtn.setToolTipText("Step projection algorithm");
    theToolBar.add(iterateBtn);
    clearBtn.setToolTipText("Clear current data");
    theToolBar.add(clearBtn);
    randomBtn.setToolTipText("Randomize datapoints");
    theToolBar.add(randomBtn);
    theToolBar.addSeparator();
    warningLabel.setPreferredSize(new Dimension(16, 16));
    warningLabel.setToolTipText("This method works best with more " + "datapoints already added");
    theToolBar.add(warningLabel);
    String stepSizeToolTip = "Scales the amount points are moved on each iteration";
    JLabel stepSizeLabel = new JLabel("Step Size");
    stepSizeLabel.setToolTipText(stepSizeToolTip);
    sammonStepSizePanel.add(stepSizeLabel);
    try {
        sammonStepSize = new JTextField("" + SimbrainPreferences.getDouble("projectorSammonEpsilon"));
    } catch (PropertyNotFoundException e1) {
        e1.printStackTrace();
    }
    sammonStepSize.setColumns(3);
    sammonStepSize.setToolTipText(stepSizeToolTip);
    sammonStepSizePanel.add(sammonStepSize);
    theToolBar.add(sammonStepSizePanel);
    adjustDimension1.setToolTipText("Dimension 1");
    adjustDimension2.setToolTipText("Dimension 2");
    theToolBar.add(adjustDimension1);
    theToolBar.add(adjustDimension2);

    // Help button
    JButton helpButton = new JButton();
    helpButton.setAction(helpAction);

    // Add/Remove dimension buttons
    JButton addButton = new JButton("Add Dimension");
    addButton.setActionCommand("Add");
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getWorkspaceComponent().getProjectionModel().addSource();
        }
    });
    JButton deleteButton = new JButton("Remove Dimension");
    deleteButton.setActionCommand("Delete");
    deleteButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getWorkspaceComponent().getProjectionModel().removeSource();
        }
    });

    // Button Panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(helpButton);
    buttonPanel.add(addButton);
    buttonPanel.add(deleteButton);

    // Setup Menu Bar
    createAttachMenuBar();

    // Status Bar
    statusBar.add(pointsLabel);
    statusBar.add(dimsLabel);
    errorBar.add(errorLabel);

    // Bottom panel
    bottomPanel.add("North", buttonPanel);
    JPanel southPanel = new JPanel();
    southPanel.add(errorBar);
    southPanel.add(statusBar);
    bottomPanel.add("South", southPanel);

    // Put all panels together
    add("North", theToolBar);
    add("Center", panel);
    add("South", bottomPanel);

    // Other initialization
    initializeComboBoxes();
    addListeners();
    updateToolBar();
    update();

}

From source file:com.versul.testes.JRViewerPanel.java

private void initComponents() {
    scrollPane = new javax.swing.JScrollPane();
    scrollPane.getHorizontalScrollBar().setUnitIncrement(5);
    scrollPane.getVerticalScrollBar().setUnitIncrement(5);

    pnlInScroll = new javax.swing.JPanel();
    pnlPage = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    pnlLinks = new javax.swing.JPanel();
    jPanel5 = new javax.swing.JPanel();
    jPanel6 = new javax.swing.JPanel();
    jPanel7 = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel9 = new javax.swing.JPanel();
    lblPage = new PageRenderer();

    setMinimumSize(new java.awt.Dimension(450, 150));
    setPreferredSize(new java.awt.Dimension(450, 150));

    setLayout(new java.awt.BorderLayout());
    addComponentListener(new java.awt.event.ComponentAdapter() {
        public void componentResized(java.awt.event.ComponentEvent evt) {
            pnlMainComponentResized(evt);
        }//from  w  ww  .  j a  va 2 s  .co  m
    });

    scrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    pnlInScroll.setLayout(new java.awt.GridBagLayout());

    pnlPage.setLayout(new java.awt.BorderLayout());
    pnlPage.setMinimumSize(new java.awt.Dimension(100, 100));
    pnlPage.setPreferredSize(new java.awt.Dimension(100, 100));

    jPanel4.setLayout(new java.awt.GridBagLayout());
    jPanel4.setMinimumSize(new java.awt.Dimension(100, 120));
    jPanel4.setPreferredSize(new java.awt.Dimension(100, 120));

    pnlLinks.setLayout(null);
    pnlLinks.setMinimumSize(new java.awt.Dimension(5, 5));
    pnlLinks.setPreferredSize(new java.awt.Dimension(5, 5));
    pnlLinks.setOpaque(false);
    pnlLinks.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            pnlLinksMousePressed(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            pnlLinksMouseReleased(evt);
        }
    });
    pnlLinks.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseDragged(java.awt.event.MouseEvent evt) {
            pnlLinksMouseDragged(evt);
        }
    });

    GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    jPanel4.add(pnlLinks, gridBagConstraints);

    jPanel5.setBackground(java.awt.Color.gray);
    jPanel5.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel5.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
    jPanel4.add(jPanel5, gridBagConstraints);

    jPanel6.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel6.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    jPanel4.add(jPanel6, gridBagConstraints);

    jPanel7.setBackground(java.awt.Color.gray);
    jPanel7.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel7.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel4.add(jPanel7, gridBagConstraints);

    jPanel8.setBackground(java.awt.Color.gray);
    jPanel8.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel8.setPreferredSize(new java.awt.Dimension(5, 5));
    jLabel1.setText("jLabel1");
    jPanel8.add(jLabel1);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    jPanel4.add(jPanel8, gridBagConstraints);

    jPanel9.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel9.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    jPanel4.add(jPanel9, gridBagConstraints);

    lblPage.setBackground(java.awt.Color.white);
    lblPage.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
    lblPage.setOpaque(true);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    jPanel4.add(lblPage, gridBagConstraints);

    pnlPage.add(jPanel4, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    pnlInScroll.add(pnlPage, gridBagConstraints);

    scrollPane.setViewportView(pnlInScroll);
    add(scrollPane, java.awt.BorderLayout.CENTER);

}