Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!

Sanjay Bahrani

Ranch Hand
+ Follow
since Apr 17, 2001
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 Sanjay Bahrani

Yeap you can print the JTable by using the J2TablePrinter Componnent. You can Download this package form the foll URL: http://aolsvccomp.cnet.com/downloads/0-14493-100-7674032.html
19 years ago
Hi there,
It seems you had Installed JDK1.3 under Linux. I am in urgent help to install the same under Linux. If you help me in any way it will be a pleasure .
Bye.
Sanjay
19 years ago
Hi there,
It seems you had Installed JDK1.3 under Linux. I am in urgent help to install the same under Linux. If you help me in any way it will be a pleasure .
Bye.
Sanjay
19 years ago
Hi Manav,
Noop I am not working with any of the ActiveX Controls, I am just working with Frames in Html page(5 frames) and each frame is calling the servlet. I am trying to move the values from one frame to another with the click of a mouse. I am facing the problem over there.
Sanjay.
Hi Ranchs of JScript,
I am facing a JSError as Permission/Access Denied. Any one came across this type of error help me out...
Thankz...
Hi there,
I am sending you the example for this, have a look at this...
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Family Tree Maker</title>
<link rel=stylesheet type ="text/css" href="../website.css">
<style type="text/css">
.level0 {position:relative; font:bold 12pt Arial; left:20; color:navy; display:block}
.level1 {position:relative; font:10pt Arial; left:40; color:teal; display:block}
.level2 {position:relative; font:10pt Arial; left:40; color:navy; display:none}
.level3 {position:relative; font:10pt Arial; left:40; color:teal; display:none}
.level4 {position:relative; font:10pt Arial; left:40; color:navy; display:none}
.level5 {position:relative; font:10pt Arial; left:40; color:teal; display:none}
.level6 {position:relative; font:10pt Arial; left:40; color:navy; display:none}
.level7 {position:relative; font:10pt Arial; left:40; color:teal; display:none}
.level8 {position:relative; font:10pt Arial; left:40; color:navy; display:none}
.level9 {position:relative; font:10pt Arial; left:40; color:teal; display:none}
</style>
<script type="text/javascript">
<!--
///////////////////////////////////////////////////////////////////////////
// Family Tree Maker by Patrick Brennan 10/12/2000 revised 20/12/2000 //
///////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
// Section 1 - creating the entries for the tree //
////////////////////////////////////////////////////////
function person(fullname, name, parent, children, level){
this.fullname = fullname
this.id = name
this.parent = parent
this.children = children
this.className = "level" + level
}
var TreeArray = new Array()
///////////////////////////////////////////////////////////////////////////////////////
// Each entry in the following array is in the following format: //
// Full name : Short name (this becomes the element id) : Parent ("root" for the //
// root element), children ( 0 if no, 1 if yes) : level (root = 0) //
///////////////////////////////////////////////////////////////////////////////////////
function makeArray(){
TreeArray[0] = new person("Parent", "parent", "root", "1", "0")
TreeArray[1] = new person("Child 1", "child1", "parent", "0", "1")
TreeArray[2] = new person("Child 2", "child2", "parent", "0", "1")
TreeArray[3] = new person("Child 3", "child3", "parent", "1", "1")
TreeArray[4] = new person("Grandchild 1", "gchild1", "child3", "0", "2")
TreeArray[5] = new person("Grandchild 2", "gchild2", "child3", "1", "2")
TreeArray[6] = new person("Great grandchild 1", "ggchild1", "gchild2", "1", "3")
TreeArray[7] = new person("Great-great grandchild 2", "gggchild2", "ggchild1", "0", "4")
TreeArray[8] = new person("Great grandchild 2", "ggchild2", "gchild2", "0", "3")
TreeArray[9] = new person("Grandchild 3", "gchild3", "child3", "0", "2")
TreeArray[10] = new person("Child 4", "child4", "parent", "0", "1")
TreeArray[11] = new person("Child 5", "child5", "parent", "2", "1")
TreeArray[12] = new person("Grandchild 4", "gchild4", "child5", "1", "2")
TreeArray[13] = new person("Great grandchild 3", "ggchild3", "gchild4", "0", "3")
for (i = 0; i <= TreeArray.length-1; i++){
TreeArray[i].index = i}
}
makeArray()
posbox = new Image
posbox.src = "images/posbox.gif"
negbox = new Image
negbox.src = "images/negbox.gif"
nullbox = new Image
nullbox.src = "images/nullbox.gif"
function swapImage(img){
if(img.src==nullbox.src)
{return false}
if(img.src==posbox.src)
{img.src=negbox.src}
else{img.src=posbox.src}
}

////////////////////////////////////////////////////////
// Section 2 - writing and displaying content //
////////////////////////////////////////////////////////

var content = ""
content += "<h1>Family Tree Maker</h1>"
content += "<span class='level0' id='parent'>" + TreeArray[0].fullname + "</span>"
document.write(content)
var newElem, newText, newImg
for (var i = 1; i <= TreeArray.length-1 ; i++){
newImg = document.createElement("img")
newImg.src = TreeArray[i].children == 0 ? "images/nullbox.gif" : "images/posbox.gif"
newElem = document.createElement("span")
newElem.id = TreeArray[i].id
newElem.className = TreeArray[i].className
newText = document.createTextNode(" " + TreeArray[i].fullname)
newElem.appendChild(newImg)
newElem.appendChild(newText)
document.getElementById(TreeArray[i].parent).appendChild(newElem)
navigator.appName == "Netscape" ? newImg.setAttribute("onclick", "swapImage(this); toggle(this)") : newImg.onclick = respond
}
function toggle(x){
for (var i = 2; i <= x.parentNode.childNodes.length-1; i++){
x.parentNode.childNodes[i].style.display == "block" ? x.parentNode.childNodes[i].style.display = "none" : x.parentNode.childNodes[i].style.display = "block"
}}
function respond(event){ // This function required for IE5
swapImage(window.event.srcElement)
toggle(window.event.srcElement)
}
// -->
</script>
</head>
<body>
<p class=main>This demo shows how the W3C Document Object Model can be used to create an
expanding family tree. The script is compatible with Internet Explorer 5 and Netscape 6,
with only three lines of cross-browser scripting. It is not compatible with Netscape 4.</p>
<p class=main>Clicking on a box will expand the level beneath. The script has up to 10 levels;
in this demo data has been entered in only the first five. Although presented here as a Family
Tree the script can be used for any type of folding-tree menu.</p>
<p class=main>Three images are used by this script - posbox.gif, negbox.gif and nullbox.gif.
The latter is transparent, of the same dimensions as the former, and is there simply for spacing.
They can be saved directly from the screen by right-clicking with the mouse.</p>
<p class=center>
<a href="../index.html">Home</a>
</p>
</body>
</html>

I this there are 3 images posbox.gif,nullbox.gif,negbox.gif replace it with your images. Cauze i cant send the files...
These files are like:
posbox.gif--- just like +ve sign near folder.
negbox.gif--- just like -ve sign near folder.
nullbox.gif--- just like nothing/noImage like a child/file in windows.

Hi Scriptians,
Can you help me out, I need a Tool tip on each and every component like textbox, Buttons etc on HTML page. Now How can I do this. Do you any related links for that plz. forward me.
Thankz..

Originally posted by Vangelis Kalis:
Thnaks, but not very useful!
If u have something more simply it would be great!
I have a class with my TableMobel and a class with my GUI AND jtable...
I will use an Add and a Remove button to add/remove rows!


Hi there,
If you want the MyTableModel class, I hope this can help you out.....

import javax.swing.table.AbstractTableModel;
import java.util.*;
public class MyTableModel extends AbstractTableModel {
private Vector columnNames, data;
public MyTableModel(Vector cName, Vector d){
columnNames = cName;
data = d;
//data.add(new String[]{"",""});
}
public int getColumnCount() {
return columnNames.size();
}
public int getRowCount() {
return data.size();
}
public String getColumnName(int col) {
return (String)columnNames.get(col);
}
public Object getValueAt(int row, int col) {
String rowData[] =(String [])data.get(row);
return rowData[col];
}
/*
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
*/
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
/*
* Don't need to implement this method unless your table's
* editable.
*/
public boolean isCellEditable(int row, int col) {
//Note that the data/cell address is constant,
//no matter where the cell appears onscreen.
if (col < 2) {
return false;
} else {
return true;
}
}
/*
* Don't need to implement this method unless your table's
* data can change.
*/
public void setValueAt(Object value, int row, int col) {}
}
19 years ago
Hi there,
Normally you can destroy a frame by using the window listener and you want to destroy the internal frames,wright? If yes, add the windowListener to all the internal frames and you can destroy the frames by clicking on the x button of frame.
the below code is for destroying the frame.....

import java.awt.*;
public class TestFrame{
Test(){
// Add your necessary frame components
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
}
}
19 years ago
Hi there,
Yeah you can add a Image to a tree, I can give you a link that will illustrate you this example.
I hope this link will solve your problem..... http://www2.gol.com/users/tame/swing/examples/JTreeExamples4.html
Bye....
19 years ago
Hi there,
Basically when you use the AbstractTableModel, it automatically adds the listener to your table and whenever you try to select the cell or click on the cell of the table, the TableMedelListener is implemented and the getValueAt fires.
Can yoiu elloborate your problem, cause i had worked on the AbstractTableModel quite more.
Thankz...
19 years ago
Hi there,
I think you should put the listener on the scrollbar i.e AdjustmentListener and use this method getValue() of AdjustmentEvent class.
I am giving you the example on applet, hope you will find it useful.....
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/** <applet code = "ScrollDemo.class" width = 300 height = 300>
</applet> */
public class ScrollDemo extends Applet
{
Scrollbar hsb;
Scrollbar vsb;
int v,h;
public void init(){
setLayout(new BorderLayout());
hsb = new Scrollbar(Scrollbar.HORIZONTAL,1,10,0,size().width);
vsb = new Scrollbar(Scrollbar.VERTICAL,1,10,0,size().height);
add("North",hsb);
add("East",vsb);
hsb.addAdjustmentListener(new AdjustmentListener(){
public void adjustmentValueChanged(AdjustmentEvent ae){
h=hsb.getValue();
v=vsb.getValue();
showStatus(h+""+","+v);
repaint();
}
});
vsb.addAdjustmentListener(new AdjustmentListener(){
public void adjustmentValueChanged(AdjustmentEvent ae){
h=hsb.getValue();
v=vsb.getValue();
showStatus(h+""+","+v);
repaint();
}
});
}
public void paint(Graphics g){
g.drawOval(50,50,h,v);
}
}
Bye...
19 years ago
Hi There,
What are you using for the Yes/No/Cancel Option, Are you using the JOptionPane......
19 years ago
Hi There,
You can achieve your functionality by setting the size of the JFrame(setSize(Dimension d)).
Use this Method of JFrame as setSize(Dimension dim), pass the Dimension object in this method. Before this create the Dimension object in this way.
JFrmae frame=new JFrame();
Dimension dim=new Dimension(Toolkit.getScreenSize());
frame.setSize(dim);
This will create your JFrame of your screenSize i.e maximized.
I hope this will solve your problem....
Bye..
19 years ago
Hi there,
You want to add the listeners to each cell, yeah you can do this by using ListSelectionListener. You have to add this listener to both rows and columns of the table so that each cell can react to the listener. I am giving you the example for this.
Example:
code....
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSelection=table.getSelectionModel();
rowSelection.addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent le) {
try {
if(le.getValueIsAdjusting()) return;
ListSelectionModel lsm= (ListSelectionModel)le.getSource();
if (lsm.isSelectionEmpty()) {
//Nothing to Do
}
else {
table.setCellSelectionEnabled(true);
table.setRowSelectionAllowed(false);
selectedRow=lsm.getMinSelectionIndex();
}catch(NumberFormatException ex) {}
}
});
The above code is for only the row, same way you have to use for column also.
I have used this in Calendar(Swing application), when you select a date in a calendar (Dates resides in the cells of the table) it will give you the weekday for a particular date. I had added the Listener on each cell in this way....
Regards.
19 years ago