Results 1 to 2 of 2
- 02-15-2010, 12:40 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
how to implement simply a progress bar
i want to see the progress of searching the value in my table, but I dont have any idea how. what im thinking now is maybe there is something to do with threads. i dont know anything about threads its too far from what i learned now. pleas help me with this one.
Java Code:public class ProgressSample extends JFrame { public ProgressSample() { ProgressBar monitor = new ProgressBar(); JPanel panel = new JPanel(); final JTextField searchField = new JTextField(); panel.setLayout(null); final String[] columns = {"Name", "Surname", "Age"}; Object[][] values = {{"Jhon", "Java", "23"}, {"Stupid", "Stupido", "500"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Michael", "Winnie", "20"}, {"Winnie", "Thepoor", "23"}, {"Max", "Dumbass", "10"}, {"Melanie", "Martin", "500"}, {"Jollibe", "Mcdonalds", "15"}}; final JTable mainTable = new JTable(values, columns); mainTable.setColumnSelectionAllowed(true); mainTable.setRowSelectionAllowed(true); JScrollPane scroll = new JScrollPane(mainTable); scroll.setBounds(0, 100, 900, 500); searchField.setBounds(10, 50, 150, 20); searchField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // set the column selection to false to gain multiple row selection mainTable.setColumnSelectionAllowed(false); // clear the selection for the next search, so the table wont // be flooded by selection highlight. mainTable.clearSelection(); String value = searchField.getText(); for (int row = 0; row <= mainTable.getRowCount() - 1; row++) { for (int col = 0; col <= mainTable.getColumnCount() - 1; col++) { if (value.equals(mainTable.getValueAt(row, col))) { // this will automatically set the view of the scroll in the location of the value mainTable.scrollRectToVisible(mainTable.getCellRect(row, col, true)); // this will automatically set the focus of the searched/selected row/value mainTable.addRowSelectionInterval(row, row); } } } } }); monitor.setBounds(300, 50, 200, 20); panel.add(monitor); panel.add(searchField); panel.add(scroll); getContentPane().add(panel); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(906, 700); setLocationRelativeTo(null); setVisible(true); } public static void main(String[] args) { new ProgressSample(); } }
- 02-15-2010, 03:28 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
How to simply get if a key is pushed?
By ChazZeromus in forum New To JavaReplies: 6Last Post: 07-28-2009, 01:32 AM -
It simply won't sort
By xf021209 in forum New To JavaReplies: 7Last Post: 04-25-2009, 03:53 PM -
input to an integer (simply)
By chitwood in forum Advanced JavaReplies: 3Last Post: 03-18-2009, 06:34 AM -
Error With Simply Displaying Picture
By JDCAce in forum Java AppletsReplies: 4Last Post: 10-07-2008, 08:09 PM -
how to implement progress bar .....
By roshithmca in forum AWT / SwingReplies: 1Last Post: 03-06-2008, 04:18 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks