Helen Wallace

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

Recent posts by Helen Wallace

Hi there,

thanks for that. It works but what I don't understand is why it works. Why by passing the graphics context in does the refresh happen automatically? In my draw method I've had access to the panel and I've been doing something like this:



Why does that not work?

Many thanks,

Helen
17 years ago
Hi Sammaiah,

I tried calling super.paintComponent but that didn't work. I have access to the Graphics object in the draw method but I don't know what use it will be.
17 years ago
Hi All,

I have a problem with disappearing graphics on a JPanel which I'd like to describe. I have a class that extends JPanel that looks like this:



My Polygon class's draw method looks like this:



The idea is that whenever I draw a polygon to the screen I also add it to the arraylist of polygons (I do this in the constructor of the Polygon class) and so whenever the paintComponent method of the MyPanel class is automatically called I loop through the arraylist calling draw() on each of the polygons.

This is sort of work but there is a problem. Whenever I maximise, minimise or resize the frame in which the panel is a component the polygons disappear and only reappear when the frame is moved around the screen a bit.

Does anyone know what I'm doing wrong and how I might solve this issue?

Many thanks,

Helen
17 years ago
Hi all,

I have a problem with JTable. I have a table from which I get the value of a particular cell from the selected row thus:



The problem is I thought that by using the column name instead of an integer to get the column from the table I would avoid the problem of getting the wrong column if the columns were moved around table. This is not so. When I move the columns around I get the wrong column from the table and hence the wrong value from the row. Am I doing something obviously wrong here?

Is there for instance something I'm missing in the table model:



Cheers

Helen
17 years ago
Hi Chris,

Many thanks. Any idea about question 2?

Helen
Dear friends,

I hope you all fine. I am new to this site and would like to ask some questions about locking that I am having problems with and wonder if you would be able to help me. My update() method in my Data class looks like this:



Now, io is the class which contains my random access file which I use to read and write to the database file with.

My questions are these:

1. Monkhouse says that we should use while loops inside synchronized blocks instead of if statements. Hence, I have used "while (isLocked(recNo)) {". The first question is: is this right?

2. My second question involves booking records. When the user books a record I have some code that looks like this:

... lock(); ... read(); ... update(); ... unlock(); ...

In other words I lock the record in question, read the latest version of the data from the database, update database with customer id and then unlock. Here are the issues:

a) Do I need to lock() before I read() or can I lock() after read() but before update().

b) My most serious problem is this. Since I call unlock() before I call update() when I reach the while loop in update() isLocked() returns true (as it would) which means I never progress further in the method than the while loop. What should one do in this case? Should I not call lock() and unlock() in the code that deals with the user selecting a record to book or should I not call lock() and unlock() in my update() method or is there something else that I am doing wrong? The reason I wanted to call lock() and unlock() in my calling code is because I would like to 'reserve' the record early on so that in my calling code if I get swapped out by some other thread they don't book my record under my feet. I'd be interested in knowing what you all have done.

Warm regards,

Helen