1 14 package wingset; 15 16 import org.wings.*; 17 18 import java.awt.event.ActionEvent ; 19 import java.awt.event.ActionListener ; 20 21 25 public class ProgressBarExample extends WingSetPane { 26 27 public SComponent createExample() { 28 final SButton forward1Percent = new SButton("+1"); 29 final SButton forward10Percent = new SButton("+10"); 30 final SButton backward1Percent = new SButton("-1"); 31 final SButton backward10Percent = new SButton("-10"); 32 33 final SProgressBar progressBar = new SProgressBar(0, 100); 34 35 ActionListener al = new ActionListener () { 36 public void actionPerformed(ActionEvent e) { 37 int valueChange = 0; 38 if (e.getSource() == forward1Percent) { 39 valueChange = 1; 40 } else if (e.getSource() == forward10Percent) { 41 valueChange = 10; 42 } else if (e.getSource() == backward1Percent) { 43 valueChange = -1; 44 } else if (e.getSource() == backward10Percent) { 45 valueChange = -10; 46 } 48 progressBar.setValue(progressBar.getValue() + valueChange); 49 } 50 }; 51 forward1Percent.addActionListener(al); 52 forward10Percent.addActionListener(al); 53 backward1Percent.addActionListener(al); 54 backward10Percent.addActionListener(al); 55 56 progressBar.setUnfilledColor(java.awt.Color.gray); 57 progressBar.setFilledColor(java.awt.Color.red); 58 progressBar.setForeground(java.awt.Color.red); 59 progressBar.setBorderColor(java.awt.Color.black); 60 progressBar.setStringPainted(true); 61 progressBar.setPreferredSize(new SDimension(250,-1)); 62 progressBar.setProgressBarDimension(new SDimension(250,12)); 63 64 progressBar.setValue(20); 65 66 SContainer panel = new SPanel(); 67 68 try { 69 java.net.URL templateURL = getSession().getServletContext().getResource("/templates/ProgressBarExample.thtml"); 70 STemplateLayout layout = new STemplateLayout(templateURL); 71 panel.setLayout(layout); 72 } catch (Exception ex) { 73 ex.printStackTrace(); 74 } 75 76 panel.add(progressBar, "ProgressBar"); 77 panel.add(forward1Percent, "Forward1Percent"); 78 panel.add(forward10Percent, "Forward10Percent"); 79 panel.add(backward1Percent, "Backward1Percent"); 80 panel.add(backward10Percent, "Backward10Percent"); 81 82 83 return panel; 84 } 85 86 87 } 88 89 90 | Popular Tags |