Example usage for javax.swing JLabel setText

List of usage examples for javax.swing JLabel setText

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "Defines the single line of text this component will display.")
public void setText(String text) 

Source Link

Document

Defines the single line of text this component will display.

Usage

From source file:com.stam.batchmove.BatchMoveUtils.java

public static void showFilesFrame(Object[][] data, String[] columnNames, final JFrame callerFrame) {
    final FilesFrame filesFrame = new FilesFrame();

    DefaultTableModel model = new DefaultTableModel(data, columnNames) {

        private static final long serialVersionUID = 1L;

        @Override//from w ww  . j a  v  a2  s.  co m
        public Class<?> getColumnClass(int column) {
            return getValueAt(0, column).getClass();
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            return column == 0;
        }
    };
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(JLabel.CENTER);
    final JTable table = new JTable(model);
    for (int i = 1; i < table.getColumnCount(); i++) {
        table.setDefaultRenderer(table.getColumnClass(i), renderer);
    }
    //            table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(30);
    table.getTableHeader().setFont(new Font("Serif", Font.BOLD, 14));
    table.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
    table.setRowSelectionAllowed(false);
    table.getColumnModel().getColumn(0).setMaxWidth(35);
    table.getColumnModel().getColumn(1).setPreferredWidth(350);
    table.getColumnModel().getColumn(2).setPreferredWidth(90);
    table.getColumnModel().getColumn(2).setMaxWidth(140);
    table.getColumnModel().getColumn(3).setMaxWidth(90);

    JPanel tblPanel = new JPanel();
    JPanel btnPanel = new JPanel();

    tblPanel.setLayout(new BorderLayout());
    if (table.getRowCount() > 15) {
        JScrollPane scrollPane = new JScrollPane(table);
        tblPanel.add(scrollPane, BorderLayout.CENTER);
    } else {
        tblPanel.add(table.getTableHeader(), BorderLayout.NORTH);
        tblPanel.add(table, BorderLayout.CENTER);
    }

    btnPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

    filesFrame.setMinimumSize(new Dimension(800, 600));
    filesFrame.setLayout(new BorderLayout());
    filesFrame.add(tblPanel, BorderLayout.NORTH);
    filesFrame.add(btnPanel, BorderLayout.SOUTH);

    final JLabel resultsLabel = new JLabel();

    JButton cancelBtn = new JButton("Cancel");
    cancelBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            filesFrame.setVisible(false);
            callerFrame.setVisible(true);
        }
    });

    JButton moveBtn = new JButton("Copy");
    moveBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            fileChooser.setDialogTitle("Choose target directory");
            int selVal = fileChooser.showOpenDialog(null);
            if (selVal == JFileChooser.APPROVE_OPTION) {
                File selection = fileChooser.getSelectedFile();
                String targetPath = selection.getAbsolutePath();

                DefaultTableModel dtm = (DefaultTableModel) table.getModel();
                int nRow = dtm.getRowCount();
                int copied = 0;
                for (int i = 0; i < nRow; i++) {
                    Boolean selected = (Boolean) dtm.getValueAt(i, 0);
                    String filePath = dtm.getValueAt(i, 1).toString();

                    if (selected) {
                        try {
                            FileUtils.copyFileToDirectory(new File(filePath), new File(targetPath));
                            dtm.setValueAt("Copied", i, 3);
                            copied++;
                        } catch (Exception ex) {
                            Logger.getLogger(SelectionFrame.class.getName()).log(Level.SEVERE, null, ex);
                            dtm.setValueAt("Failed", i, 3);
                        }
                    }
                }
                resultsLabel.setText(copied + " files copied. Finished!");
            }
        }
    });
    btnPanel.add(cancelBtn);
    btnPanel.add(moveBtn);
    btnPanel.add(resultsLabel);

    filesFrame.revalidate();
    filesFrame.setVisible(true);

    callerFrame.setVisible(false);
}

From source file:com.intuit.tank.proxy.ProxyApp.java

private JPanel getTransactionTable() {
    JPanel frame = new JPanel(new BorderLayout());
    model = new TransactionTableModel();
    final JTable table = new TransactionTable(model);
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
    table.setRowSorter(sorter);//from   w ww .j  a v a2 s . com
    final JPopupMenu pm = new JPopupMenu();
    JMenuItem item = new JMenuItem("Delete Selected");
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            int[] selectedRows = table.getSelectedRows();
            if (selectedRows.length != 0) {
                int response = JOptionPane.showConfirmDialog(ProxyApp.this,
                        "Are you sure you want to delete " + selectedRows.length + " Transactions?",
                        "Confirm Delete", JOptionPane.YES_NO_OPTION);
                if (response == JOptionPane.YES_OPTION) {
                    int[] correctedRows = new int[selectedRows.length];
                    for (int i = selectedRows.length; --i >= 0;) {
                        int row = selectedRows[i];
                        int index = (Integer) table.getValueAt(row, 0) - 1;
                        correctedRows[i] = index;
                    }
                    Arrays.sort(correctedRows);
                    for (int i = correctedRows.length; --i >= 0;) {
                        int row = correctedRows[i];
                        Transaction transaction = model.getTransactionForIndex(row);
                        if (transaction != null) {
                            model.removeTransaction(transaction, row);
                            isDirty = true;
                            saveAction.setEnabled(isDirty && !stopAction.isEnabled());
                        }
                    }
                }
            }
        }
    });
    pm.add(item);
    table.add(pm);

    table.addMouseListener(new MouseAdapter() {
        boolean pressed = false;

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                Point p = e.getPoint();
                int row = table.rowAtPoint(p);
                int index = (Integer) table.getValueAt(row, 0) - 1;
                Transaction transaction = model.getTransactionForIndex(index);
                if (transaction != null) {
                    detailsTF.setText(transaction.toString());
                    detailsTF.setCaretPosition(0);
                    detailsDialog.setVisible(true);
                }
            }
        }

        /**
         * @{inheritDoc
         */
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                pressed = true;
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows.length != 0) {
                    pm.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }

        /**
         * @{inheritDoc
         */
        @Override
        public void mouseReleased(MouseEvent e) {
            if (!pressed && e.isPopupTrigger()) {
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows.length != 0) {
                    pm.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }

    });

    JScrollPane pane = new JScrollPane(table);
    frame.add(pane, BorderLayout.CENTER);
    JPanel panel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Filter: ");
    panel.add(label, BorderLayout.WEST);
    final JLabel countLabel = new JLabel(" Count: 0 ");
    panel.add(countLabel, BorderLayout.EAST);
    final JTextField filterText = new JTextField("");
    filterText.addKeyListener(new KeyAdapter() {
        public void keyTyped(KeyEvent e) {
            String text = filterText.getText();
            if (text.length() == 0) {
                sorter.setRowFilter(null);
            } else {
                try {
                    sorter.setRowFilter(RowFilter.regexFilter(text));
                    countLabel.setText(" Count: " + sorter.getViewRowCount() + " ");
                } catch (PatternSyntaxException pse) {
                    System.err.println("Bad regex pattern");
                }
            }
        }
    });
    panel.add(filterText, BorderLayout.CENTER);

    frame.add(panel, BorderLayout.NORTH);
    return frame;
}

From source file:net.mumie.coursecreator.gui.ClassChooser.java

private void buildLayout() {
    //       Dimensions of the Dialog      
    int width = 10;
    int height = 160;
    int buttonWidth = 100;
    int buttonHeight = 30;

    // sets the Layout
    this.getContentPane().setLayout(new GridBagLayout());

    // the Button and Label Text
    String okButtonText = "Zuweisen";
    String cancelButtonText = "Cancel";
    headlineLabelText = "";

    // the Fonts/* ww w  . j a v a 2 s. c o  m*/
    Font font = new Font("SansSerif", Font.PLAIN, 14);
    Font headlineLabelFont = new Font("SansSerif", Font.PLAIN, 12);
    Font textFieldFont = new Font("Monospaced", Font.PLAIN, 10);

    // GridBagContraints for rootPanel (s.b.):
    GridBagConstraints rootPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 0);

    // GridBagContraints for headlineLabel:
    GridBagConstraints headlineLabelStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0);

    // GridBagConstraints for textFieldPanel (s.b.):
    GridBagConstraints textFieldPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0,
            1);

    // GridBagConstraints for buttonPanel (s.b.):
    GridBagConstraints buttonPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 2);

    // GridBagConstraints for serverTextField:
    GridBagConstraints serverTextFieldStyle = createGridBagContrains(GridBagConstraints.WEST, 6, 6, 6, 6, 1, 0);

    // GridBagContraints for okButton (s.b.):
    GridBagConstraints okButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0);

    // GridBagContraints for cancelButton (s.b.):
    GridBagConstraints cancelButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 1, 0);

    // Creating rootPanel (contains all components)
    JPanel rootPanel = new JPanel(new GridBagLayout());
    rootPanel.setFont(font);

    // Creating headlineLabel:
    JLabel headlineLabel = new JLabel(headlineLabelText);
    headlineLabel.setFont(headlineLabelFont);

    // Creating textFieldPanel:
    JPanel textFieldPanel = new JPanel(new GridBagLayout());
    textFieldPanel.setFont(font);

    // Creating classTextField:
    classBox = new JComboBox(this.classList);
    classBox.setFont(textFieldFont);

    String classPath = this.controller.getMetaInfoField().getMetaInfos().getClassPath();
    String className = this.controller.getMetaInfoField().getMetaInfos().getClassName();

    if (setSelectedClass(classPath, className) == -1)
        headlineLabel.setForeground(Color.RED);
    else
        headlineLabel.setForeground(Color.BLACK);

    headlineLabel.setText(this.headlineLabelText);

    // Creating buttonPanel:
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    buttonPanel.setFont(font);

    // okButton:
    JButton okButton = new JButton(okButtonText);
    okButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight));
    okButton.setActionCommand(CommandConstants.META_INFO_FIELD_OK);
    okButton.addActionListener(this.controller);

    // cancelButton:
    JButton cancelButton = new JButton(cancelButtonText);
    cancelButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight));
    cancelButton.setActionCommand(CommandConstants.META_INFO_FIELD_CANCEL);
    cancelButton.addActionListener(this.controller);

    // Composing the GUI:
    this.getContentPane().setLayout(new GridBagLayout());
    this.getContentPane().add(rootPanel, rootPanelStyle);
    rootPanel.add(headlineLabel, headlineLabelStyle);
    rootPanel.add(textFieldPanel, textFieldPanelStyle);
    textFieldPanel.add(classBox, serverTextFieldStyle);
    rootPanel.add(buttonPanel, buttonPanelStyle);
    buttonPanel.add(okButton, okButtonStyle);
    buttonPanel.add(cancelButton, cancelButtonStyle);

    this.addWindowListener(this.windowListener);

    int maxString = this.headlineLabelText.length();
    for (int i = 0; i < this.classList.size(); i++) {
        maxString = Math.max(((String) this.classList.get(i).toString()).length(), maxString);
    }

    width = Math.max(width, maxString * 8);
    this.setSize(width, height);
}

From source file:edu.harvard.i2b2.query.ui.QueryTopPanel.java

public void addPanel() {
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override//from   www .ja v a  2  s .co m
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }
    });

    // jPanel1.add(label);
    // label.setBounds(rightmostPosition, 90, 30, 18);

    QueryConceptTreePanel panel = new QueryConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1),
            this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, label, rightmostPosition + 5 + 180);

    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
    resizePanels(getParent().getWidth(), getParent().getHeight());
}

From source file:edu.harvard.i2b2.query.ui.QueryTopPanel.java

private void jMorePanelsButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (dataModel.hasEmptyPanels()) {
        JOptionPane.showMessageDialog(this, "Please use an existing empty panel before adding a new one.");
        return;/* www.  j  ava 2  s .  co m*/
    }
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }
    });

    QueryConceptTreePanel panel = new QueryConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1),
            this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, label, rightmostPosition + 5 + 180);

    /*
     * System.out.println(jScrollPane4.getViewport().getExtentSize().width+":"
     * + jScrollPane4.getViewport().getExtentSize().height);
     * System.out.println
     * (jScrollPane4.getHorizontalScrollBar().getVisibleRect().width+":"
     * +jScrollPane4.getHorizontalScrollBar().getVisibleRect().height);
     * System
     * .out.println(jScrollPane4.getHorizontalScrollBar().getVisibleAmount
     * ());
     * System.out.println(jScrollPane4.getHorizontalScrollBar().getValue());
     */
    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
    // this.jScrollPane4.removeAll();
    // this.jScrollPane4.setViewportView(jPanel1);
    // revalidate();
    // jScrollPane3.setBounds(420, 0, 170, 300);
    // jScrollPane4.setBounds(20, 35, 335, 220);
    resizePanels(getParent().getWidth(), getParent().getHeight());
}

From source file:com.smanempat.controller.ControllerClassification.java

public void chooseFile(ActionEvent evt, JTextField txtFileDirectory, JTextField txtNumberOfK,
        JLabel labelJumlahData, JButton buttonProses, JTable tablePreview) {
    try {//from w  w  w. j  a v  a 2s  .c  o  m
        JFileChooser fileChooser = new JFileChooser();
        FileNameExtensionFilter fileNameExtensionFilter = new FileNameExtensionFilter("Excel File", "xls",
                "xlsx");
        fileChooser.setFileFilter(fileNameExtensionFilter);

        if (fileChooser.showOpenDialog(fileChooser) == JFileChooser.APPROVE_OPTION) {
            txtFileDirectory.setText(fileChooser.getSelectedFile().getAbsolutePath());
            System.out.println("Good, File Chooser runing well!");
            if (txtFileDirectory.getText().endsWith(".xls") || txtFileDirectory.getText().endsWith(".xlsx")) {
                showOnTable(evt, txtFileDirectory, tablePreview);
                labelJumlahData.setText(tablePreview.getRowCount() + " Data");
                txtNumberOfK.setEnabled(true);
                txtNumberOfK.requestFocus();
                buttonProses.setEnabled(true);
            } else {
                JOptionPane.showMessageDialog(null,
                        "File dataset harus file spreadsheet dengan ekstensi *xls atau *.xlsx!", "Error",
                        JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
                txtFileDirectory.setText("");
                chooseFile(evt, txtFileDirectory, txtNumberOfK, labelJumlahData, buttonProses, tablePreview);
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:SuitaDetails.java

public void updateStats(int val[]) {
    int i = 0;//w w  w .j  a va 2 s.  c o  m
    for (JLabel l : stats) {
        l.setText(val[i] + "");
        i++;
    }
    summary.repaint();
}

From source file:com.smanempat.controller.ControllerClassification.java

public String[] processMining(JTextField textNumberOfK, JTable tablePreview, JLabel labelPesanError,
        JTable tableResult, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan,
        JYearChooser jYearChooser1, JYearChooser jYearChooser2, JTabbedPane jTabbedPane1) {

    String numberValidate = textNumberOfK.getText();
    ModelClassification modelClassification = new ModelClassification();
    int rowCountModel = modelClassification.getRowCount();
    int rowCountData = tablePreview.getRowCount();
    System.out.println("Row Count Data : " + rowCountData);
    System.out.println("Row Count Model : " + rowCountModel);
    String[] knnValue = null;//from ww w. ja v a2 s  .c  o  m

    /*Validasi Nilai Number of Nearest Neighbor*/
    if (Pattern.matches("[0-9]+", numberValidate) == false && numberValidate.length() > 0) {
        labelPesanError.setText("Number of Nearest Neighbor tidak valid");
        JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        textNumberOfK.requestFocus();
    } else if (numberValidate.isEmpty()) {
        JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong");
        textNumberOfK.requestFocus();
    } else if (Integer.parseInt(numberValidate) >= rowCountModel) {
        labelPesanError.setText("Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + "");
        JOptionPane.showMessageDialog(null,
                "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        textNumberOfK.requestFocus();
    } else {
        int confirm = 0;
        confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?", "Proses Klasifikasi",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
        if (confirm == JOptionPane.OK_OPTION) {
            int kValue = Integer.parseInt(textNumberOfK.getText());
            String[][] modelValue = getModelValue(rowCountModel);
            double[][] dataValue = getDataValue(rowCountData, tablePreview);
            knnValue = getKNNValue(rowCountData, rowCountModel, modelValue, dataValue, kValue);
            showClassificationResult(tableResult, tablePreview, knnValue, rowCountData, labelSiswaIPA,
                    labelSiswaIPS, labelKeterangan, jYearChooser1, jYearChooser2, kValue);
            jTabbedPane1.setSelectedIndex(1);
        }

    }
    return knnValue;
}

From source file:com.github.benchdoos.weblocopener.updater.gui.UpdateDialog.java

/**
 * @noinspection ALL//  w ww  . jav  a 2 s. c o  m
 */
private void $$$loadLabelText$$$(JLabel component, String text) {
    StringBuffer result = new StringBuffer();
    boolean haveMnemonic = false;
    char mnemonic = '\0';
    int mnemonicIndex = -1;
    for (int i = 0; i < text.length(); i++) {
        if (text.charAt(i) == '&') {
            i++;
            if (i == text.length())
                break;
            if (!haveMnemonic && text.charAt(i) != '&') {
                haveMnemonic = true;
                mnemonic = text.charAt(i);
                mnemonicIndex = result.length();
            }
        }
        result.append(text.charAt(i));
    }
    component.setText(result.toString());
    if (haveMnemonic) {
        component.setDisplayedMnemonic(mnemonic);
        component.setDisplayedMnemonicIndex(mnemonicIndex);
    }
}

From source file:dpcs.UninstallSystemApps.java

@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" })
public UninstallSystemApps() {
    setResizable(false);//  w w  w .j a  va2 s  .  c o m
    setTitle("Uninstall System Apps");
    setIconImage(
            Toolkit.getDefaultToolkit().getImage(UninstallSystemApps.class.getResource("/graphics/Icon.png")));
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 482, 475);
    contentPane = new JPanel();
    contentPane.setBackground(Color.WHITE);
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel AppStatus = new JLabel("");
    AppStatus.setBounds(12, 393, 456, 17);
    contentPane.add(AppStatus);

    SystemAppUninstallDone = new JLabel("");
    SystemAppUninstallDone.setBounds(151, 312, 186, 56);
    contentPane.add(SystemAppUninstallDone);

    JLabel lblSelect = new JLabel("Select an app to remove");
    lblSelect.setBounds(26, 12, 405, 17);
    contentPane.add(lblSelect);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(22, 41, 428, 259);
    contentPane.add(scrollPane);

    final JButton btnUninstall = new JButton("Uninstall");
    btnUninstall.setToolTipText("Uninstall the selected app");
    btnUninstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            SystemAppUninstallDone.setText("");
            if (list.getSelectedValue() == null) {
                JOptionPane.showMessageDialog(null, "Please select an app first");
            } else {
                try {
                    AppStatus.setText("Uninstalling...");
                    Process p1 = Runtime.getRuntime().exec("adb remount");
                    p1.waitFor();
                    String[] commands = new String[3];
                    commands[0] = "adb shell su -c rm -r ";
                    commands[1] = "/system/app/";
                    commands[2] = " " + list.getSelectedValue();
                    Process p2 = Runtime.getRuntime().exec(commands, null);
                    p2.waitFor();
                    Process p3 = Runtime.getRuntime()
                            .exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt");
                    p3.waitFor();
                    Process p4 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt");
                    p4.waitFor();
                    Process p5 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt");
                    p5.waitFor();
                    lines = IOUtils.readLines(new FileInputStream(".systemapps.txt"));
                    values = new String[lines.size()];
                    values = lines.toArray(values);
                    list = new JList();
                    list.setModel(new AbstractListModel() {
                        public int getSize() {
                            return values.length;
                        }

                        public Object getElementAt(int index) {
                            return values[index];
                        }
                    });
                    scrollPane.setViewportView(list);
                    File file = new File(".systemapps.txt");
                    if (file.exists() && !file.isDirectory()) {
                        file.delete();
                    }
                    AppStatus.setText("App has been uninstalled successfully");
                    SystemAppUninstallDone
                            .setIcon(new ImageIcon(Interface.class.getResource("/graphics/Smalldone.png")));
                    btnUninstall.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });
    btnUninstall.setBounds(26, 327, 107, 27);
    contentPane.add(btnUninstall);

    JButton btnRefresh = new JButton("Refresh");
    btnRefresh.setToolTipText("Refresh the apps list");
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt");
                p2.waitFor();
                Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt");
                p3.waitFor();
                lines = IOUtils.readLines(new FileInputStream(".systemapps.txt"));
                values = new String[lines.size()];
                values = lines.toArray(values);
                list = new JList();
                list.setModel(new AbstractListModel() {
                    public int getSize() {
                        return values.length;
                    }

                    public Object getElementAt(int index) {
                        return values[index];
                    }
                });
                scrollPane.setViewportView(list);
                File file = new File(".systemapps.txt");
                if (file.exists() && !file.isDirectory()) {
                    file.delete();
                }
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });
    btnRefresh.setBounds(344, 327, 107, 27);
    contentPane.add(btnRefresh);

    try {
        Process p1 = Runtime.getRuntime().exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt");
        p1.waitFor();
        Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt");
        p2.waitFor();
        Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt");
        p3.waitFor();
        lines = IOUtils.readLines(new FileInputStream(".systemapps.txt"));
        values = new String[lines.size()];
        values = lines.toArray(values);
        list = new JList();
        list.setModel(new AbstractListModel() {
            public int getSize() {
                return values.length;
            }

            public Object getElementAt(int index) {
                return values[index];
            }
        });
        scrollPane.setViewportView(list);
        JLabel lblNewLabel = new JLabel("Note: You should also remove app's odex file if it exists");
        lblNewLabel.setBounds(25, 374, 438, 17);
        contentPane.add(lblNewLabel);

        JLabel label = new JLabel("Needs root and does not work on production android builds!");
        label.setBounds(25, 413, 454, 17);
        contentPane.add(label);
        File file = new File(".systemapps.txt");
        if (file.exists() && !file.isDirectory()) {
            file.delete();
        }
    } catch (Exception e) {
        System.err.println(e);
    }
}