ciaran Hurst

Greenhorn
+ Follow
since Oct 30, 2001
Merit badge: grant badges
For More
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 ciaran Hurst

ya i fixed it. Basically i was making it more complicated than it needed to be.
21 years ago
Hi,
i have a java program that refuses to call the paint method when i call repaint. I know that i can call update as well but I believe that this won't paint swing only awt. I may be wrong on that . Therefore i need to call paint
code is below can anyone see whats the problem
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Line2D;
import java.util.HashMap;
import java.util.Iterator;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JOptionPane;
import java.util.Map;
public class DrawMethods extends ShannonTracer{

private ShannonData traceData;
private HashMap paintedButtons;
private JButton temp;
private JPanel panel;
private Dimension buttonDimension;
private Point buttonLocation, startPoint, endPoint;
private int buttonX,buttonY;
private double buttonHeight,buttonWidth;
private Graphics graphics;
private Rectangle rr;
public DrawMethods(ShannonData data, JPanel thePanel ){
panel = thePanel;
traceData = data;
paintedButtons = new HashMap();
paintedButtons = traceData.getPaintedButtons();
//drawlines();
//this.update(graphics);
//DrawMethods.this.paint(graphics);
repaint();
//panel.updateUI();
//panel.paintComponents(gg);
//this.update(gg);
}

private void drawlines(){
Iterator iter = paintedButtons.entrySet().iterator();
while(iter.hasNext()){
Map.Entry e =(Map.Entry)iter.next();
temp = (JButton)paintedButtons.get(e.getKey().toString());
getButtonDimensions(temp);
startPoint = calculateStart();
}
}

private void getButtonDimensions(JButton button){
buttonWidth = button.getWidth();
buttonHeight = button.getHeight();
buttonLocation = button.getLocation(); //can use getLocation().y or .x
buttonDimension = button.getSize();
}

private Point calculateStart(){
Point start = new Point();
Point end = new Point();
start.x = (int)((double) buttonLocation.x + (buttonWidth/2.0));
start.y = (int)((double)buttonLocation.y + (buttonHeight/2.0));
end.x=start.x+0;
end.y=start.y+200;
return start;
}

public void paint(Graphics g){
JOptionPane.showMessageDialog(null,"I am a dope");
g.setColor(Color.yellow);
Font font = new Font("arial",Font.ITALIC,55);
g.drawString("bigears" + g.getFont(),200,100);

}


}
21 years ago
hi all,
i'm writing a visual debugger in java for java programs. I believe that the only way i can get local variables in a method is via the stack frame. I get a reference to the thread suspend it and get a stack frame (code is below). I know that there are local variables in the methods cause i put them there but each time i check to see the number of frames on the stack it returns 0. This cannot be (well it is but i haven't figured out what's wrong) Any help would be appreciated. Am i doing anything wrong.

public void getLocalVariables(){
//suspend the vm ang get the stack frame

threadRef.suspend();
try{
List list = threadRef.frames();
JOptionPane.showMessageDialog(null,"frame count"+ threadRef.frameCount());
Iterator it = list.iterator();
while(it.hasNext()){
stackFrame = (StackFrame) it.next();
JOptionPane.showMessageDialog(null,"values ->" + it.next());
}
}catch(IncompatibleThreadStateException itse){
JOptionPane.showMessageDialog(null,"IncompatibleThreadStateException");
}



:roll:
21 years ago

Originally posted by Rodney Woodruff:
Here is a suggestion:
You wrote:

Solution 2:

Can you tell me why you can't call next?
[ March 07, 2003: Message edited by: Rodney Woodruff ]
[ March 07, 2003: Message edited by: Rodney Woodruff ]


cheers got it
21 years ago

Originally posted by Ashish Mahajan:
Hi Ciaran,
Is the JTextArea in which to click on a file name same as the JTextArea used as editor ?? i.e. is the file name hyperlink is in editor itself or it is in separate text area??


its just a seperate text area. In fact i will more then likely have to pull the name off the textarea and and search throung the directory structure for the name
21 years ago
hi,
i have a problem with hashset. I need to use them cause i cannot afford duplicate entries. But i need to get an element out of the hashset change it and put it back into the hashset in the same place. I wrote a simple program below. How would i for example check for a value of 3 if its 3 change it to some other number an insert it in the same place in the hashset.
public class test{
private HashSet theset, set2;
public test(){
theset = new HashSet();
set2 = new HashSet();
fillset();
set2 = theset;
printset();
}
public static void main(String[] args) {
test atest = new test();
}
public void printset(){
Iterator iter = set2.iterator();
while(iter.hasNext()){
System.out.println("the value is" + iter.next());
}
}
public void fillset(){
theset.add("1");
theset.add("2");
theset.add("3");
theset.add("4");
theset.add("5");
theset.add("6");
}
public void changeElement(){
Iterator iter = set2.iterator();
while(iter.hasNext()){
//HOW DO I CHANGE "3" WITHOUT JUMPING AHEAD ONE
// IE I CANNOT USE NEXT


}

}
}
21 years ago
Hi,
I'm basically building this editor using java. basically i want to click on the name of a file in a JTextArea and open it in an editor. How might I go about doing this. Would I have to add a listener to the entire textArea and then return back the string which was clicked on.Or is there an easier way of doing this.
21 years ago
Hi,
is there a way via a layout manager to specify the exact x and y coordinates of a Jbutton.
21 years ago
could some body please tell me how to clone a simple integer array? Do i have to construct a class that implements cloneable
thanks.
------------------
regards
Ciaran
22 years ago