Purvi Pandya

Greenhorn
+ Follow
since Feb 11, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Purvi Pandya

Hi
Another way to call dll using java than you can also use -
System.loadLibrary("hello");
run hello.dll
bye,
Purvi Pandya
16 years ago
Hi
Below code of JTabbedPane. It might be helpful to u.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.metal.*;
public class ColorTabbedPaneExample extends JFrame {
String[] titles = {"blue","cyan","green","yellow",
"orange","pink","red"};
Color[] colors = {Color.blue, Color.cyan, Color.green, Color.yellow,
Color.orange,Color.pink, Color.red };
JTabbedPane tabbedPane;
public ColorTabbedPaneExample() {
super("ColorTabbedPaneExample (Metal)");
UIManager.put("TabbedPane.selected", colors[0]);
tabbedPane = new JTabbedPane() {
public void updateUI(){
setUI(new ColoredTabbedPaneUI());
}
};
for (int i=0;i<titles.length;i++) {
tabbedPane.addTab(titles[i], createPane (titles[i], colors[i]));
tabbedPane.setBackgroundAt(i, colors[i].darker());
}
tabbedPane.setSelectedIndex(0);
tabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int i = tabbedPane.getSelectedIndex();
((ColoredTabbedPaneUI)tabbedPane.getUI()).setSelectedTabBackground(colors[i]);
tabbedPane.revalidate();
tabbedPane.repaint();
}
});
getContentPane().add(tabbedPane);
}
JPanel createPane(String title, Color color) {
JPanel panel = new JPanel();
panel.setBackground(color);
JLabel label = new JLabel(title);
label.setOpaque(true);
label.setBackground(Color.white);
panel.add(label);
return panel;
}
class ColoredTabbedPaneUI extends MetalTabbedPaneUI {
public void setSelectedTabBackground(Color color) {
selectColor = color;
}
protected void paintFocusIndicator(Graphics g, int tabPlacement,
Rectangle[] rects, int tabIndex,
Rectangle iconRect, Rectangle textRect,
boolean isSelected) {
}
}
public static void main(String[] args) {
JFrame frame = new ColorTabbedPaneExample();
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit(0);
}
});
frame.setSize( 360, 100 );
frame.setVisible(true);
}
}
bye,
Purvi Pandya
16 years ago
Hi
Below is example for DynamicTree. It might be helpful to u.
--------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DynamicTree extends JFrame {
public DynamicTree(int n) {
super("Creating a Dynamic JTree");
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
Container content = getContentPane();
JTree tree = new JTree(new OutlineNode(1, n));
content.add(new JScrollPane(tree), BorderLayout.CENTER);
setSize(300, 475);
setVisible(true);
}
public static void main(String[] args) {
int n = 5; // Number of children to give each node
if (args.length > 0)
try {
n = Integer.parseInt(args[0]);
} catch(NumberFormatException nfe) {
System.out.println("Can't parse number; using default of " + n);
}
new DynamicTree(n);
}
}
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
public class OutlineNode extends DefaultMutableTreeNode {
private boolean areChildrenDefined = false;
private int outlineNum;
private int numChildren;
public OutlineNode(int outlineNum, int numChildren) {
this.outlineNum = outlineNum;
this.numChildren = numChildren;
}
public boolean isLeaf() {
return(false);
}
public int getChildCount() {
if (!areChildrenDefined)
defineChildNodes();
return(super.getChildCount());
}
private void defineChildNodes() {
// You must set the flag before defining children if you
// use "add" for the new children. Otherwise you get an infinite
// recursive loop, since add results in a call to getChildCount.
// However, you could use "insert" in such a case.
areChildrenDefined = true;
for(int i=0; i<numChildren; i++)
add(new OutlineNode(i+1, numChildren));
}
public String toString() {
TreeNode parent = getParent();
if (parent == null)
return(String.valueOf(outlineNum));
else
return(parent.toString() + "." + outlineNum);
}
}
---------------------
bye,
Purvi Pandya
16 years ago
Hi,
below code is to load JComboBox from String[] and Hashtable both
---------------------------------------
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class JComboEx extends JFrame {
static String[] screenNames = {
"Auto Screen", "On Screen", "Off Screen",
"INT_xRGB", "INT_ARGB", "INT_ARGB_PRE", "INT_BGR",
"3BYTE_BGR", "4BYTE_ABGR", "4BYTE_ABGR_PRE", "USHORT_565_RGB",
"USHORT_x555_RGB", "BYTE_GRAY", "USHORT_GRAY",
"BYTE_BINARY", "BYTE_INDEXED", "BYTE_BINARY 2 bit", "BYTE_BINARY 4 bit",
"INT_RGBx", "USHORT_555x_RGB"};
static JComboBox screenCombo;
static JComboBox screenComboHash;
Hashtable hashScreenValue;

public JComboEx() {

screenCombo = new JComboBox();
screenCombo.setPreferredSize(new Dimension(120, 18));
screenCombo.setLightWeightPopupEnabled(true);

for (int i = 0; i < screenNames.length; i++) {
screenCombo.addItem(screenNames[i]);
}
// first i have to add item to the hash table
// bcoz at present i can't show with database

hashScreenValue = new Hashtable();
for (int i = 0; i < screenNames.length; i++) {
hashScreenValue.put(new Integer(i), screenNames[i]);
}

screenComboHash = new JComboBox();
screenComboHash.setPreferredSize(new Dimension(120, 18));
screenComboHash.setLightWeightPopupEnabled(true);

Enumeration enum = hashScreenValue.elements();
while(enum.hasMoreElements()){
String value = (String)enum.nextElement();
screenComboHash.addItem(value);
}

JPanel topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );

topPanel.add( screenCombo, BorderLayout.NORTH );
topPanel.add( new JLabel("Hello !!!"), BorderLayout.CENTER );
topPanel.add( screenComboHash, BorderLayout.SOUTH );
}
public static void main(String args[]){

JComboEx cex = new JComboEx();
cex.setSize(400,400);
cex.setVisible(true);
}
}
Bye,
Purvi Pandya
16 years ago
Hello !!!
You can do this also
----------------
(Code in Applet)
URL helloServletURL = new URL( getCodeBase().toString()+ "HelloServlet" );
URLConnection urlConnection = helloServletURL.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);

ObjectOutputStream objOut = new ObjectOutputStream (urlConnection.getOutputStream());
objOut.writeUTF(Id); // pass parameter to servlet
objOut.flush();

ObjectInputStream objIn = new ObjectInputStream(urlConnection.getInputStream());
String state = objIn.readUTF(); // read String from Servlet
----------------
(Code in Servlet)
ObjectInputStream dataInput = new ObjectInputStream(request.getInputStream());
String id = dataInput.readUTF();
ObjectOutputStream dataOutput = new ObjectOutputStream(response.getOutputStream());
dataOutput.writeUTF(status);
dataOutput.flush();
dataInput.close();
dataOutput.close();
--------------------
Purvi Pandya
16 years ago
Hello Maulin

Thanks for all your input so far.
With the use of Sun's singing tools i have solved my problem of java.security.AccessControlException: access denied & jarsigner for signing jar file. Below link is very helpfull for me.
http://java.sun.com/docs/books/tutorial/security1.2/toolsign/
Thanks
Purvi Pandya
16 years ago
Hello
I have an facing problem when i use .jar file in archive
<applet code="Sample.class" width='630' height='420' archive="sample.jar" >
</applet>
I got below exception
java.lang.SecurityException: cannot verify signature block file META-INF/ZIGBERT
at sun.security.util.SignatureFileVerifier.process(Unknown Source)
at java.util.jar.JarVerifier.processEntry(Unknown Source)
at java.util.jar.JarVerifier.update(Unknown Source)
at java.util.jar.JarFile.initializeVerifier(Unknown Source)
at java.util.jar.JarFile.getInputStream(Unknown Source)
at sun.misc.URLClassPath$4.getInputStream(Unknown Source)
at sun.misc.Resource.getBytes(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Hoping for a reply at an earliest
Please let me know if you have found a solution for this.
Thanks and Regards
purvi pandya
16 years ago