Dewang Shah

Greenhorn
+ Follow
since Mar 14, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Dewang Shah

The listener requires you to import
java.awt.event.*;
24 years ago
The problem is you have not opened a connection to the url. Add the line

before you try to open the stream.
HTH
24 years ago
For your first problem, you need to add the java directory to your path.
Check you existing path entry and add an entry as
c:\jdk1.2.2\bin
24 years ago
If you dont want to draw multiple lines, you can also use fillRect() method.
24 years ago
Why do you need to use JApplet applet = new JApplet()??
You need the AppletContext() of the applet that you are running, so just use

Also, AppletViewer does not support showDocument(). That is why you dont see any result. Try viewing the applet in a browser.
24 years ago
I need to add a number of labels to a Panel. If the labels are more than can be accomodated on the Panel, then I need to display a label/button to allow the user
to scroll. I do not want to use a ScrollBar.
My call to getWidth() and getBounds() both is returning 0. Thus I have no way of
knowing when a Label is outside the visible area.
I tried setLayout(null) but then none of the labels are being displayed. And even then, the function calls still return 0
//------------- Code ------------------------------------
indexPanel.setLayout(null);
int iw = indexPanel.getWidth();
int newPos = 0;
for(int i=0;i<indexNames.size();i++) {<br /> //indexTabs and indexNames are vectors<br /> indexTabs.addElement(new Label((String)indexNames.elementAt(i),Label.CENTER));<br /> <br /> if((newPos + ((Label)indexTabs.elementAt(i)).getWidth()) > (iw - scrollR.getWidth() - 2)) {
scrollR.setLocation(newPos,0);
indexPanel.add(scrollR);
lastLabel = i-1;
break;
}

((Label)indexTabs.elementAt(i)).setLocation(newPos,0);
indexPanel.add((Label)indexTabs.elementAt(i));
newPos += ((Label)indexTabs.elementAt(i)).getWidth() + 2;
}

[This message has been edited by Dewang Shah (edited March 20, 2001).]
24 years ago
I am using two panels in my code. One to show some data, and another one with labels at the bottom of the applet to approximate a JTabbedPane with AWT.
When I check the size of the data panel, it shows the size that I have set. However when I run the applet, the panel is only of size 10x10... What could be the problem?
Even the setBounds() does not position the panel at the specified x,y. Does it require a specific Layout??
//------------ Code ----------
public void init() {
indexPanel = new Panel();
graphPanel = new Panel();
Dimension td = getSize();
int w = td.width;
int h = td.height;
// graphPanel.setSize(w,h-20);
graphPanel.setBounds(0,0,w,h-20);
d = graphPanel.getSize();
System.out.println("getSize() " + graphPanel.getSize());
System.out.println("bounds " + graphPanel.getBounds());

// indexPanel.setSize(w,18);
indexPanel.setBounds(0,h-18,w,18);
add(graphPanel);
add(indexPanel);
}
24 years ago
Hi,
One option is to use a Collection(ArrayList or LinkedList) and add each checkbox to the collection. Then wherever you need to refer to the checkbox you can refer to it via the Collection index.

Originally posted by Matt Senecal:
[B]I need to dynamically create an unspecified number of JCheckBoxes, giving one a unique static value.
Because I don't know ahead of time how many JCheckBoxes I'll have to create, I thought that I could use one JCheckBox object and (in a loop as many times as necessary) give it unique settings and then adding the (hopefully) unique checkbox to the JPanel after each loop iteration.
This doesn't work.
What happens is that on screen I get checkboxes with different names, but their values and actions all correspond to the ones assigned to the last JCheckBox created. This makes sense, as all the JCheckBoxes point to the one JCheckBox object I created.
My question: Am I on the right track, or is there a better way to do this?
[/B]


24 years ago
I have written a class that extends JPanel, and am adding it to a JTabbedPane. However I am unable to set the background color for the JPanel. The call to setBackground(Color) does not give any error but does not set the background either.
If I dont extend JPanel and add the JPanel directly to the JTabbedPane(rather than my class) ,then the background is set.
What could be the reason??
When extending the class, other methods like setFont() and setToolTipText() are working fine...
24 years ago