?? test.java
字號:
package cwq4;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class test extends JFrame {
private String sorttimes[] =
{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"};
private int sorttimes_int[] =
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
private JComboBox combobox;
private JLabel label;
private JTextArea textarea;
private FlowLayout layout;
//set up GUI
public test() {
super("Write / Read & Sort a shared array problem:");
layout = new FlowLayout(FlowLayout.LEFT,10,10);
Container container = getContentPane();
container.setLayout(layout);
label = new JLabel("please select sort times from the combobox: ");
combobox = new JComboBox(sorttimes);
container.add(label);
container.add(combobox);
textarea = new JTextArea(20,30);
textarea.setEnabled(false);
textarea.setBackground(Color.black);//.setForeground(Color.black);
//ArraySynchronized sharedArray = new ArraySynchronized();
combobox.addItemListener(
new ItemListener(){
public void itemStateChanged(ItemEvent event){
if(event.getStateChange()==ItemEvent.SELECTED)
{
ArraySynchronized sharedArray = new ArraySynchronized();
sharedArray.settimes
(sorttimes_int[combobox.getSelectedIndex()]);
textarea.removeAll();
textarea.setText("the output of this program is:\n\n");
// create threads
WriteArray producer =
new WriteArray( sharedArray, sharedArray.gettimes(), textarea );
ReadSortArray consumer =
new ReadSortArray( sharedArray, sharedArray.gettimes(), textarea );
// start threads
producer.start();
consumer.start();
}
}
}
);
container.add(textarea);
container.add(new JScrollPane(textarea));
setSize(400,500);
this.setResizable(false);
setVisible(true);
}
public static void main(String[] args) {
test application = new test();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -