Example usage for java.text NumberFormat getIntegerInstance

List of usage examples for java.text NumberFormat getIntegerInstance

Introduction

In this page you can find the example usage for java.text NumberFormat getIntegerInstance.

Prototype

public static final NumberFormat getIntegerInstance() 

Source Link

Document

Returns an integer number format for the current default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

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

private JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart3D("Stacked Bar Chart 3D Demo 2", "Category",
            "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer();
    stackedbarrenderer3d.setRenderAsPercentages(true);
    stackedbarrenderer3d.setDrawBarOutline(false);
    stackedbarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}",
            NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%")));
    stackedbarrenderer3d.setBaseItemLabelsVisible(true);
    stackedbarrenderer3d//from w  w  w . j a  v  a  2s. co m
            .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    stackedbarrenderer3d
            .setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    return jfreechart;
}

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

private JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart3D("Stacked Bar Chart 3D Demo 4", "Category",
            "Value", categorydataset, PlotOrientation.HORIZONTAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer();
    stackedbarrenderer3d.setRenderAsPercentages(true);
    stackedbarrenderer3d.setDrawBarOutline(false);
    stackedbarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}",
            NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%")));
    stackedbarrenderer3d.setBaseItemLabelsVisible(true);
    stackedbarrenderer3d//w ww  .  j a va2  s .  c o  m
            .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    stackedbarrenderer3d
            .setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    return jfreechart;
}

From source file:org.snipsnap.util.XMLSnipRepair.java

/**
 * Load snips and users into the SnipSpace from an xml document out of a stream.
 *
 * @param file the file to load from//from  w w  w  .  ja v a  2  s.com
 */
private static Document load(File file) throws Exception {
    final long fileLength = file.length();
    SAXReader saxReader = new SAXReader();
    System.err.print("0%");
    InputStreamReader reader = new InputStreamReader(new FileInputStream(file), "UTF-8") {
        public int read(char[] chars) throws IOException {
            int n = super.read(chars);
            for (int i = 0; i < n; i++) {
                chars[i] = replaceIfIllegal(chars[i]);
            }
            return n;
        }

        public int read(char[] chars, int start, int length) throws IOException {
            int n = super.read(chars, start, length);
            for (int i = 0; i < n; i++) {
                chars[i] = replaceIfIllegal(chars[i]);
            }
            readProgress(fileLength, curr += n, length);
            return n;
        }

        private char replaceIfIllegal(char c) {
            if (c < 0x20 && !(c == 0x09 || c == 0x0a || c == 0x0d)) {
                //          System.err.println("Replacing illegal character '0x" + Integer.toHexString(c) + "' by space.");
                errCount++;
                return (char) 0x20;
            }
            return c;
        }

        private void readProgress(long length, long current, int blockSize) {
            long percentage = current * 100 / length;
            if (percentage % 5 != 0 && ((current - blockSize) * 100 / length) % 5 == 0) {
                System.err.print(".");
            } else if (percentage % 20 == 0 && ((current - blockSize) * 100 / length) % 20 != 0) {
                System.err.print(NumberFormat.getIntegerInstance().format(percentage) + "%");
            }
        }
    };

    Document document = saxReader.read(reader);
    System.err.println();

    if (errCount > 0) {
        System.err.println("Replaced " + errCount + " illegal characters in input document by a space.");
        System.err.println("Characters not considered valid in an XML document are considered illegal.");
        System.err.println("This includes all characters with a code below 32 unless its TAB, CR or LF.");
    }

    return document;
}

From source file:dbseer.gui.panel.DBSeerMiddlewarePanel.java

private void initializeGUI() {
    this.setLayout(new MigLayout());

    JLabel ipAddressLabel = new JLabel("IP Address:");
    JLabel portLabel = new JLabel("Port:");
    JLabel idLabel = new JLabel("ID:");
    JLabel passwordLabel = new JLabel("Password:");

    ipField = new JTextField(20);

    DecimalFormat portFormatter = new DecimalFormat();

    portFormatter.setMaximumFractionDigits(0);
    portFormatter.setMaximumIntegerDigits(5);
    portFormatter.setMinimumIntegerDigits(1);
    portFormatter.setDecimalSeparatorAlwaysShown(false);
    portFormatter.setGroupingUsed(false);

    portField = new JFormattedTextField(portFormatter);
    portField.setColumns(6);/*from ww w  .  j a v  a  2  s . c  o  m*/
    portField.setText("3555"); // default port.
    idField = new JTextField(20);
    passwordField = new JPasswordField(20);

    logInOutButton = new JButton("Login");
    logInOutButton.addActionListener(this);
    startMonitoringButton = new JButton("Start Monitoring");
    startMonitoringButton.addActionListener(this);
    stopMonitoringButton = new JButton("Stop Monitoring");
    stopMonitoringButton.addActionListener(this);

    startMonitoringButton.setEnabled(true);
    stopMonitoringButton.setEnabled(false);

    ipField.setText(DBSeerGUI.userSettings.getLastMiddlewareIP());
    portField.setText(String.valueOf(DBSeerGUI.userSettings.getLastMiddlewarePort()));
    idField.setText(DBSeerGUI.userSettings.getLastMiddlewareID());

    NumberFormatter formatter = new NumberFormatter(NumberFormat.getIntegerInstance());
    formatter.setMinimum(1);
    formatter.setMaximum(120);
    formatter.setAllowsInvalid(false);

    refreshRateLabel = new JLabel("Monitoring Refresh Rate:");
    refreshRateField = new JFormattedTextField(formatter);
    JLabel refreshRateRangeLabel = new JLabel("(1~120 sec)");

    refreshRateField.setText("1");
    applyRefreshRateButton = new JButton("Apply");
    applyRefreshRateButton.addActionListener(this);

    this.add(ipAddressLabel, "cell 0 0 2 1, split 4");
    this.add(ipField);
    this.add(portLabel);
    this.add(portField);
    this.add(idLabel, "cell 0 2");
    this.add(idField, "cell 1 2");
    this.add(passwordLabel, "cell 0 3");
    this.add(passwordField, "cell 1 3");
    this.add(refreshRateLabel, "cell 0 4");
    this.add(refreshRateField, "cell 1 4, growx, split 3");
    this.add(refreshRateRangeLabel);
    this.add(applyRefreshRateButton, "growx, wrap");
    //      this.add(logInOutButton, "cell 0 2 2 1, growx, split 3");
    this.add(startMonitoringButton);
    this.add(stopMonitoringButton);
}

From source file:com.jgoodies.validation.tutorial.formatted.NumberExample.java

/**
 * Appends the demo rows to the given builder and returns the List of
 * formatted text fields./*ww w. j a  v  a2  s.c  o m*/
 * 
 * @param builder  the builder used to add components to
 * @return the List of formatted text fields
 */
private List appendDemoRows(DefaultFormBuilder builder) {
    // The Formatter is choosen by the initial value.
    JFormattedTextField defaultNumberField = new JFormattedTextField(new Long(42));

    // The Formatter is choosen by the given Format.
    JFormattedTextField noInitialValueField = new JFormattedTextField(NumberFormat.getIntegerInstance());

    // Uses a custom NumberFormat.
    NumberFormat customFormat = NumberFormat.getIntegerInstance();
    customFormat.setMinimumIntegerDigits(3);
    JFormattedTextField customFormatField = new JFormattedTextField(new NumberFormatter(customFormat));

    // Uses a custom NumberFormatter that prints natural language strings.
    JFormattedTextField customFormatterField = new JFormattedTextField(new CustomNumberFormatter());

    // Uses a custom FormatterFactory that used different formatters
    // for the display and while editing.
    DefaultFormatterFactory formatterFactory = new DefaultFormatterFactory(new NumberFormatter(),
            new CustomNumberFormatter());
    JFormattedTextField formatterFactoryField = new JFormattedTextField(formatterFactory);

    // Wraps a NumberFormatter to map empty strings to null and vice versa.
    JFormattedTextField numberOrNullField = new JFormattedTextField(new EmptyNumberFormatter());

    // Wraps a NumberFormatter to map empty strings to -1 and vice versa.
    Integer emptyValue = new Integer(-1);
    JFormattedTextField numberOrEmptyValueField = new JFormattedTextField(new EmptyNumberFormatter(emptyValue));
    numberOrEmptyValueField.setValue(emptyValue);

    // Commits values on valid edit texts.
    DefaultFormatter formatter = new NumberFormatter();
    formatter.setCommitsOnValidEdit(true);
    JFormattedTextField commitOnValidEditField = new JFormattedTextField(formatter);

    // Returns number values of type Integer
    NumberFormatter numberFormatter = new NumberFormatter();
    numberFormatter.setValueClass(Integer.class);
    JFormattedTextField integerField = new JFormattedTextField(numberFormatter);

    Format displayFormat = new DisplayFormat(NumberFormat.getIntegerInstance());
    Format typedDisplayFormat = new DisplayFormat(NumberFormat.getIntegerInstance(), true);
    List fields = new LinkedList();
    fields.add(Utils.appendRow(builder, "Default", defaultNumberField, typedDisplayFormat));
    fields.add(Utils.appendRow(builder, "No initial value", noInitialValueField, displayFormat));
    fields.add(Utils.appendRow(builder, "Empty <-> null", numberOrNullField, displayFormat));
    fields.add(Utils.appendRow(builder, "Empty <->   -1", numberOrEmptyValueField, displayFormat));
    fields.add(Utils.appendRow(builder, "Custom format", customFormatField, displayFormat));
    fields.add(Utils.appendRow(builder, "Custom formatter", customFormatterField, displayFormat));
    fields.add(Utils.appendRow(builder, "Formatter factory", formatterFactoryField, displayFormat));
    fields.add(Utils.appendRow(builder, "Commits on valid edit", commitOnValidEditField, displayFormat));
    fields.add(Utils.appendRow(builder, "Integer Result", integerField, typedDisplayFormat));

    return fields;
}

From source file:net.sourceforge.squirrel_sql.plugins.sqlscript.table_script.CreateFileOfCurrentSQLCommand.java

/**
 * Do the work./*from  w w w . j a  va2 s. co m*/
 * @param owner
 */
private void doCreateFileOfCurrentSQL(JFrame owner) {
    try {

        ISQLConnection unmanagedConnection = null;
        try {
            unmanagedConnection = createUnmanagedConnection();

            // TODO maybe, we should use a SQLExecutorTask for taking advantage of some ExecutionListeners like the parameter replacement. But how to get the right Listeners?
            if (unmanagedConnection != null) {

                stmt = createStatementForStreamingResults(unmanagedConnection.getConnection());
            } else {
                stmt = createStatementForStreamingResults(getSession().getSQLConnection().getConnection());
            }

            ProgressAbortFactoryCallback progressFactory = new ProgressAbortFactoryCallback() {
                @Override
                public ProgressAbortCallback create() {
                    createProgressAbortDialog();
                    return progressDialog;
                }
            };

            StopWatch stopWatch = new StopWatch();
            stopWatch.start();

            DialectType dialectType = DialectFactory.getDialectType(getSession().getMetaData());
            resultSetExportCommand = new ResultSetExportCommand(stmt, currentSQL, dialectType, progressFactory);
            resultSetExportCommand.execute(owner);

            stopWatch.stop();

            if (isAborted()) {
                return;
            } else if (resultSetExportCommand.getWrittenRows() >= 0) {
                NumberFormat nf = NumberFormat.getIntegerInstance();

                String rows = nf.format(resultSetExportCommand.getWrittenRows());
                File targetFile = resultSetExportCommand.getTargetFile();
                String seconds = nf.format(stopWatch.getTime() / 1000);
                String msg = s_stringMgr.getString("CreateFileOfCurrentSQLCommand.progress.sucessMessage", rows,
                        targetFile, seconds);
                getSession().showMessage(msg);
            }
        } finally {
            SQLUtilities.closeStatement(stmt);
            if (unmanagedConnection != null) {
                unmanagedConnection.close();
            }
        }
    } catch (Exception e) {
        if (e.getCause() != null) {
            getSession().showErrorMessage(e.getCause());
        }
        getSession().showErrorMessage(e.getMessage());
    } finally {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                hideProgressMonitor();
            }
        });
    }
}

From source file:org.mapfish.print.config.Config.java

public void printClientConfig(JSONWriter json) throws JSONException {
    json.key("scales");
    json.array();//from w ww.java 2  s  .  co  m
    for (Integer scale : scales) {
        json.object();
        json.key("name").value("1:" + NumberFormat.getIntegerInstance().format(scale));
        json.key("value").value(scale.toString());
        json.endObject();
    }
    json.endArray();

    json.key("dpis");
    json.array();
    for (Integer dpi : dpis) {
        json.object();
        json.key("name").value(dpi.toString());
        json.key("value").value(dpi.toString());
        json.endObject();
    }
    json.endArray();

    json.key("outputFormats");
    json.array();
    for (String format : outputFactory.getSupportedFormats(this)) {
        json.object();
        json.key("name").value(format);
        json.endObject();
    }
    json.endArray();

    json.key("layouts");
    json.array();
    ArrayList<String> sortedLayouts = new ArrayList<String>();
    sortedLayouts.addAll(layouts.keySet());
    Collections.sort(sortedLayouts);
    for (int i = 0; i < sortedLayouts.size(); i++) {
        String key = sortedLayouts.get(i);
        json.object();
        json.key("name").value(key);
        layouts.get(key).printClientConfig(json);
        json.endObject();
    }
    json.endArray();
}

From source file:com.att.aro.main.FileTypesChartPanel.java

/**
 * Initializes the File Type chart./* w w w  . ja v  a  2  s.c  o  m*/
 */
private void initialize() {
    JFreeChart chart = ChartFactory.createBarChart(rb.getString("chart.filetype.title"), null,
            rb.getString("simple.percent"), null, PlotOrientation.HORIZONTAL, false, false, false);

    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(.5f);
    domainAxis.setLabelFont(AROUIManager.LABEL_FONT);
    domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(0.0, 100.0);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {

            FileTypeSummary summary = content.get(column);

            return MessageFormat.format(rb.getString("chart.filetype.tooltip"),
                    NumberFormat.getIntegerInstance().format(summary.getBytes()));
        }
    });

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    BarPainter painter = new StandardBarPainter();
    renderer.setBarPainter(painter);
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(0.1);

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, 400, ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT,
            ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER,
            PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS);

    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    this.add(chartPanel, BorderLayout.CENTER);
}

From source file:com.att.aro.ui.view.overviewtab.FileTypesChartPanel.java

private JFreeChart initializeChart() {
    JFreeChart chart = ChartFactory.createBarChart(
            ResourceBundleHelper.getMessageString("chart.filetype.title"), null,
            ResourceBundleHelper.getMessageString("simple.percent"), null, PlotOrientation.HORIZONTAL, false,
            false, false);/*from   w w  w.jav a 2 s .c om*/

    //chart.setBackgroundPaint(fileTypePanel.getBackground());
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.cPlot = chart.getCategoryPlot();
    cPlot.setBackgroundPaint(Color.white);
    cPlot.setDomainGridlinePaint(Color.gray);
    cPlot.setRangeGridlinePaint(Color.gray);
    cPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis domainAxis = cPlot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(.5f);
    domainAxis.setLabelFont(AROUIManager.LABEL_FONT);
    domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) cPlot.getRangeAxis();
    rangeAxis.setRange(0.0, 100.0);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {

            FileTypeSummary summary = fileTypeContent.get(column);

            return MessageFormat.format(ResourceBundleHelper.getMessageString("chart.filetype.tooltip"),
                    NumberFormat.getIntegerInstance().format(summary.getBytes()));
        }
    });

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    BarPainter painter = new StandardBarPainter();
    renderer.setBarPainter(painter);
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(0.1);

    cPlot.setRenderer(renderer);
    cPlot.getDomainAxis().setMaximumCategoryLabelLines(2);

    return chart;
}

From source file:savant.chromatogram.ChromatogramPlugin.java

@Override
public void init(JPanel panel) {

    NavigationUtils.addLocationChangedListener(new Listener<LocationChangedEvent>() {
        @Override//from  w w  w .  ja va  2  s. c om
        public void handleEvent(LocationChangedEvent event) {
            updateChromatogram();
        }
    });
    GenomeUtils.addGenomeChangedListener(new Listener<GenomeChangedEvent>() {
        @Override
        public void handleEvent(GenomeChangedEvent event) {
            updateChromatogram();
        }
    });
    panel.setLayout(new GridBagLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.EAST;
    panel.add(new JLabel("File:"), gbc);

    pathField = new JTextField();
    gbc.gridwidth = 3;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel.add(pathField, gbc);

    JButton browseButton = new JButton("Browse\u2026");
    browseButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            File f = DialogUtils.chooseFileForOpen("Chromatogram File", null, null);
            if (f != null) {
                try {
                    pathField.setText(f.getAbsolutePath());
                    if (canvas != null) {
                        canvas.getParent().remove(canvas);
                        canvas = null;
                    }
                    chromatogram = ChromatogramFactory.create(f);
                    updateEndField();
                    updateChromatogram();
                } catch (UnsupportedChromatogramFormatException x) {
                    DialogUtils.displayMessage("Unable to Open Chromatogram", String.format(
                            "<html><i>%s</i> does not appear to be a valid chromatogram file.<br><br><small>Supported formats are ABI and SCF.</small></html>",
                            f.getName()));
                } catch (Exception x) {
                    DialogUtils.displayException("Unable to Open Chromatogram",
                            String.format("<html>There was an error opening <i>%s</i>.</html>", f.getName()),
                            x);
                }
            }
        }
    });
    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    panel.add(browseButton, gbc);

    JLabel startLabel = new JLabel("Start Base:");
    gbc.gridy++;
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.EAST;
    panel.add(startLabel, gbc);

    startField = new JTextField("0");
    startField.setColumns(12);
    startField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            updateEndField();
        }
    });
    gbc.weightx = 0.5;
    gbc.anchor = GridBagConstraints.WEST;
    panel.add(startField, gbc);

    JLabel endLabel = new JLabel("End Base:");
    gbc.weightx = 0.0;
    gbc.anchor = GridBagConstraints.EAST;
    panel.add(endLabel, gbc);

    endField = new JTextField();
    endField.setColumns(12);
    endField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            try {
                NumberFormat numberParser = NumberFormat.getIntegerInstance();
                int endBase = numberParser.parse(endField.getText()).intValue();
                if (chromatogram != null) {
                    int startBase = endBase - chromatogram.getSequenceLength();
                    startField.setText(String.valueOf(startBase));
                    if (canvas != null) {
                        canvas.updatePos(startBase);
                    }
                }
            } catch (ParseException x) {
                Toolkit.getDefaultToolkit().beep();
            }
        }
    });
    gbc.weightx = 0.5;
    gbc.anchor = GridBagConstraints.WEST;
    panel.add(endField, gbc);

    JCheckBox fillCheck = new JCheckBox("Fill Background");
    fillCheck.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            canvas.updateFillbackground(((JCheckBox) ae.getSource()).isSelected());
        }
    });
    gbc.gridy++;
    gbc.gridx = 1;
    gbc.weightx = 0.0;
    panel.add(fillCheck, gbc);

    // Add a filler panel at the bottom to force our components to the top.
    gbc.gridy++;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1.0;
    panel.add(new JPanel(), gbc);
}