Example usage for javax.swing JTextField setAutoscrolls

List of usage examples for javax.swing JTextField setAutoscrolls

Introduction

In this page you can find the example usage for javax.swing JTextField setAutoscrolls.

Prototype

@BeanProperty(bound = false, expert = true, description = "Determines if this component automatically scrolls its contents when dragged.")
public void setAutoscrolls(boolean autoscrolls) 

Source Link

Document

Sets the autoscrolls property.

Usage

From source file:regresiones.RegresionMultiple.java

private void pintar(Double[] Yestimada, JTabbedPane resultados, Double[][] auxiliar) {
    // mostramos resultados para la pestaa resultados***********************************************************************
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(Color.white);
    JLabel titulo = new JLabel("Resultados");//creamos el titulo
    panel.add(titulo, BorderLayout.PAGE_START);//lo agregamos al inicio
    jtable = new JTable();//creamos la tabla a mostrar
    jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable.setFont(new java.awt.Font("Arial", 1, 14));
    jtable.setColumnSelectionAllowed(true);
    jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable.setInheritsPopupMenu(true);//from ww  w  .  j a v  a  2 s .  co  m
    jtable.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos = { "X1", "X2", "Y", "Y estimada", "X1^2", "X2^2", "X1*Y", "X2*Y", "Y-Y estimada" };//los titulos de la tabla
    arregloFinal = new String[N][9];
    DecimalFormat formato = new DecimalFormat("0.00");
    for (int i = 0; i < N; i++) {//armamos el arreglo
        arregloFinal[i][0] = datos[i][0] + "";
        arregloFinal[i][1] = datos[i][1] + "";
        arregloFinal[i][2] = datos[i][2] + "";
        arregloFinal[i][3] = formato.format(Yestimada[i]);
        arregloFinal[i][4] = formato.format(auxiliar[i][0]);
        arregloFinal[i][5] = formato.format(auxiliar[i][1]);
        arregloFinal[i][6] = formato.format(auxiliar[i][2]);
        arregloFinal[i][7] = formato.format(auxiliar[i][3]);
        arregloFinal[i][8] = formato.format(auxiliar[i][4]);
    }
    DefaultTableModel TableModel = new DefaultTableModel(arregloFinal, titulos);
    jtable.setModel(TableModel);
    JScrollPane jScrollPane1 = new JScrollPane();
    jScrollPane1.setViewportView(jtable);
    jtable.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    panel.add(jScrollPane1, BorderLayout.CENTER);
    JPanel panel2 = new JPanel(new GridLayout(0, 6));//creo un panel con rejilla de 4 columnas
    JLabel etiquetaN = new JLabel("N");
    JTextField cajaN = new JTextField();
    cajaN.setText(N + "");
    cajaN.setEditable(false);

    JLabel etiquetaK = new JLabel("K");
    JTextField cajaK = new JTextField();
    cajaK.setText("2");
    cajaK.setEditable(false);

    JLabel etiquetab0 = new JLabel("b0");
    JTextField cajab0 = new JTextField();
    cajab0.setText(formato.format(b0) + "");
    cajab0.setEditable(false);

    JLabel etiquetab1 = new JLabel("b1");
    JTextField cajab1 = new JTextField();
    cajab1.setText(formato.format(b1) + "");
    cajab1.setEditable(false);

    JLabel etiquetab2 = new JLabel("b2");
    JTextField cajab2 = new JTextField();
    cajab2.setText(formato.format(b2) + "");
    cajab2.setEditable(false);

    JLabel etiquetaSe = new JLabel("Se");
    JTextField cajaSe = new JTextField();
    cajaSe.setText(Se + "");
    cajaSe.setEditable(false);
    cajaSe.setAutoscrolls(true);

    JButton botonI = new JButton("Exportar a PDF");
    botonI.addActionListener(this);

    panel2.add(etiquetaN);
    panel2.add(cajaN);
    panel2.add(etiquetaK);
    panel2.add(cajaK);
    panel2.add(etiquetab2);
    panel2.add(etiquetab0);
    panel2.add(cajab0);
    panel2.add(etiquetab1);
    panel2.add(cajab1);
    panel2.add(etiquetab2);
    panel2.add(cajab2);
    panel2.add(etiquetaSe);
    panel2.add(cajaSe);
    panel2.add(botonI);
    panel.add(panel2, BorderLayout.SOUTH);//agrego el panel2 con rejilla en el panel principal al sur
    resultados.addTab("resultado", panel);
    //**************************************************************************************
    //intervalos de confianza
    JPanel intervalos = new JPanel(new BorderLayout());
    JPanel variables = new JPanel(new GridLayout(0, 2));
    JLabel variableX1 = new JLabel("X1");
    cajaVariableX1 = new JTextField();
    JLabel variableX2 = new JLabel("X2");
    cajaVariableX2 = new JTextField();
    boton = new JButton("calcular");
    boton.addActionListener(this);
    JLabel variableEfectividad = new JLabel("Efectividad");
    String[] efectividades = { "80", "85", "90", "95", "99" };
    combo = new JComboBox(efectividades);
    variables.add(variableX1);
    variables.add(cajaVariableX1);
    variables.add(variableX2);
    variables.add(cajaVariableX2);
    variables.add(variableEfectividad);
    variables.add(combo);
    variables.add(boton);
    intervalos.add(variables, BorderLayout.NORTH);
    jtable2 = new JTable();//creamos la tabla a mostrar
    jtable2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable2.setFont(new java.awt.Font("Arial", 1, 14));
    jtable2.setColumnSelectionAllowed(true);
    jtable2.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable2.setInheritsPopupMenu(true);
    jtable2.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla
    String[][] pruebaIntervalos = { { "", "", "" } };
    DefaultTableModel TableModel2 = new DefaultTableModel(pruebaIntervalos, titulos2);
    jtable2.setModel(TableModel2);
    JScrollPane jScrollPane2 = new JScrollPane();
    jScrollPane2.setViewportView(jtable2);
    jtable2.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    intervalos.add(jScrollPane2, BorderLayout.CENTER);
    resultados.addTab("intervalos", intervalos);
    //***************************************************************************
    JPanel graficas = new JPanel(new GridLayout(0, 1));
    XYDataset dataset = createSampleDataset(Yestimada, 1);
    JFreeChart chart = ChartFactory.createXYLineChart("Grafica 1 - X1", "X", "Y", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);
    plot.setRenderer(renderer);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    graficas.add(chartPanel);//agregamos la primer grafica
    //********** creamos la segunda grafica
    XYDataset dataset2 = createSampleDataset(Yestimada, 2);
    JFreeChart chart2 = ChartFactory.createXYLineChart("Grafica 2 -X2", "X", "Y", dataset2,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot2 = (XYPlot) chart2.getPlot();
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, true);
    renderer2.setSeriesShapesVisible(0, true);
    renderer2.setSeriesLinesVisible(1, true);
    renderer2.setSeriesShapesVisible(1, true);
    plot2.setRenderer(renderer2);
    final ChartPanel chartPanel2 = new ChartPanel(chart2);
    chartPanel2.setPreferredSize(new java.awt.Dimension(500, 300));
    graficas.add(chartPanel2);
    resultados.addTab("graficas", graficas);
}