Advertisement
Guest User

Untitled

a guest
Mar 10th, 2011
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.47 KB | None | 0 0
  1. //Interface.java
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import javax.swing.*;
  6. import java.io.*;
  7. import javax.swing.*;
  8. import java.awt.Cursor.*;
  9. import javax.swing.text.*;
  10. import java.text.*;
  11. import java.util.*;
  12. import javax.swing.undo.*;
  13. import javax.swing.event.*;
  14. import java.net.*;
  15. import java.awt.print.*;
  16. import java.awt.geom.*;
  17. import java.util.Vector;
  18. import javax.swing.JToolBar;
  19. import javax.swing.JPanel;
  20. import javax.swing.filechooser.*;
  21. import java.awt.geom.*;
  22. import java.awt.event.ActionListener;
  23. import java.awt.event.ActionEvent;
  24. import java.awt.print.PrinterJob;
  25. import java.awt.event.ActionListener;
  26. import javax.swing.filechooser.*;
  27. import javax.swing.JEditorPane;
  28. import javax.swing.JFrame;
  29. import javax.swing.JPanel;
  30. import javax.swing.JScrollPane;
  31. import javax.swing.JSplitPane;
  32. import javax.swing.JButton;
  33. import javax.swing.table.TableColumn;
  34. import javax.swing.JTree;
  35. import javax.swing.tree.DefaultMutableTreeNode;
  36. import javax.swing.tree.TreeSelectionModel;
  37. import javax.swing.event.TreeSelectionEvent;
  38. import javax.swing.event.TreeSelectionListener;
  39. import javax.swing.tree.DefaultTreeCellRenderer;
  40. import javax.swing.ToolTipManager;
  41. import javax.swing.ImageIcon;
  42. import javax.swing.Icon;
  43. import java.net.URL;
  44. import java.io.IOException;
  45. import java.awt.Dimension;
  46. import java.awt.GridLayout;
  47. import java.awt.Component;
  48. import java.awt.Polygon;
  49. //import file/OPEN.*;
  50. import java.io.*;
  51. import java.awt.*;
  52. import java.awt.event.*;
  53. import javax.swing.*;
  54. import java.text.DecimalFormat;
  55. import javax.swing.table.DefaultTableModel;
  56. import javax.swing.table.DefaultTableCellRenderer;
  57. import javax.swing.table.JTableHeader;
  58. import javax.swing.table.TableCellRenderer;
  59.  
  60. public class Interface extends JFrame {
  61.  
  62. // global variables:
  63. //Scheduling_Session SS = new Scheduling_Session();
  64. //Paging_Session PS = new Paging_Session();
  65. Scheduling_Session SS;
  66. Paging_Session PS;
  67. Scheduling_Algorithm S_Algorithm;
  68. Paging_Algorithm P_Algorithm;
  69. Schedule schedule;
  70. boolean Schanged = false;
  71. boolean Pchanged = false;
  72. int graphWidth = 0;
  73. private final Color colorValues[] = {Color.black, Color.blue, Color.red, Color.green};
  74. private JRadioButtonMenuItem colorItems[], fonts[];
  75. private JCheckBoxMenuItem styleItems[];
  76. private JLabel displayLabel;
  77. //private JTextField outputG2;
  78. PageFaultPanel PageFault;
  79. private JTextArea outputGraphArea;
  80. private ButtonGroup fontGroup, colorGroup;
  81. private JTabbedPane tabbedPane;
  82. private int style;
  83. private JMenuItem Session_a[];
  84. private JPanel panel1, panel2;
  85. private FlowLayout layout;
  86. private JDesktopPane theDesktop;
  87. private JFileChooser fc;
  88. private JButton OpenItem;
  89. private JScrollPane OutputPane;
  90. private JInternalFrame ResultFrame;
  91. private SchedulingOutput outputGraph;
  92. private SchedulingOutput DetailedOutputGraph;
  93. private PagingOutput PO;
  94. private JTable outputTable, outputTableP;
  95. private JTable input, input2;
  96. private JInternalFrame frame, frame2;
  97. private JTextField PenaltyAverage = new JTextField(), CPU = new JTextField();
  98. //private CalculationPanel calculations;
  99. private JTextField quantum = new JTextField();
  100. private AveragePanel Average;
  101. private JButton Enlarge;
  102. private JButton Steps, StepsB;
  103. private JPanel PriorityPanel;
  104. private JSplitPane inputSplitPane;
  105. private JTextField mField, fsField, fField, CBField;
  106. private JTextField mField2, fsField2, fField2;
  107. private JButton Cal;
  108. private JLabel QLabel, fLabel, fsLabel, mLabel, CBLabel;
  109. private JLabel fLabel2, fsLabel2, mLabel2, inputTableTextP;
  110. private JLabel inputTableTextP3, outputTableTextP;
  111. private JLabel outputGraphLabel2, outputGraphText2;
  112. private JCheckBox showCache;
  113. private JRadioButton frameNo, memSize, frameNo2, memSize2;
  114. private ButtonGroup radioGroup1, radioGroup2;
  115. private ObjectOutputStream output;
  116. private ObjectInputStream inputS;
  117. JButton PrintButton = new JButton("Print", new ImageIcon("images/printer2.png"));
  118. JRadioButton Preemptive = new JRadioButton("Pre-emptive", false), nonPreemptive = new JRadioButton("Non Pre-emptive", true);
  119.  
  120. private FileInputStream fileInput;
  121. private File fileName;
  122. int Length = 35;
  123. JComboBox algorithmsComboBox;
  124. JComboBox PalgorithmsComboBox;
  125. String SAlgorithms[] = {"Choose Algorithm", "First Come First Served (FCFS)",
  126. "Round Robin (RR)", "Shortest Process Next (SPN)", "Shortest Remaining Time (SRT)", "Highest Response Ratio Next (HRRN)",
  127. "Priority scheduling", "Multilevel Feedback Queue Scheduling"};
  128.  
  129. ;
  130. //if choice=1 show number of frame field else show memory size& frame size field
  131. private int choice = 1;
  132. //if b=true show cache memory
  133. private boolean b = false;
  134. boolean pre = false;
  135. // set up GUI
  136.  
  137. public Interface() {
  138. super("CPU Scheduler");
  139.  
  140. // Set the OS Magnifier slogan
  141. ImageIcon image = new ImageIcon("images/1.png");
  142. this.setIconImage(image.getImage());
  143.  
  144. theDesktop = new JDesktopPane();
  145. getContentPane().add(theDesktop);
  146.  
  147. JToolBar toolBar = new JToolBar();
  148. toolBar.setFloatable(false);
  149. addButtons(toolBar);
  150. toolBar.setVisible(true);
  151.  
  152. // add toolBar to container
  153. //setSize(270,80);
  154. toolBar.setSize(270, 80);
  155. getContentPane().add(toolBar);
  156.  
  157. setVisible(true);
  158. getContentPane().setLayout(new BorderLayout());
  159. // set the bounds of the toolbar
  160. toolBar.setBounds(5, 0, 900, 50);
  161.  
  162. // create JTabbedPane
  163. tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
  164.  
  165. // set up pane11 and add it to JTabbedPane
  166. panel1 = new JPanel();
  167. tabbedPane.addTab(" Scheduling ", null, panel1, "Scheduling Session");
  168. //pressing Alt-1 makes the Scheduling tab appear and the index of the tab =0
  169. tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
  170.  
  171. // set up pane11 and add it to JTabbedPane
  172. panel2 = new JPanel();
  173. tabbedPane.addTab(" Paging ", null, panel2, "Paging Session"); // this is the tab content that I DO NOT want to display
  174.  
  175. // to create imageicon in the top of tap
  176. ImageIcon sicon = new ImageIcon("images/s.png");
  177. ImageIcon picon = new ImageIcon("images/p.png");
  178.  
  179. .......
  180. ..........
  181. ......
  182. .....
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement