Dude,
super() has to be the first line in any function you use it in. Period. End of Discussion.
Monday, August 23, 2004
Wednesday, August 18, 2004
Tokenize strings, the StringTokenizer
Notice the different techniques to use tokenizer. StringTokenizer is self - explanatory,
RETokenizer tokenizes on regexs. The one in the example, treats and, AND, or and OR as
delims and also returns the delims as tokens. StringTokenizer doesnot return delims.
----------------------------------------------------------------------------------
String text;
StringTokenizer st = new StringTokenizer(text,",");
-----------
Iterator t = new RETokenizer(s,"\\s(and|AND|or|OR)\\s", returnDelims);
while(t.hasNext())
{
String cs = (String)t.next();
if(!(cs.equalsIgnoreCase(" and ") || cs.equalsIgnoreCase(" or ")))
conditionList.add(cs);
}
----------------------------------------------------------------------------------
ProtocolQuery : edu.upmc.database.SQLStatement
RETokenizer tokenizes on regexs. The one in the example, treats and, AND, or and OR as
delims and also returns the delims as tokens. StringTokenizer doesnot return delims.
----------------------------------------------------------------------------------
String text;
StringTokenizer st = new StringTokenizer(text,",");
-----------
Iterator t = new RETokenizer(s,"\\s(and|AND|or|OR)\\s", returnDelims);
while(t.hasNext())
{
String cs = (String)t.next();
if(!(cs.equalsIgnoreCase(" and ") || cs.equalsIgnoreCase(" or ")))
conditionList.add(cs);
}
----------------------------------------------------------------------------------
ProtocolQuery : edu.upmc.database.SQLStatement
Server Side includes when your server doesnot support it
This works only with HTML. A typical use will be to place some piece of html code at the top of every page on the website, used when you have a menu bar on each page. A big pain is to modify the menu, because you have to go to each and every page and do the changes to make it uniform.
Ofcourse there are other solutions like using frames so that now there is only 1 file to modify.
But what if you dont want to use frames.... Javascript to the rescue.
Use Javascript document.write method to write out the html code to your page. Place this javascript code in a something.js file and include something.js in every page where you want to have that html code present.
Including for javascript is as simple as
<script language="javascript" src="something.js">
I typically write 2 functions in this file, namely writeHeader() and writeFooter(). At the exact location where I want the code to be written I call this function
Example :
Ofcourse there are other solutions like using frames so that now there is only 1 file to modify.
But what if you dont want to use frames.... Javascript to the rescue.
Use Javascript document.write method to write out the html code to your page. Place this javascript code in a something.js file and include something.js in every page where you want to have that html code present.
Including for javascript is as simple as
<script language="javascript" src="something.js">
I typically write 2 functions in this file, namely writeHeader() and writeFooter(). At the exact location where I want the code to be written I call this function
Example :
<body class="main" onload="MM_preloadImages('images/mmenuhomeon.gif','images/mmenuabouton.gif','images/mmenueventson.gif','images/mmenugovernon.gif','images/mmenubbon.gif','images/mmenulinkson.gif','images/mmenucontactoff.gif')">
<script type="text/javascript">writeHeader()script>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
...
...
-----------------------------------------------------------------
Of ActionListeners and Popup menus
An example of how to use ActionListeners.
-------------------------------------------
class LoadAction extends AbstractAction {
LoadAction(){
super("Load"); //this is the menu item name in a popup
}
public void actionPerformed(ActionEvent e){
//do what you want to here
}
---------------
JPopupMenu popup = new JPopupMenu();
popup.add(new LoadAction());
---------------
You can also call the Action explicitly by
new LoadAction().actionPerformed(null);
-----
If you need access to members of the parent class pass them to the LoadAction constructor. when you create it.
--------
edu.upmc.opi.spin.client.SpinDataStoreTreeViewer
-------------------------------------------
class LoadAction extends AbstractAction {
LoadAction(){
super("Load"); //this is the menu item name in a popup
}
public void actionPerformed(ActionEvent e){
//do what you want to here
}
---------------
JPopupMenu popup = new JPopupMenu();
popup.add(new LoadAction());
---------------
You can also call the Action explicitly by
new LoadAction().actionPerformed(null);
-----
If you need access to members of the parent class pass them to the LoadAction constructor. when you create it.
--------
edu.upmc.opi.spin.client.SpinDataStoreTreeViewer
About this blog
Hi wanderer,
This blog wasnt created for your viewing pleasure. It just contains some random ideas and code snippets that I come across when I am at work. I need a place to store these so that I can get back to them when I need them. So if some posts dont make sense to you at all... well... they weren't meant to.
This blog wasnt created for your viewing pleasure. It just contains some random ideas and code snippets that I come across when I am at work. I need a place to store these so that I can get back to them when I need them. So if some posts dont make sense to you at all... well... they weren't meant to.
Subscribe to:
Posts (Atom)