当前位置:编程学习 > JAVA >>

求助——关于操作系统存储管理!

怎么做操作系统存储管理(主要是地址转换、FIFO、LRU三个功能)加界面的。我手头有个是用图形界面的,打算改改。可以把SWING做的图形界面改成JSP的吗?求助中......

--------------------编程问答-------------------- public class PageManagement extends JFrame implements ActionListener{

public static final int FRAME_WIDTH=600;
public static final int FRAME_HEIGHT=400;
private JTextField xulieText , pageCountText;
private JButton ok;
private JList leftPanel;
private JPanel centerPanel;
private JPanel tempPanel;

private String xlArrary [] ;
private int pageCount;

/**
 * 显示窗口
 */
public void showFrame(){
this.setLocation(200, 200);
this.setTitle("请求调页存储管理系统的模拟实现");
showF();
this.setSize(FRAME_WIDTH , FRAME_HEIGHT);
setVisible(true);
this.setResizable(false);
addWindowListener(new WindowAdapter(){
   public void windowClose(WindowEvent e){
   System.exit(0);
   }
});
this.setBackground(Color.gray);
}

/**
 * 显示界面的构造,即绘制界面元素
 */
public void showF() {
String arg[] = { " ", "FIFO" ," ", "LRU" ," ", "Optimal" ," "," "," "," "," "," "};
leftPanel = new JList(arg);
centerPanel = new JPanel();
JPanel downLeftPanel = new JPanel();
JPanel downRightPanel = new JPanel();
//JPanel tempPanel = new JPanel();

        ok = new JButton("确定");
JLabel xulie = new JLabel("访问序列:");
JLabel pageCountl = new JLabel("页块数:");
xulieText=new JTextField(15);
pageCountText=new JTextField();
downLeftPanel.setLayout(new GridLayout(5 , 1));
downLeftPanel.add(pageCountl);
downLeftPanel.add(pageCountText);
downLeftPanel.add(xulie);
downLeftPanel.add(xulieText);
downLeftPanel.add(ok);

ok.addActionListener(this);
leftPanel.addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
pageCount  = 3;
xlArrary  = new String []{"1","4","5","2","3","5","7","8"};
if(leftPanel.getSelectedValue().equals("FIFO")){
FIFO panel =  new FIFO(pageCount , xlArrary ,centerPanel);
repaint();
}
else if(leftPanel.getSelectedValue().equals("LRU")) {
LRU panel =  new LRU(pageCount , xlArrary ,centerPanel);
repaint();
}
else if (leftPanel.getSelectedValue().equals("Optimal")) {
Optimal panel =  new Optimal(pageCount , xlArrary , centerPanel);
repaint();
}
}
});


JSplitPane outPane =
new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, downLeftPanel, downRightPanel);
//outPane.setDividerLocation(20);
JSplitPane innerPane =
new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, leftPanel, centerPanel);
innerPane.setContinuousLayout( true);
innerPane.setOneTouchExpandable( true);
JSplitPane outerPane =
new JSplitPane( JSplitPane.VERTICAL_SPLIT, innerPane, outPane);
this.add(outerPane , BorderLayout.CENTER);

}
/* public void splistPane(JPanel downLeftPanel,JPanel downRightPanel) {
JSplitPane outPane =
new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, downLeftPanel, downRightPanel);
//outPane.setDividerLocation(20);
JSplitPane innerPane =
new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, leftPanel, centerPanel);
innerPane.setContinuousLayout( true);
innerPane.setOneTouchExpandable( true);
JSplitPane outerPane =
new JSplitPane( JSplitPane.VERTICAL_SPLIT, innerPane, outPane);
this.add(outerPane , BorderLayout.CENTER);
}*/

/**
 * 对ok事件进行处理
 */
public void actionPerformed(ActionEvent ea) {
if(ea.getSource() == ok) {
pageCount = Integer.parseInt(pageCountText.getText());
StringTokenizer st = new StringTokenizer(xulieText.getText() , ",");
String ag [] = new String [30];
int i=0;
while(st.hasMoreTokens()) {
            ag[i] = st.nextToken();
++i;
}
String lie[] = new String[i];
for( int j = 0;j<i;j++) 
lie[j] = ag[j];
xlArrary=lie;
for( int j =0;j<i;j++)
  //System.out.print(xlArrary[j]+" ");
JOptionPane.showMessageDialog(this, "输入数据成功!!");
}
}


public static void main(String[] args) {
      PageManagement pm=new PageManagement();
      pm.showFrame();
}




}
补充:Java ,  Java相关
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,