Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. public static JTextField percentLine = null;
  2.  
  3. private static String DEFAULT_PERCENT = "90.0";
  4.  
  5. private static float percentage;
  6.  
  7. private static JFrame errorWindow;
  8.  
  9. private static JButton enterPercent;
  10.  
  11. public JPanel initCustomization()
  12. {
  13. percentage = new Float(DEFAULT_PERCENT)/100;
  14. //new panel to contain all the elements
  15. JPanel percentLinePanel = new JPanel();
  16. //create text field for user input
  17. percentLine = new JTextField(5);
  18. percentLine.addActionListener(new ActionListener(){
  19. public void actionPerformed(ActionEvent e)
  20. {
  21. percentLine.setText(percentLine.getText());
  22. }
  23. });
  24. percentLine.setEditable(true);
  25. percentLine.setText(DEFAULT_PERCENT);
  26. percentLine.setPreferredSize(new Dimension(100,25));
  27. //create label beside text field
  28. JLabel percentLineLabel = new JLabel();
  29. percentLineLabel.setText("Enter percent line to display (1-100)%:");
  30. //create the confirmation button
  31. enterPercent = new JButton();
  32. enterPercent.setText("Confirm");
  33. enterPercent.addActionListener(new ActionListener(){
  34. public void actionPerformed(ActionEvent e)
  35. {
  36. if(checkPercent(percentLine.getText())) //check for valid input
  37. {
  38. setPercent(percentLine.getText());
  39. JOptionPane.showMessageDialog(errorWindow,
  40. (percentLine.getText()+"% Line has been set."),"Confirmation",
  41. JOptionPane.INFORMATION_MESSAGE);
  42. }
  43. }
  44. });
  45. enterPercent.setPreferredSize(new Dimension(80,25));
  46.  
  47. percentLinePanel.add(percentLineLabel, BorderLayout.WEST);
  48. percentLinePanel.add(percentLine, BorderLayout.CENTER);
  49. percentLinePanel.add(enterPercent, BorderLayout.EAST);
  50.  
  51. return percentLinePanel;
  52. }
  53.  
  54. super();
  55.  
  56. model = new ObjectTableModel(COLUMNS,
  57. SamplingStatCalculator.class,
  58. new Functor[] {
  59. new Functor("getLabel"), //$NON-NLS-1$
  60. new Functor("getCount"), //$NON-NLS-1$
  61. new Functor("getMeanAsNumber"), //$NON-NLS-1$
  62. new Functor("getMedian"), //$NON-NLS-1$
  63. new Functor("getPercentPoint", //$NON-NLS-1$
  64. new Object[] { StatVisualizerAddOn.getPercent() }), //90% line
  65. new Functor("getMin"), //$NON-NLS-1$
  66. new Functor("getMax"), //$NON-NLS-1$
  67. new Functor("getErrorPercentage"), //$NON-NLS-1$
  68. new Functor("getRate"), //$NON-NLS-1$
  69. new Functor("getKBPerSecond") //$NON-NLS-1$
  70. },
  71. new Functor[] { null, null, null, null, null, null, null, null, null, null },
  72. new Class[] { String.class, Long.class, Long.class, Long.class, Long.class,
  73. Long.class, Long.class, String.class, String.class, String.class });
  74. clearData();
  75. init();
  76. }
  77.  
  78. addon = new StatVisualizerAddOn();
  79. JPanel percentile = addon.getPanel();
  80. mainPanel.add(percentile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement