Example usage for javax.swing JCheckBox JCheckBox

List of usage examples for javax.swing JCheckBox JCheckBox

Introduction

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

Prototype

public JCheckBox() 

Source Link

Document

Creates an initially unselected check box button with no text, no icon.

Usage

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();/*from   w w  w .ja  v  a  2s . c  om*/
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null) {
                startMovie();
            } else {
                stopMovie();
            }
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            if (newValue > MAXIMUM_SCALE) {
                newValue = currentValue;
            }
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java

private JPanel createCordinatePanel() {
    JPanel wrap = new JPanel(new BorderLayout());

    JPanel coordinate = new JPanel(new GridLayout(3, 1));
    coordinate.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    //Horizontal group
    JPanel horizontal = new JPanel(new BorderLayout());
    horizontal/*from   w  w  w  .j av  a2 s  .  c  om*/
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Horizontal Axis"));

    JPanel inner = new JPanel(new LCBLayout(6));
    inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    inner.add(new JLabel("Flip X Axis"));
    flipX = new JCheckBox();
    flipX.setActionCommand(FLIP_X_AXIS_COMMAND);
    flipX.addActionListener(this);
    inner.add(flipX);
    inner.add(new JLabel());

    horizontal.add(inner, BorderLayout.NORTH);

    //Vertical group
    JPanel vertical = new JPanel(new BorderLayout());
    vertical.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Vertical Axis"));

    inner = new JPanel(new LCBLayout(6));
    inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    inner.add(new JLabel("Flip Y Axis"));
    flipY = new JCheckBox();
    flipY.setActionCommand(FLIP_Y_AXIS_COMMAND);
    flipY.addActionListener(this);
    inner.add(flipY);
    inner.add(new JLabel());

    vertical.add(inner, BorderLayout.NORTH);

    //Color scale group
    JPanel colorScale = new JPanel(new BorderLayout());
    colorScale.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Color Scale"));

    inner = new JPanel(new LCBLayout(6));
    inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    inner.add(new JLabel("Show Color Scale"));
    showColorScale = new JCheckBox();
    showColorScale.setActionCommand(SHOW_SCALE_COMMAND);
    showColorScale.addActionListener(this);
    inner.add(showColorScale);
    inner.add(new JLabel());

    inner.add(new JLabel("Select Theme"));
    ColorScale[] scales = ColorScale.values();
    colourScaleCombo = new JComboBox(scales);
    //      colourScaleCombo.setMaximumRowCount(7);
    colourScaleCombo.setActionCommand(CHANGE_COLOUR_SCALE_COMMAND);
    colourScaleCombo.addActionListener(this);
    inner.add(colourScaleCombo);
    inner.add(new JLabel());

    inner.add(new JLabel("Use Logarithmic Scale"));
    logarithmScale = new JCheckBox();
    logarithmScale.setActionCommand(LOGARITHM_SCALE_COMMAND);
    logarithmScale.addActionListener(this);
    inner.add(logarithmScale);
    inner.add(new JLabel());

    colorScale.add(inner, BorderLayout.NORTH);

    coordinate.add(horizontal);
    coordinate.add(vertical);
    coordinate.add(colorScale);
    wrap.setName("Coordinate");

    wrap.add(coordinate, BorderLayout.NORTH);
    return wrap;
}

From source file:com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL//w ww.j  av a  2s . com
 */
private void $$$setupUI$$$() {
    createUIComponents();
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(10, 3, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.setName("");
    final JLabel label1 = new JLabel();
    this.$$$loadLabelText$$$(label1, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoCheckoutForm.SelectRepository"));
    contentPanel.add(label1,
            new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    repositoryFilter = new JTextField();
    repositoryFilter.setName("");
    contentPanel.add(repositoryFilter,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    final JLabel label2 = new JLabel();
    this.$$$loadLabelText$$$(label2, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoCheckoutForm.ParentDirectory"));
    contentPanel.add(label2,
            new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JLabel label3 = new JLabel();
    this.$$$loadLabelText$$$(label3, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoCheckoutForm.DirectoryName"));
    contentPanel.add(label3,
            new GridConstraints(7, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    directoryName = new JTextField();
    directoryName.setName("");
    contentPanel.add(directoryName,
            new GridConstraints(8, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    contentPanel.add(userAccountPanel,
            new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    repositoryTableScrollPane = new JScrollPane();
    contentPanel.add(repositoryTableScrollPane,
            new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    repositoryTable = new JTable();
    repositoryTable.setFillsViewportHeight(true);
    repositoryTable.setName("");
    repositoryTable.setShowHorizontalLines(false);
    repositoryTable.setShowVerticalLines(false);
    repositoryTableScrollPane.setViewportView(repositoryTable);
    parentDirectory = new TextFieldWithBrowseButton();
    contentPanel.add(parentDirectory,
            new GridConstraints(6, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    refreshButton = new JButton();
    refreshButton.setIcon(new ImageIcon(getClass().getResource("/actions/refresh.png")));
    refreshButton.setText("");
    refreshButton.setToolTipText(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("CheckoutDialog.RefreshButton.ToolTip"));
    contentPanel.add(refreshButton,
            new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    busySpinner = new BusySpinnerPanel();
    contentPanel.add(busySpinner,
            new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    helpPanel = new HelpPanel();
    helpPanel.setHelpText(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoLookupHelp.helpText"));
    helpPanel.setPopupText(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin")
            .getString("VsoLookupHelp.Instructions"));
    contentPanel.add(helpPanel,
            new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    advancedCheckBox = new JCheckBox();
    advancedCheckBox.setText("example text");
    contentPanel.add(advancedCheckBox,
            new GridConstraints(9, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}

From source file:net.sf.profiler4j.console.ProjectDialog.java

JCheckBox getExportCheckBox() {
    if (null == exportCheckBox) {
        exportCheckBox = new JCheckBox();
        exportCheckBox.setSelected(false);
        exportCheckBox.setText("Export call graph on each snapshot");
        exportCheckBox.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                exportPatternText.setEnabled(exportCheckBox.isSelected());
            }/*w  w  w  .  j a  va  2  s  . co m*/
        });
    }
    return exportCheckBox;
}

From source file:com.aw.swing.mvp.binding.component.BndSJTable.java

private void configureEditableCell(TableColumn col, ColumnInfo columnInfo) {
    TableCellRenderer tableCellRenderer = new DefaultEditableCellRenderer(columnInfo);
    ((DefaultTableCellRenderer) tableCellRenderer).setHorizontalAlignment(columnInfo.getAlignment());

    TableCellEditor tableCellEditor = null;
    Font font = ((DefaultEditableCellRenderer) tableCellRenderer).getFont();
    if (columnInfo.getCellEditorValuesProvider() != null) {
        JComponentCellRenderer jComponentCellRenderer = new JComponentCellRenderer();
        JComponentCellEditor jComponentCellEditor = new JComponentCellEditor(columnInfo, font);
        jComponentCellEditor.setCellRenderer(jComponentCellRenderer);
        jComponentCellEditor.setCellEditorProvider(columnInfo.getCellEditorValuesProvider());
        col.setCellRenderer(jComponentCellRenderer);
        col.setCellEditor(jComponentCellEditor);
        columnInfo.setSpecialCellRenderer(jComponentCellRenderer);
        return;//from   ww w.j a v  a 2  s  . co  m
    }
    if (columnInfo.getColumnEditorType() == ColumnInfo.TEXT_BOX) {
        ((DefaultEditableCellRenderer) tableCellRenderer).setCellColorChanger(cellColorChanger);
        tableCellEditor = CellEditorFactory.getJTextFielCellEditor(columnInfo, jTable, font);
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.TEXT_AREA) {
        tableCellEditor = new JTextAreaCellEditor(getJTable(), columnInfo, font);
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.CHECK_BOX) {
        tableCellRenderer = new JCheckBoxCellRenderer(columnInfo, columnInfo.getValueTrue());
        ((JCheckBoxCellRenderer) tableCellRenderer).setBndSJTable(this);
        tableCellEditor = CellEditorFactory.getJCheckBoxEditor(columnInfo, jTable,
                getCellEditableFocusListener());
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.RADIO_BUTTON) {
        tableCellRenderer = new JRadioButtonCellRenderer(columnInfo.getValueTrue());
        tableCellEditor = new JRadioButtonCellEditor(new JCheckBox(), columnInfo.getValueTrue());
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.COMBO_BOX) {

        if (columnInfo.hasParentCmps()) {
            CellDropDownProvider cellDropDownProvider = columnInfo.getCellDropDownProvider(this);
            tableCellRenderer = new JComboBoxDependentCellRenderer(columnInfo,
                    new JComboBoxDependentCellRendererModel(cellDropDownProvider));
            JComboBoxDependentCellEditorModel comboBoxModel = new JComboBoxDependentCellEditorModel(
                    cellDropDownProvider);
            final JComboBox jComboBox = getJComboBox(comboBoxModel);

            JComboBoxDependentCellEditor jComboBoxCellEditor = new JComboBoxDependentCellEditor(jComboBox);
            tableCellEditor = jComboBoxCellEditor;

        } else {
            JComboBoxCellRenderer comboBoxCellRenderer = new JComboBoxCellRenderer(columnInfo,
                    new JComboBoxCellRendererModel(columnInfo.getMetaLoader()));
            comboBoxCellRenderer.setEditingRowPolicy(editingRowPolicy);
            tableCellRenderer = comboBoxCellRenderer;

            JComboBoxCellEditorModel comboBoxModel = new JComboBoxCellEditorModel();
            comboBoxModel.setMetaLoader(columnInfo.getMetaLoader());
            final JComboBox jComboBox = getJComboBox(comboBoxModel);

            JComboBoxCellEditor jComboBoxCellEditor = new JComboBoxCellEditor(jComboBox);
            jComboBoxCellEditor.setCol(columnInfo.getIdx());
            tableCellEditor = jComboBoxCellEditor;
        }
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.FILE_CHOOSER) {
        tableCellEditor = new JFileChooserCellEditor();
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.BUTTON) {
        tableCellEditor = new JButtonCellEditor(columnInfo);
        tableCellRenderer = new JButtonCellRenderer();
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.LINK) {
        tableCellEditor = new JLabelLinkCellEditor(columnInfo);
        //tableCellEditor = new JLabelLinkCellRenderer();
        JLabelLinkCellRenderer linkCellRenderer = new JLabelLinkCellRenderer();
        linkCellRenderer.setColumnInfo(columnInfo);
        linkCellRenderer.setCellColorChanger(cellColorChanger);
        linkCellRenderer.setHorizontalAlignment(columnInfo.getAlignment());
        linkCellRenderer.setTableEditable(isEditable());
        if (isAuditingColumn(columnInfo.getFieldName())) {
            linkCellRenderer.setCustomBackground(AUDITING_COLUMN_COLOR);
        }
        tableCellRenderer = linkCellRenderer;

    }
    col.setCellRenderer(tableCellRenderer);
    col.setCellEditor(tableCellEditor);
}

From source file:AST.DesignPatternDetection.java

private void initComponents() {

    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Murat Oruc
    btPathFinder = new JButton();
    label1 = new JLabel();
    tfPath = new JTextField();
    label2 = new JLabel();
    cbSelectionDP = new JComboBox<>();
    btRun = new JButton();
    label3 = new JLabel();
    tfProjectName = new JTextField();
    label4 = new JLabel();
    tfThreshold = new JTextField();
    chbOverlap = new JCheckBox();
    btRunSgiso = new JButton();
    scrollPane1 = new JScrollPane();
    taInfo = new JTextArea();
    label5 = new JLabel();
    tfProgramPath = new JTextField();
    btProgramPath = new JButton();
    button1 = new JButton();
    button2 = new JButton();
    chbInnerClass = new JCheckBox();

    //======== this ========
    setTitle("DesPaD (Design Pattern Detector)");
    setIconImage(((ImageIcon) UIManager.getIcon("FileView.computerIcon")).getImage());
    addWindowListener(new WindowAdapter() {
        @Override//from   ww  w.  j  av  a2s  . co m
        public void windowClosing(WindowEvent e) {
            thisWindowClosing(e);
        }
    });
    Container contentPane = getContentPane();

    //---- btPathFinder ----
    btPathFinder.setText("...");
    btPathFinder.setFont(btPathFinder.getFont().deriveFont(btPathFinder.getFont().getSize() + 1f));
    btPathFinder.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btPathFinderActionPerformed(e);
        }
    });

    //---- label1 ----
    label1.setText("Source Code Directory Path");

    //---- tfPath ----
    tfPath.setText("...");
    tfPath.setEditable(false);
    tfPath.setForeground(Color.blue);
    tfPath.setFont(tfPath.getFont().deriveFont(tfPath.getFont().getStyle() | Font.BOLD));

    //---- label2 ----
    label2.setText("Select Design Pattern");

    //---- cbSelectionDP ----
    cbSelectionDP.setModel(new DefaultComboBoxModel<>(
            new String[] { "FACTORY_METHOD", "PROTOTYPE", "ABSTRACT_FACTORY", "BUILDER", "SINGLETON",
                    "COMPOSITE", "FACADE", "DECORATOR", "DECORATOR2", "BRIDGE", "FLYWEIGHT", "ADAPTER", "PROXY",
                    "MEDIATOR", "STATE", "OBSERVER", "TEMPLATE_METHOD", "TEMPLATE_METHOD2", "COMMAND",
                    "CHAIN_OF_RESPONSIBILITY", "INTERPRETER", "MEMENTO", "ITERATOR", "STRATEGY", "VISITOR" }));

    //---- btRun ----
    btRun.setText("1. Build Model Graph");
    btRun.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                btRunActionPerformed(e);
            } catch (IOException | InterruptedException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //---- label3 ----
    label3.setText("Project Name");

    //---- label4 ----
    label4.setText("Threshold");

    //---- tfThreshold ----
    tfThreshold.setText("0.0");

    //---- chbOverlap ----
    chbOverlap.setText("Overlap");

    //---- btRunSgiso ----
    btRunSgiso.setText("2. Run Subdue-Sgiso Algorithm");
    btRunSgiso.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                btRunSgisoActionPerformed(e);
            } catch (IOException | InterruptedException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //======== scrollPane1 ========
    {
        scrollPane1.setViewportView(taInfo);
    }

    //---- label5 ----
    label5.setText("Program Directory Path");

    //---- tfProgramPath ----
    tfProgramPath.setEditable(false);
    tfProgramPath.setForeground(Color.blue);
    tfProgramPath.setFont(tfProgramPath.getFont().deriveFont(tfProgramPath.getFont().getStyle() | Font.BOLD));

    //---- btProgramPath ----
    btProgramPath.setText("...");
    btProgramPath.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btProgramPathActionPerformed(e);
        }
    });

    //---- button1 ----
    button1.setText("3. Exclude overlap outputs");
    button1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                button1ActionPerformed(e);
            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //---- button2 ----
    button2.setText("4. Graph Representations");
    button2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                button2ActionPerformed(e);
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //---- chbInnerClass ----
    chbInnerClass.setText("Include Inner Classes");
    chbInnerClass.setSelected(true);

    GroupLayout contentPaneLayout = new GroupLayout(contentPane);
    contentPane.setLayout(contentPaneLayout);
    contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout.createSequentialGroup()
                    .addContainerGap().addGroup(contentPaneLayout
                            .createParallelGroup().addGroup(GroupLayout.Alignment.TRAILING,
                                    contentPaneLayout.createSequentialGroup().addComponent(label1).addGap(21,
                                            433, Short.MAX_VALUE))
                            .addGroup(contentPaneLayout
                                    .createSequentialGroup().addGroup(contentPaneLayout.createParallelGroup()
                                            .addComponent(label4).addGroup(contentPaneLayout
                                                    .createSequentialGroup().addGroup(contentPaneLayout
                                                            .createParallelGroup(GroupLayout.Alignment.TRAILING,
                                                                    false)
                                                            .addComponent(
                                                                    button1, GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(tfThreshold,
                                                                    GroupLayout.Alignment.LEADING)
                                                            .addComponent(cbSelectionDP,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(label2, GroupLayout.Alignment.LEADING)
                                                            .addComponent(
                                                                    btRun, GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE))
                                                    .addGap(30, 30, 30)
                                                    .addGroup(contentPaneLayout
                                                            .createParallelGroup(GroupLayout.Alignment.LEADING,
                                                                    false)
                                                            .addComponent(label3)
                                                            .addComponent(tfProjectName,
                                                                    GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE)
                                                            .addGroup(contentPaneLayout.createSequentialGroup()
                                                                    .addComponent(chbOverlap)
                                                                    .addPreferredGap(
                                                                            LayoutStyle.ComponentPlacement.RELATED,
                                                                            GroupLayout.DEFAULT_SIZE,
                                                                            Short.MAX_VALUE)
                                                                    .addComponent(chbInnerClass))
                                                            .addComponent(btRunSgiso, GroupLayout.DEFAULT_SIZE,
                                                                    260, Short.MAX_VALUE)
                                                            .addComponent(
                                                                    button2, GroupLayout.DEFAULT_SIZE, 260,
                                                                    Short.MAX_VALUE))))
                                    .addGap(0, 56, Short.MAX_VALUE))
                            .addGroup(GroupLayout.Alignment.TRAILING,
                                    contentPaneLayout.createSequentialGroup().addGroup(contentPaneLayout
                                            .createParallelGroup(GroupLayout.Alignment.TRAILING)
                                            .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 594,
                                                    Short.MAX_VALUE)
                                            .addGroup(contentPaneLayout.createSequentialGroup()
                                                    .addGroup(contentPaneLayout.createParallelGroup()
                                                            .addGroup(contentPaneLayout.createSequentialGroup()
                                                                    .addComponent(label5)
                                                                    .addGap(0, 418, Short.MAX_VALUE))
                                                            .addComponent(tfProgramPath,
                                                                    GroupLayout.DEFAULT_SIZE, 564,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(
                                                                    tfPath, GroupLayout.Alignment.TRAILING,
                                                                    GroupLayout.DEFAULT_SIZE, 564,
                                                                    Short.MAX_VALUE))
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addGroup(contentPaneLayout
                                                            .createParallelGroup(GroupLayout.Alignment.LEADING,
                                                                    false)
                                                            .addComponent(btPathFinder,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(btProgramPath,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    Short.MAX_VALUE))))
                                            .addContainerGap()))));
    contentPaneLayout.setVerticalGroup(contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout
            .createSequentialGroup().addGap(29, 29, 29).addComponent(label1).addGap(5, 5, 5)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(tfPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(btPathFinder, GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE))
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(label5)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(tfProgramPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(btProgramPath))
            .addGap(18, 18, 18)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(label2)
                    .addComponent(label3))
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(cbSelectionDP, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfProjectName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18).addComponent(label4).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(tfThreshold, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(chbOverlap).addComponent(chbInnerClass))
            .addGap(18, 18, 18)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(btRun, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btRunSgiso, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                    .addComponent(button2, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                    .addComponent(button1, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE))
            .addGap(18, 18, 18).addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
            .addContainerGap()));
    setSize(630, 625);
    setLocationRelativeTo(null);
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:gtu._work.etc.EnglishTester.java

private void initGUI() {
    try {/*w w  w.j  av a 2s  .c o m*/
        JCommonUtil.defaultToolTipDelay();
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            jTabbedPane1.setPreferredSize(new java.awt.Dimension(462, 259));

            jTabbedPane1.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    // XXX
                    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                    jTabbedPane1.requestFocus();// FOCUS TODO
                    // XXX
                    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                }
            });
            jTabbedPane1.addKeyListener(new KeyAdapter() {
                public void keyPressed(KeyEvent evt) {
                    System.out.println("2===" + evt.getKeyCode());
                    if (evt.getKeyCode() == 49) {// 0
                        jTabbedPane1.setSelectedIndex(0);
                    }
                    if (evt.getKeyCode() == 50) {// 1
                        jTabbedPane1.setSelectedIndex(1);
                    }
                    if (evt.getKeyCode() == 10) {// enter
                        skipBtnAction();
                    }
                    if (evt.getKeyCode() == 32) {// 
                        removeBtnAction();
                    }
                }
            });
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("english", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(420, 141));
                    {
                        englishArea = new JTextArea();
                        jScrollPane1.setViewportView(englishArea);
                        englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, 22));
                    }
                }
                {
                    jPanel5 = new JPanel();
                    jPanel1.add(jPanel5, BorderLayout.SOUTH);
                    jPanel5.setPreferredSize(new java.awt.Dimension(402, 65));
                    {
                        skipBtn = new JButton();
                        jPanel5.add(skipBtn);
                        skipBtn.setText("skip");
                        skipBtn.setPreferredSize(new java.awt.Dimension(187, 24));
                        skipBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                skipBtnAction();
                            }
                        });
                    }
                    {
                        removeBtn = new JButton();
                        jPanel5.add(removeBtn);
                        removeBtn.setText("remove");
                        removeBtn.setPreferredSize(new java.awt.Dimension(180, 24));
                        removeBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                removeBtnAction();
                            }
                        });
                    }
                    {
                        questionCountLabel = new JLabel();
                        jPanel5.add(questionCountLabel);
                        questionCountLabel.setPreferredSize(new java.awt.Dimension(47, 21));
                        questionCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                        questionCountLabel.setToolTipText("");
                    }
                    {
                        propCountLabel = new JLabel();
                        jPanel5.add(propCountLabel);
                        propCountLabel.setPreferredSize(new java.awt.Dimension(45, 21));
                        propCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                        propCountLabel.setToolTipText("");
                    }
                    {
                        googleSearchBtn = new JButton();
                        jPanel5.add(googleSearchBtn);
                        googleSearchBtn.setText("<html>GPic</html>");
                        googleSearchBtn.setPreferredSize(new java.awt.Dimension(58, 24));
                        googleSearchBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    String word = currentWordIndex.trim();
                                    ClipboardUtil.getInstance().setContents(word);
                                    word = word.replace(" ", "%20");
                                    URI uri = new URI(
                                            "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q="
                                                    + word);
                                    //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + word);
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        yahooDicBtn = new JButton();
                        jPanel5.add(yahooDicBtn);
                        yahooDicBtn.setText("<html>Dict</html>");
                        yahooDicBtn.setPreferredSize(new java.awt.Dimension(57, 24));
                        yahooDicBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    // URI uri = new
                                    // URI("http://tw.dictionary.yahoo.com/dictionary?p="
                                    // + currentWord.trim());
                                    URI uri = new URI("http://www.dreye.com/axis/ddict.jsp?ver=big5&dod=0102&w="
                                            + currentWordIndex.trim() + "&x=0&y=0");
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        pickBtn = new JButton();
                        jPanel5.add(pickBtn);
                        pickBtn.setText("<html>+Pick</html>");
                        pickBtn.setPreferredSize(new java.awt.Dimension(60, 24));
                        pickBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    String key = currentWordIndex;
                                    String value = englishProp.getProperty(currentWordIndex);
                                    if (StringUtils.isEmpty(value)) {
                                        JCommonUtil._jOptionPane_showMessageDialog_error(
                                                "add pick failed : no such word => " + key);
                                    } else {
                                        pickProp.setProperty(key, value);
                                        JCommonUtil._jOptionPane_showMessageDialog_info(
                                                "key=" + key + "\nvalue=" + value + "\nsize=" + pickProp.size(),
                                                "??");
                                    }
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        scanPicBtn = new JButton();
                        scanPicBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                            }
                        });
                        jPanel5.add(scanPicBtn);
                        scanPicBtn.setPreferredSize(new java.awt.Dimension(46, 24));
                        scanPicBtn.addMouseListener(new MouseAdapter() {

                            public void mouseClicked(MouseEvent evt) {
                                if (picDir == null) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null");
                                    return;
                                }

                                if (picSet != null && picSet.size() > 0) {
                                    try {
                                        Desktop.getDesktop().open(picSet.iterator().next());
                                    } catch (IOException e) {
                                        JCommonUtil.handleException(e);
                                    }
                                    return;
                                }

                                try {
                                    String text = currentWordIndex.trim().toLowerCase();
                                    ClipboardUtil.getInstance().setContents(text);
                                    text = text.replace(" ", "%20");
                                    URI uri = new URI(
                                            "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q="
                                                    + text);
                                    //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + text);
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        showChineseOption = new JCheckBox();
                        showChineseOption.setSelected(true);
                        jPanel5.add(showChineseOption);
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("chinese", null, jPanel2, null);
                jPanel2.setPreferredSize(new java.awt.Dimension(420, 211));
                {
                    showEnglishText = new JTextField();
                    jPanel2.add(showEnglishText, BorderLayout.NORTH);
                    showEnglishText.setEditable(false);
                }
                {
                    jPanel10 = new JPanel();
                    jPanel2.add(jPanel10, BorderLayout.CENTER);
                }
                {
                    answerBtn[0] = new JButton();
                    jPanel10.add(answerBtn[0]);
                    answerBtn[0].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[0].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[0]);
                        }
                    });
                }
                {
                    answerBtn[1] = new JButton();
                    jPanel10.add(answerBtn[1]);
                    answerBtn[1].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[1].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[1]);
                        }
                    });
                }
                {
                    answerBtn[2] = new JButton();
                    jPanel10.add(answerBtn[2]);
                    answerBtn[2].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[2].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[2]);
                        }
                    });
                }
                {
                    answerBtn[3] = new JButton();
                    jPanel10.add(answerBtn[3]);
                    answerBtn[3].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[3].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[3]);
                        }
                    });
                }
                {
                    for (int ii = 0; ii < 4; ii++) {
                        answerBtn[ii].setFont(new java.awt.Font("", 0, 14));
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("word", null, jPanel3, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel3.add(jScrollPane3, BorderLayout.CENTER);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(420, 187));
                    {
                        propTable = new JTable();
                        jScrollPane3.setViewportView(propTable);
                        JTableUtil.defaultSetting(propTable);
                        propTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JPopupMenuUtil.newInstance(propTable)
                                        .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems())
                                        .applyEvent(evt).show();
                            }
                        });
                    }
                }
                {
                    saveBtn = new JButton();
                    jPanel3.add(saveBtn, BorderLayout.SOUTH);
                    saveBtn.setText("save table");
                    saveBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            DefaultTableModel model = JTableUtil.newInstance(propTable).getModel();
                            for (int ii = 0; ii < model.getRowCount(); ii++) {
                                String key = (String) model.getValueAt(ii, 0);
                                String value = (String) model.getValueAt(ii, 1);
                                if (!englishProp.containsKey(key)) {
                                    englishProp.setProperty(key, value);
                                }
                            }
                            try {
                                englishProp.store(new FileOutputStream(englishFile), "comment");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            JCommonUtil._jOptionPane_showMessageDialog_info("save file ok!  \n" + englishFile);
                        }
                    });
                }
                {
                    queryText = new JTextField();
                    jPanel3.add(queryText, BorderLayout.NORTH);
                    queryText.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                @Override
                                public void process(DocumentEvent event) {
                                    String text = JCommonUtil.getDocumentText(event);
                                    Pattern pattern = Pattern.compile(text);
                                    Matcher matcher = null;
                                    DefaultTableModel propTableModel = JTableUtil.createModel(false, "english",
                                            "chinese");
                                    for (Enumeration<?> enu = englishProp.propertyNames(); enu
                                            .hasMoreElements();) {
                                        String key = (String) enu.nextElement();
                                        String value = englishProp.getProperty(key);
                                        if (key.contains(text)) {
                                            propTableModel.addRow(new Object[] { key, value });
                                            continue;
                                        }
                                        matcher = pattern.matcher(key);
                                        if (matcher.find()) {
                                            propTableModel.addRow(new Object[] { key, value });
                                            continue;
                                        }
                                    }
                                    propTable.setModel(propTableModel);
                                }
                            }));
                }
            }
            {
                jPanel4 = new JPanel();
                jTabbedPane1.addTab("config", null, jPanel4, null);
                {
                    savePickBtn = new JButton();
                    jPanel4.add(savePickBtn);
                    savePickBtn.setText("save pick");
                    savePickBtn.setPreferredSize(new java.awt.Dimension(116, 40));
                    savePickBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            if (englishFile == null) {
                                File file = new File(//
                                        PropertiesUtil.getJarCurrentPath(EnglishTester.class),
                                        "temp.properties");
                                englishFile = file;
                            }
                            if (pickProp.isEmpty()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("?!");
                                return;
                            }
                            String fileName = englishFile.getName().replaceAll("\\.properties",
                                    "_bak.properties");
                            File jarWhereFile = PropertiesUtil.getJarCurrentPath(EnglishTester.class);
                            fileName = JCommonUtil._jOptionPane_showInputDialog("save target properties",
                                    fileName);
                            if (StringUtils.isEmpty(fileName)) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("can't save!");
                                return;
                            }
                            if (fileName.equalsIgnoreCase(englishFile.getName())) {
                                JCommonUtil._jOptionPane_showMessageDialog_error(
                                        "??englishFile???");
                                return;
                            }
                            if (!fileName.endsWith(".properties")) {
                                fileName += ".properties";
                            }
                            File newFile = new File(jarWhereFile, fileName);
                            Properties oldProp = new Properties();
                            if (newFile.exists()) {
                                try {
                                    oldProp.load(new FileInputStream(newFile));
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            oldProp.putAll(pickProp);
                            try {
                                oldProp.store(new FileOutputStream(newFile), "comment");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            JCommonUtil._jOptionPane_showMessageDialog_info("save file ok!  \n" + newFile);
                        }
                    });
                }
                {
                    saveConfigBtn2 = new JButton();
                    jPanel4.add(saveConfigBtn2);
                    saveConfigBtn2.setText("save config");
                    saveConfigBtn2.setPreferredSize(new java.awt.Dimension(108, 40));
                    saveConfigBtn2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            saveConfigBtnAction();
                        }
                    });
                }
                {
                    startAllBtn = new JButton();
                    jPanel4.add(startAllBtn);
                    startAllBtn.setText("start all");
                    startAllBtn.setPreferredSize(new java.awt.Dimension(101, 40));
                    startAllBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            Object[] files = fileList.getSelectedValues();
                            if (files == null || files.length == 0) {
                                JCommonUtil
                                        ._jOptionPane_showMessageDialog_error("?properties");
                                return;
                            }
                            Properties allProp = new Properties();
                            Properties prop = new Properties();
                            for (Object ff : files) {
                                try {
                                    prop.load(new FileInputStream((File) ff));
                                } catch (Exception e) {
                                    JCommonUtil.handleException(e);
                                }
                                allProp.putAll(prop);
                            }
                            englishProp = allProp;
                            System.out.println("englishProp = " + englishProp.size());
                            startNow();
                        }
                    });
                }
                {
                    startNow = new JButton();
                    jPanel4.add(startNow);
                    startNow.setText("start now");
                    startNow.setPreferredSize(new java.awt.Dimension(101, 40));

                    startNow.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            startNow();
                        }
                    });
                }
                {
                    picOnly = new JCheckBox();
                    jPanel4.add(picOnly);
                    picOnly.setText("picOnly");
                }
                {
                    sortChkBox = new JCheckBox();
                    jPanel4.add(sortChkBox);
                    sortChkBox.setText("sort");
                }
                {
                    showPicChkBox = new JCheckBox();
                    showPicChkBox.setSelected(true);
                    jPanel4.add(showPicChkBox);
                    showPicChkBox.setText("showPic");
                }
                {
                    JCommonUtil.defaultToolTipDelay();
                    fontSizeSliber = new JSlider(JSlider.HORIZONTAL);
                    jPanel4.add(fontSizeSliber);
                    fontSizeSliber.setPreferredSize(new java.awt.Dimension(419, 35));
                    fontSizeSliber.setValue(22);
                    fontSizeSliber.setMinimum(22);
                    fontSizeSliber.setMaximum(300);
                    fontSizeSliber.setMajorTickSpacing(30);
                    fontSizeSliber.setMinorTickSpacing(5);
                    fontSizeSliber.setCursor(new Cursor(Cursor.HAND_CURSOR));
                    fontSizeSliber.setPaintTicks(false);
                    fontSizeSliber.setPaintLabels(true);
                    {
                        picFolderDirText = new JTextField();
                        JCommonUtil.jTextFieldSetFilePathMouseEvent(picFolderDirText, true);
                        jPanel4.add(picFolderDirText);
                        picFolderDirText.setColumns(20);
                    }
                    fontSizeSliber.addChangeListener(new ChangeListener() {
                        @Override
                        public void stateChanged(ChangeEvent e) {
                            int size = fontSizeSliber.getValue();
                            fontSizeSliber.setToolTipText("" + size);
                            englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, size));
                        }
                    });

                }
            }
            {
                jPanel6 = new JPanel();
                jTabbedPane1.addTab("files", null, jPanel6, null);
                BorderLayout jPanel6Layout = new BorderLayout();
                jPanel6.setLayout(jPanel6Layout);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel6.add(jScrollPane4, BorderLayout.CENTER);
                    jScrollPane4.setPreferredSize(new java.awt.Dimension(420, 211));
                    {
                        fileList = new JList();
                        reloadFileList();
                        jScrollPane4.setViewportView(fileList);
                        fileList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                final File file = JListUtil.getLeadSelectionObject(fileList);
                                if (JMouseEventUtil.buttonRightClick(1, evt)) {
                                    JPopupMenuUtil.newInstance(EnglishTester.this.fileList).applyEvent(evt)//
                                            .addJMenuItem("reload", new ActionListener() {
                                                @Override
                                                public void actionPerformed(ActionEvent e) {
                                                    reloadFileList();
                                                }
                                            })//
                                            .addJMenuItem("delete : " + file.getName(), new ActionListener() {
                                                @Override
                                                public void actionPerformed(ActionEvent e) {
                                                    boolean result = JCommonUtil
                                                            ._JOptionPane_showConfirmDialog_yesNoOption(
                                                                    "delete : " + file.getName() + " ?",
                                                                    "confirm");
                                                    if (result) {
                                                        file.delete();
                                                        reloadFileList();
                                                    }
                                                }//
                                            }).show();
                                    return;
                                }
                                if (evt.getClickCount() == 1) {
                                    return;
                                }
                                if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                        "?,?\n" + file.getName(),
                                        "")) {
                                    loadEnglishFile(file);
                                }
                            }
                        });
                        fileList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(fileList).defaultJListKeyPressed(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel9 = new JPanel();
                jTabbedPane1.addTab("pic", null, jPanel9, null);
                {
                    picCheckText = new JTextField();
                    jPanel9.add(picCheckText);
                    picCheckText.setPreferredSize(new java.awt.Dimension(177, 39));
                }
                {
                    picCheckBtn = new JButton();
                    jPanel9.add(picCheckBtn);
                    picCheckBtn.setText("check");
                    picCheckBtn.setPreferredSize(new java.awt.Dimension(98, 43));
                    {
                        jPanel11 = new JPanel();
                        jTabbedPane1.addTab("", null, jPanel11, null);
                        jPanel11.setLayout(new BorderLayout(0, 0));
                        {
                            inputTestArea2 = new JTextArea();
                            inputTestArea2.setFont(new Font("", Font.PLAIN, 12));
                            inputTestArea2.addKeyListener(new KeyAdapter() {
                                @Override
                                public void keyReleased(KeyEvent e) {
                                    inputTestTrainer.keyin(e);
                                }
                            });
                            jPanel11.add(inputTestArea2, BorderLayout.SOUTH);
                        }
                        {
                            inputTestArea1 = new JTextArea();
                            JTextAreaUtil.setWrapTextArea(inputTestArea1);
                            inputTestArea1.setFont(new Font("", Font.PLAIN, 22));
                            jPanel11.add(inputTestArea1, BorderLayout.CENTER);
                        }
                        {
                            panel = new JPanel();
                            jPanel11.add(panel, BorderLayout.NORTH);
                            {
                                inputTestLabel = new JLabel("");
                                panel.add(inputTestLabel);
                            }
                            {
                                inputTestChk = new JCheckBox("");
                                inputTestChk.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                        inputTestTrainer.initQuestion();
                                    }
                                });
                                panel.add(inputTestChk);
                            }
                        }
                    }
                    picCheckBtn.addActionListener(new ActionListener() {
                        void scanPic(String searchWord, File file, Set<File> findFile) {
                            if (file.isDirectory()) {
                                File[] list = null;
                                if ((list = file.listFiles()) != null) {
                                    for (File f : list) {
                                        scanPic(searchWord, f, findFile);
                                    }
                                }
                            } else {
                                String text = searchWord;
                                String name = file.getName().toLowerCase();
                                if (isMatch(name, text)) {
                                    findFile.add(file);
                                }
                            }
                        }

                        public void actionPerformed(ActionEvent evt) {
                            picDir = new File(picFolderDirText.getText());
                            if (picDir == null) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null");
                                return;
                            }
                            if (!picDir.exists() || !picDir.isDirectory()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("picDir ");
                                return;
                            }

                            picCheckBtn.setText("search..");

                            String searchWord = picCheckText.getText().toLowerCase().trim();

                            Set<File> picSet2 = new HashSet<File>();
                            scanPic(searchWord, picDir, picSet2);

                            if (picSet2 != null && picSet2.size() > 0) {
                                picCheckBtn.setText("" + picSet2.size());

                                try {
                                    Desktop.getDesktop().open(picSet2.iterator().next());
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                }
                            } else {
                                picCheckBtn.setText("0");
                            }
                        }
                    });
                }
            }
        }

        JCommonUtil.setJFrameIcon(this, "resource/images/ico/english_tester.ico");

        pack();
        this.setSize(423, 314);

        configHelper.init();
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private JPanel getIntervalo() {
    JPanel intervalo = new JPanel(new GridBagLayout());
    intervalo.setOpaque(false);//from   w w w . ja va 2 s.  com
    intervalo.setBorder(new TitledBorder("Intervalo Temporal de Consulta"));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    intervalo.add(new JLabel("Fecha/Hora Inicial"), gbc);
    gbc.gridx++;
    calendarini = new JCalendarCombo();
    calendarini.addActionListener(actionListener);
    calendarini.addDateListener(dateListener);
    intervalo.add(calendarini, gbc);
    gbc.gridx++;
    final Calendar instance = Calendar.getInstance();
    instance.set(Calendar.HOUR, 0);
    instance.set(Calendar.MINUTE, 0);
    instance.set(Calendar.SECOND, 0);
    horaini = initializeSpinner(instance);
    intervalo.add(horaini, gbc);

    gbc.gridx = 0;
    gbc.gridy++;

    intervalo.add(new JLabel("Fecha/Hora Final"), gbc);
    gbc.gridx++;
    calendarfin = new JCalendarCombo();
    calendarfin.addActionListener(actionListener);
    calendarfin.addDateListener(dateListener);
    intervalo.add(calendarfin, gbc);
    gbc.gridx++;
    horafin = initializeSpinner(instance);
    intervalo.add(horafin, gbc);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.EAST;
    soloUltimas = new JCheckBox();
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRecursos();
        }
    });
    soloUltimas.setOpaque(false);
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean enabled = !soloUltimas.isSelected();
            calendarini.setEnabled(enabled);
            calendarfin.setEnabled(enabled);
            horaini.setEnabled(enabled);
            horafin.setEnabled(enabled);
        }
    });
    intervalo.add(soloUltimas, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.WEST;
    intervalo.add(new JLabel("Consultar Slo Las ltimas Posiciones"), gbc);

    return intervalo;
}

From source file:library.Form_Library.java

License:asdf

public Form_Library() {
    super("Library Management");
    initComponents();/*from  ww w. ja v  a 2  s  . c  o  m*/
    setLocationRelativeTo(null);
    setSize(1100, 700);
    jPanel1.setSize(900, 600);
    jPanel2.setSize(900, 600);
    jPanel3.setSize(900, 600);
    jPanel4.setSize(900, 600);
    jPanel5.setSize(900, 600);
    jPanel6.setSize(900, 600);

    //        BufferedImage img = null;
    //        try {
    //            img = ImageIO.read(new File("D:\\CODE\\00. SOFTTECH\\9. JAVA 1\\Project\\Library_Minh\\src\\icon\\BG.jpg"));
    //        } catch (IOException e) {
    //            e.printStackTrace();
    //        }
    //        ImageIcon imageIcon = new ImageIcon(img.getScaledInstance(jLabel20.getWidth(), jLabel20.getHeight(), Image.SCALE_SMOOTH));
    //        jLabel20.setIcon(imageIcon);
    AutoSuggestor autoSuggestor = new Form_Library.AutoSuggestor(tfSearchBook, this, null,
            Color.BLACK.brighter(), Color.WHITE, Color.RED, 1.00f) {
        @Override
        boolean wordTyped(String typedWord) {
            //create list for dictionary this in your case might be done via calling a method which queries db and returns results as arraylist
            ArrayList<String> BookNameList = new ArrayList<String>();
            BookNameList = da.loadBookName("select BookName from book", "BookName");
            setDictionary(BookNameList);
            return super.wordTyped(typedWord);//now call super to check for any matches against newest dictionary
        }
    };
    da.LoadData(sql, tbPhieuQuaHan);
    try {
        String sql1 = "SELECT SUM(Quantity) as BookSum from book";
        String sql2 = "SELECT COUNT(RdID) as ReaderSum FROM reader";
        String sql3 = "SELECT COUNT(BorrowID) as BorrowSum FROM borrowingmanagement";
        String sql4 = "SELECT COUNT(DISTINCT RdID) as ReaderBorrowSum FROM borrowingmanagement";
        String sql5 = "SELECT COUNT(BorrowID) as DatedBorrowSum FROM borrowingmanagement "
                + "where (ReturnDate < CURDATE())";
        ResultSet rs1 = da.getData(sql1);
        ResultSet rs2 = da.getData(sql2);
        ResultSet rs3 = da.getData(sql3);
        ResultSet rs4 = da.getData(sql4);
        ResultSet rs5 = da.getData(sql5);
        if (rs1.next()) {
            this.lbTongSach.setText("Total books : " + Integer.toString(rs1.getInt("BookSum")));
        }
        if (rs2.next()) {
            this.lbTongKhach.setText("Total Readers: " + Integer.toString(rs2.getInt("ReaderSum")));
        }
        if (rs3.next()) {
            this.lbTongPhieu.setText("Total Borrowings: " + Integer.toString(rs3.getInt("BorrowSum")));
        }
        if (rs4.next()) {
            this.lbTongKhachMuon.setText(
                    "Total Readers who borrowing books: " + Integer.toString(rs4.getInt("ReaderBorrowSum")));
        }
        if (rs5.next()) {
            this.lbTongPhieuQuaHan
                    .setText("Total overdue Borrowings: " + Integer.toString(rs5.getInt("DatedBorrowSum")));
        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e);
    }
    taBaoCao.setText("");
    //        ResultSet rs = null;
    //        rs = da.getData(sql);
    //        List l;
    //        l = DbUtils.resultSetToNestedList(rs);
    //        this.taBaoCao.append(this.lbTongSach.getText() + "\n");
    //        this.taBaoCao.append(this.lbTongKhach.getText() + "\n");
    //        this.taBaoCao.append(this.lbTongPhieu.getText() + "\n");
    //        this.taBaoCao.append(this.lbTongKhachMuon.getText() + "\n");
    //        this.taBaoCao.append(this.lbTongPhieuQuaHan.getText() + "\n\n");
    //        this.taBaoCao.append("|  BorrowID  |  RdID  |  BookID  |  BorrowDate  |  ReturnDate  |\n");
    //        for (int i = 0; i < l.size(); i++) {
    //            this.taBaoCao.append(l.get(i).toString() + "\n");
    //        }

    //Reader
    this.tbReader.setModel(dmReader);
    dmReader.setColumnIdentifiers(tenCotReader);
    ReaderList.load("Select * from reader");
    for (Reader r : ReaderList.getList()) {
        dmReader.addRow(r.toVector());
    }

    //Borrowing Management
    this.tbBorrowingManagement.setModel(dmBorrowing);
    dmBorrowing.setColumnIdentifiers(tenCotBorrowing);

    //Gia hn th ?c
    tbReader.getColumn("Add 1 Year").setCellRenderer(new ButtonRenderer());
    ButtonEditor be = new ButtonEditor(new JCheckBox());
    tbReader.getColumn("Add 1 Year").setCellEditor(be);
    be.button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int donghh = tbReader.getSelectedRow();
            String RdIDhh = tbReader.getValueAt(donghh, 0).toString();
            String RdNamehh = tbReader.getValueAt(donghh, 1).toString();
            String IDcardhh = tbReader.getValueAt(donghh, 2).toString();
            String Sexhh = tbReader.getValueAt(donghh, 3).toString();
            Date Birthdayhh = carBirthday.getDate();
            String Addresshh = tbReader.getValueAt(donghh, 5).toString();
            String Phonehh = tbReader.getValueAt(donghh, 6).toString();
            String Emailhh = tbReader.getValueAt(donghh, 7).toString();
            Date ActiveDatehh = carActivationDate.getDate();

            Reader r = new Reader(RdIDhh, RdNamehh, IDcardhh, Sexhh, Birthdayhh, Addresshh, Phonehh, Emailhh,
                    ActiveDatehh, nextyear);
            Vector vt = r.toVector();

            try {
                ReaderList.suaExpiredDate(donghh, r);
            } catch (Exception ex) {
                Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
            }
            dmReader.removeRow(donghh);
            dmReader.insertRow(donghh, vt);
        }
    });

    //Return
    this.tbReturn.setModel(dmReturn);
    dmReturn.setColumnIdentifiers(tenCotReturn);

    //        "Borrow ID", "Book ID", "Reader Name", "Book Name", "Author Name", "Publisher Name", "Price", "Borrow Date", "Return Date", "Overdue Days", "Penalty", "Delete"
    //Xa phiu mn
    tbReturn.getColumn("Delete").setCellRenderer(new ButtonRenderer());
    ButtonEditor beDel = new ButtonEditor(new JCheckBox());
    tbReturn.getColumn("Delete").setCellEditor(beDel);
    beDel.button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            try {
                int donghh = tbReturn.getSelectedRow();
                String borID = tbReturn.getValueAt(donghh, 0).toString();
                System.out.println(borID);
                int xoaPhieu = ReturnList.xoa(borID);
                dmReturn.removeRow(xoaPhieu);
            } catch (Exception ex) {
                Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    });
    ReturnList.load(
            "select borrowingmanagement.BorrowID, borrowingmanagement.BookID, reader.RdName,book.BookName, author.AuthorName, publisher.PublisherName, book.Price, borrowingmanagement.BorrowDate, borrowingmanagement.ReturnDate\n"
                    + "from borrowingmanagement\n"
                    + "inner join book on borrowingmanagement.BookID = book.BookID\n"
                    + "inner join author on book.AuthorID = author.AuthorID\n"
                    + "inner join reader on borrowingmanagement.RdID = reader.RdID\n"
                    + "inner join publisher on book.PublisherID = publisher.PublisherID\n");
    for (ReturnManagement c : ReturnList.getReturnList()) {
        dmReturn.addRow(c.toVector());
    }

    //Gia hn mn sch
    tbBorrowingManagement.getColumn("Add 10 Days").setCellRenderer(new ButtonRenderer());
    ButtonEditor buttonEditor = new ButtonEditor(new JCheckBox());
    tbBorrowingManagement.getColumn("Add 10 Days").setCellEditor(buttonEditor);
    buttonEditor.button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int donghh = tbBorrowingManagement.getSelectedRow();
            try {
                System.out.println(
                        truNgayThang(df.parse(tbBorrowingManagement.getValueAt(donghh, 4).toString())));
            } catch (ParseException ex) {
                Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
            }
            try {
                if (truNgayThang(df2.parse(tbBorrowingManagement.getValueAt(donghh, 4).toString())) <= 0) {

                    String BrIDhh = tbBorrowingManagement.getValueAt(donghh, 0).toString();
                    String RdIDhh = tbBorrowingManagement.getValueAt(donghh, 1).toString();
                    String BookIDhh = tbBorrowingManagement.getValueAt(donghh, 2).toString();
                    Date BorrowDatehh = carBorrowDate.getDate();

                    BorrowingManagement r = new BorrowingManagement(BrIDhh, RdIDhh, BookIDhh, BorrowDatehh,
                            nextday);
                    Vector vt = r.toVector();

                    try {
                        BorrowingList.suaReturnDate(donghh, r);
                    } catch (Exception ex) {
                        Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    dmBorrowing.removeRow(donghh);
                    dmBorrowing.insertRow(donghh, vt);
                    //                disableCarlendarBorrow();
                } else {
                    JOptionPane.showMessageDialog(null, "Can't renew");
                }
            } catch (ParseException ex) {
                Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    BorrowingList.load("Select * from borrowingmanagement");

    for (BorrowingManagement r : BorrowingList.getList()) {
        dmBorrowing.addRow(r.toVector());

    }

    //Book
    this.tbBookAdmin.setModel(dmBook);
    dmBook.setColumnIdentifiers(tenCotBook);
    BookList.load("Select * from book");
    for (Book b : BookList.getList()) {
        dmBook.addRow(b.toVector());
    }
    clist.loadCategory();
    for (Category c : clist.getCategoryList()) {
        this.cbCategoryID.addItem(c.getCategoryID());
    }

    //Author
    this.tbAuthorAdmin.setModel(dmAuthor);
    dmAuthor.setColumnIdentifiers(tenCotAuthor);
    AuthorList.load("Select * from author");
    for (Author b : AuthorList.getList()) {
        dmAuthor.addRow(b.toVector());
    }

    //Category
    this.tbcategory.setModel(dmCategory);
    dmCategory.setColumnIdentifiers(tenCotCategory);
    CategoryList.load("Select * from category");
    for (Category c : CategoryList.getCategoryList()) {
        dmCategory.addRow(c.toVector());
    }

    //Publisher
    this.tbPublisher.setModel(dmPublisher);
    dmPublisher.setColumnIdentifiers(tenCotPublisher);
    PublisherList.load("Select * from publisher");
    for (Publisher c : PublisherList.getPublisherList()) {
        dmPublisher.addRow(c.toVector());
    }

    //Supplier
    this.tbSupplierAdmin.setModel(dmSupplier);
    dmSupplier.setColumnIdentifiers(tenCotSupplier);
    SupplierList.load("Select * from supplier");
    for (Supplier c : SupplierList.getSupplierList()) {
        dmSupplier.addRow(c.toVector());
    }

    //Co dn cc ct
    resizeColumnWidth(tbAuthorAdmin);
    resizeColumnWidth(tbBookAdmin);
    resizeColumnWidth(tbBorrowingManagement);
    resizeColumnWidth(tbPhieuQuaHan);
    resizeColumnWidth(tbPublisher);
    resizeColumnWidth(tbReader);
    resizeColumnWidth(tbReturn);
    resizeColumnWidth(tbSupplierAdmin);
    resizeColumnWidth(tbcategory);

    //Sort Jtable
    TableRowSorter<TableModel> sorter = new TableRowSorter<>(tbBookAdmin.getModel());
    tbBookAdmin.setRowSorter(sorter);
    TableRowSorter<TableModel> sorter2 = new TableRowSorter<>(tbReturn.getModel());
    tbReturn.setRowSorter(sorter2);
    sorter2.setComparator(6, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });
    sorter2.setComparator(9, new Comparator<Long>() {
        @Override
        public int compare(Long o1, Long o2) {
            return o1.intValue() - o2.intValue();
        }
    });
    sorter2.setComparator(10, new Comparator<Long>() {
        @Override
        public int compare(Long o1, Long o2) {
            return o1.intValue() - o2.intValue();
        }
    });

    sorter.setComparator(6, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });
    sorter.setComparator(7, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });
    sorter.setComparator(9, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });
    sorter.setComparator(10, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });

    jPopupMenuBook.setName("jPopupMenu");
    tbBookAdmin.setComponentPopupMenu(jPopupMenuBook);
    jMenuItemBook.setText("Copy"); // NOI18N
    jMenuItemBook.setName("jMenuItem"); // NOI18N
    jPopupMenuBook.add(jMenuItemBook);

    jMenuItemBo.setName("jPopupMenu");
    tbBorrowingManagement.setComponentPopupMenu(jPopupMenuBo);
    jMenuItemBo.setText("Copy"); // NOI18N
    jMenuItemBo.setName("jMenuItem"); // NOI18N
    jPopupMenuBo.add(jMenuItemBo);

    jPopupMenuAuthor.setName("jPopupMenu");
    tbAuthorAdmin.setComponentPopupMenu(jPopupMenuAuthor);
    jMenuItemAuthor.setText("Copy"); // NOI18N
    jMenuItemAuthor.setName("jMenuItem"); // NOI18N
    jPopupMenuAuthor.add(jMenuItemAuthor);

    jPopupMenuPub.setName("jPopupMenu");
    tbPublisher.setComponentPopupMenu(jPopupMenuPub);
    jMenuItemPub.setText("Copy"); // NOI18N
    jMenuItemPub.setName("jMenuItem"); // NOI18N
    jPopupMenuPub.add(jMenuItemPub);

    jPopupMenuCate.setName("jPopupMenu");
    tbcategory.setComponentPopupMenu(jPopupMenuCate);
    jMenuItemCate.setText("Copy"); // NOI18N
    jMenuItemCate.setName("jMenuItem"); // NOI18N
    jPopupMenuCate.add(jMenuItemCate);

    jPopupMenuSup.setName("jPopupMenu");
    tbSupplierAdmin.setComponentPopupMenu(jPopupMenuSup);
    jMenuItemSup.setText("Copy"); // NOI18N
    jMenuItemSup.setName("jMenuItem"); // NOI18N
    jPopupMenuSup.add(jMenuItemSup);

    jPopupMenuReader.setName("jPopupMenu");
    tbReader.setComponentPopupMenu(jPopupMenuReader);
    jMenuItemReader.setText("Copy"); // NOI18N
    jMenuItemReader.setName("jMenuItem"); // NOI18N
    jPopupMenuReader.add(jMenuItemReader);

    jLabel20.setIcon(loadImage("src\\icon\\BG.jpg", 1070, 558));

    setCarlendarBorrow();
    setCarlendarReader();
}

From source file:cnu.eslab.fileTest.NewJFrame.java

private void initGUI() {
    try {/* w ww  .ja  v a  2  s.  com*/
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);
        {
            jPanel1 = new JPanel();
            FlowLayout jPanel1Layout = new FlowLayout();
            jPanel1.setLayout(jPanel1Layout);
            getContentPane().add(jPanel1, "North");
            jPanel1.setBounds(12, 434, 590, 66);
            jPanel1.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
                mParsingBtn = new JButton();
                jPanel1.add(mParsingBtn);
                mParsingBtn.setText("Parsing");
                mParsingBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mTotalPowerBtn = new JButton();
                jPanel1.add(mTotalPowerBtn);
                mTotalPowerBtn.setText("Phone Total Power");
                mTotalPowerBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mBatteryCapacityBtn = new JButton();
                jPanel1.add(mBatteryCapacityBtn);
                mBatteryCapacityBtn.setText("Battery Capacity");
                mBatteryCapacityBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mTotalCompareBtn = new JButton();
                jPanel1.add(mTotalCompareBtn);
                mTotalCompareBtn.setText("Total Compare");
                mTotalCompareBtn.setPreferredSize(new java.awt.Dimension(124, 24));
            }
            {
                mPhoneTotalStackPowerBtn = new JButton();
                jPanel1.add(mPhoneTotalStackPowerBtn);
                mPhoneTotalStackPowerBtn.setText("Phone Total Stack Power");
            }
            {
                mDevicesPowerButton = new JButton();
                jPanel1.add(mDevicesPowerButton);
                mDevicesPowerButton.setText("Hardware Component Max Power");
                mDevicesPowerButton.setPreferredSize(new java.awt.Dimension(280, 24));
            }
            {
                mCompareAppPowerBtn = new JButton();
                jPanel1.add(mCompareAppPowerBtn);
                mCompareAppPowerBtn.setText("Compare");
            }
        }
        {
            jPanel2 = new JPanel();
            getContentPane().add(jPanel2, "West");
            jPanel2.setBounds(12, 25, 589, 67);
            jPanel2.setLayout(null);
            jPanel2.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
                mFilePathLabel = new JLabel();
                jPanel2.add(mFilePathLabel);
                mFilePathLabel.setText("File Path");
                mFilePathLabel.setPreferredSize(new java.awt.Dimension(48, 17));
                mFilePathLabel.setBounds(8, 8, 48, 17);
            }
            {
                mFilePathTextField = new JTextField();
                jPanel2.add(mFilePathTextField);
                mFilePathTextField.setText("None");
                mFilePathTextField.setEditable(false);
                mFilePathTextField.setBounds(68, 4, 430, 24);
            }
            {
                mFileBtn = new JButton();
                jPanel2.add(mFileBtn);
                mFileBtn.setText("OPEN");
                mFileBtn.setBounds(503, 6, 81, 24);
            }
            {
                LOGTimeLabel = new JLabel();
                jPanel2.add(LOGTimeLabel);
                LOGTimeLabel.setText("LOG Time");
                LOGTimeLabel.setBounds(8, 37, 60, 17);
            }
            {
                mLogScaleTextFiled = new JTextField();
                jPanel2.add(mLogScaleTextFiled);
                mLogScaleTextFiled.setText("None");
                mLogScaleTextFiled.setEditable(false);
                mLogScaleTextFiled.setBounds(68, 34, 430, 24);
            }
        }
        {
            jScrollPane1 = new JScrollPane();
            getContentPane().add(jScrollPane1);
            jScrollPane1.setBounds(13, 122, 424, 228);
            {
                listModel = new DefaultListModel();// List? ??  ??.
                mUidList = new JList(listModel);
                mUidList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 
                // ?
                // ?
                // .
                jScrollPane1.setViewportView(mUidList);
                jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

                mUidList.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
                //mUidList.setPreferredSize(new java.awt.Dimension(586, 222));   /?  ?.
            }
        }
        {
            jPanel3 = new JPanel();
            getContentPane().add(jPanel3);
            jPanel3.setBounds(12, 0, 579, 31);
            {
                dd = new JLabel();
                jPanel3.add(dd);
                dd.setText("Power Tutor Trace");
                dd.setPreferredSize(new java.awt.Dimension(106, 17));
            }
        }
        {
            jPanel5 = new JPanel();
            getContentPane().add(jPanel5, "West");
            jPanel5.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel5.setBounds(12, 356, 304, 58);
            jPanel5.setLayout(null);
            {
                Range = new JLabel();
                jPanel5.add(Range);
                Range.setText("Range");
                Range.setBounds(14, 10, 46, 17);
            }
            {
                mFirstRangeText = new JTextField();
                jPanel5.add(mFirstRangeText);
                mFirstRangeText.setBounds(59, 7, 63, 24);
            }
            {
                mUidPieDiagramBtn = new JButton();
                jPanel5.add(mUidPieDiagramBtn);
                mUidPieDiagramBtn.setText("UID Pie");
                mUidPieDiagramBtn.setBounds(207, 7, 90, 24);
            }
            {
                jLabel3 = new JLabel();
                jPanel5.add(jLabel3);
                jLabel3.setText("-");
                jLabel3.setBounds(128, 10, 10, 17);
            }
            {
                mSecondRangeText = new JTextField();
                jPanel5.add(mSecondRangeText);
                mSecondRangeText.setBounds(138, 7, 63, 24);
            }
            {
                mComponentPieBtn = new JButton();
                jPanel5.add(mComponentPieBtn);
                mComponentPieBtn.setText("PHONE Pie");
                mComponentPieBtn.setBounds(59, 36, 238, 16);
            }
        }
        {
            jPanel6 = new JPanel();
            getContentPane().add(jPanel6, "West");
            jPanel6.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel6.setBounds(322, 356, 275, 66);
            jPanel6.setLayout(null);
            {
                jLabel4 = new JLabel();
                jPanel6.add(jLabel4);
                jLabel4.setText("TotalPM");
                jLabel4.setBounds(16, 10, 56, 26);
            }
            {
                mChartMeanUnitTextField = new JTextField();
                jPanel6.add(mChartMeanUnitTextField);
                mChartMeanUnitTextField.setBounds(77, 7, 135, 29);
            }
            {
                m3DBarChartMean = new JButton();
                jPanel6.add(m3DBarChartMean);
                m3DBarChartMean.setText("ok");
                m3DBarChartMean.setBounds(218, 7, 49, 24);
            }
            {
                mAudioCheckBox = new JCheckBox();
                jPanel6.add(mAudioCheckBox);
                mAudioCheckBox.setText("AUDIO");
                mAudioCheckBox.setBounds(79, 40, 65, 21);
            }
            {
                mGPSCheckBox = new JCheckBox();
                jPanel6.add(mGPSCheckBox);
                mGPSCheckBox.setText("GPS");
                mGPSCheckBox.setBounds(151, 40, 56, 21);
            }
        }
        {
            jPanel4 = new JPanel();
            getContentPane().add(jPanel4, "North");
            FlowLayout jPanel4Layout = new FlowLayout();
            jPanel4.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel4.setLayout(jPanel4Layout);
            jPanel4.setBounds(12, 523, 590, 66);
            {
                mAppTotalPowerBtn = new JButton();
                jPanel4.add(mAppTotalPowerBtn);
                mAppTotalPowerBtn.setText("UID Line Total Power");
                mAppTotalPowerBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mAppStackedPower = new JButton();
                jPanel4.add(mAppStackedPower);
                mAppStackedPower.setText("UID Stack Total Power");
                mAppStackedPower.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mLedBtn = new JButton();
                jPanel4.add(mLedBtn);
                mLedBtn.setText("UID LED Power");
                mLedBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mCpuBtn = new JButton();
                jPanel4.add(mCpuBtn);
                mCpuBtn.setText("UID CPU Power");
                mCpuBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mWifiBtn = new JButton();
                jPanel4.add(mWifiBtn);
                mWifiBtn.setText("UID WIFI Power");
                mWifiBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                m3GBtn = new JButton();
                jPanel4.add(m3GBtn);
                m3GBtn.setText("UID ThreeG Power");
                m3GBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
        }
        {
            jPanel7 = new JPanel();
            getContentPane().add(jPanel7, "North");
            FlowLayout jPanel7Layout = new FlowLayout();
            jPanel7.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel7.setLayout(jPanel7Layout);
            jPanel7.setBounds(12, 618, 590, 63);
            {
                mComponentLEDBtn = new JButton();
                jPanel7.add(mComponentLEDBtn);
                mComponentLEDBtn.setText("LED Power");
                mComponentLEDBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentWIFIBtn = new JButton();
                jPanel7.add(mComponentWIFIBtn);
                mComponentWIFIBtn.setText("WIFI Power");
                mComponentWIFIBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mGpsBtn = new JButton();
                jPanel7.add(mGpsBtn);
                mGpsBtn.setText("GPS Power");
                mGpsBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentCPUBtn = new JButton();
                jPanel7.add(mComponentCPUBtn);
                mComponentCPUBtn.setText("CPU Power");
                mComponentCPUBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentThreeGBtn = new JButton();
                jPanel7.add(mComponentThreeGBtn);
                mComponentThreeGBtn.setText("ThreeG Power");
                mComponentThreeGBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mAudioBtn = new JButton();
                jPanel7.add(mAudioBtn);
                mAudioBtn.setText("AUDIO Power");
                mAudioBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
        }
        {
            jLabel1 = new JLabel();
            getContentPane().add(jLabel1);
            jLabel1.setText("Individual App component Power");
            jLabel1.setBounds(12, 506, 202, 17);
        }
        {
            jLabel2 = new JLabel();
            getContentPane().add(jLabel2);
            jLabel2.setText("Function Button");
            jLabel2.setBounds(12, 411, 181, 17);
        }
        {
            jLabel5 = new JLabel();
            getContentPane().add(jLabel5);
            jLabel5.setText("Individual H/W Component Power");
            jLabel5.setBounds(12, 601, 223, 17);
        }
        {
            jScrollPane2 = new JScrollPane();
            getContentPane().add(jScrollPane2);
            jScrollPane2.setBounds(493, 122, 108, 194);
            {
                listModelUidDelte = new DefaultListModel();// List? ??  ??.
                mDeleteList = new JList(listModelUidDelte);
                jScrollPane2.setViewportView(mDeleteList);
            }
        }
        {
            mDeleteAllBtn = new JButton();
            getContentPane().add(mDeleteAllBtn);
            mDeleteAllBtn.setText("A");
            mDeleteAllBtn.setBounds(493, 321, 51, 24);
        }
        {
            mDeleteOneBtn = new JButton();
            getContentPane().add(mDeleteOneBtn);
            mDeleteOneBtn.setText("O");
            mDeleteOneBtn.setBounds(549, 321, 48, 24);
        }
        {
            mDeleteUidMoveBtn = new JButton();
            getContentPane().add(mDeleteUidMoveBtn);
            mDeleteUidMoveBtn.setText(">");
            mDeleteUidMoveBtn.setBounds(443, 169, 45, 95);
        }
        {
            jLabel6 = new JLabel();
            getContentPane().add(jLabel6);
            jLabel6.setText("Package Name List");
            jLabel6.setBounds(13, 99, 139, 17);
        }
        {
            jLabel7 = new JLabel();
            getContentPane().add(jLabel7);
            jLabel7.setText("Remove Uid");
            jLabel7.setBounds(493, 100, 139, 17);
        }
        pack();
        this.setSize(623, 725);
        // setVisible(true);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}