#navi(contents-page-name): No such page: ST

FrontPage

Terai Atsuhiro 2024-02-02 (金) 11:46:37

private FileHistory fh;

private JMenu fileHistory;
private void initHistory(){
	int hmax = 0;
	if(prefs.getBoolean("flag_history", true)){
		hmax = prefs.getInt("history_size", 6);
	}
	fh = new FileHistory(prefs, "style", hmax);
	JMenu fm = getMenu("file");
	if(fileHistory==null){

		fileHistory.setMnemonic('F');
		JMenuItem exit = getMenuItem("exit");
		fm.remove(exit);
		fm.add(fileHistory);
		fm.addSeparator();
		fm.add(exit);
	}else{
		fileHistory.removeAll();
	}
	Vector vl = fh.getModel();
	if(vl.size()<=0){
		noFile.setEnabled(false);
		fileHistory.add(noFile);
	}else{
		fm.remove(noFile);
		for(int i=0;i<vl.size();i++){
			String name = (String)vl.elementAt(i);
			String num  = Integer.toString(i+1);
			JMenuItem mi = new JMenuItem(new HistoryAction(new File(name)));
			mi.setText(num + ": "+ name);
			byte[] bt = num.getBytes();
			mi.setMnemonic((int) bt[0]);
			fileHistory.add(mi);
		}
	}
}
private void updateHistory(String str){
	fileHistory.removeAll();
	Vector vl = fh.getModel();
	for(int i=0;i<vl.size();i++){
		String name = (String)vl.elementAt(i);
		String num  = Integer.toString(i+1);
		JMenuItem mi = new JMenuItem(new HistoryAction(new File(name)));
		mi.setText(num + ": "+ name);
		byte[] bt = num.getBytes();
		mi.setMnemonic((int) bt[0]);
		fileHistory.add(mi, i);
	}
}
class HistoryAction extends AbstractAction{
	final private File file;
	public HistoryAction(File file_){
		super();
		file = file_;
	}
	public void actionPerformed(ActionEvent evt){

		//if(!isSaved()){


		//	java.awt.Toolkit.getDefaultToolkit().beep();
		//	int retValue = JOptionPane.showConfirmDialog((JPanel)null, 
		//	obj, "APP_NAME", JOptionPane.YES_NO_CANCEL_OPTION);
		//	if(retValue!=JOptionPane.YES_OPTION){
		//		return;
		//    }
		//}

		//Thread loader = new FileLoader(file);
		//loader.start();
	}
}