H Lander

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

Recent posts by H Lander

There is a commercial product which provides a wide variety of Print and Page Setop dialogs: Java Print Dialog Framework. You can get a free Demo at Java Print Dialog Framework
18 years ago
Whenever new text is loaded into your text area record the index of the JList item to which that text corresponds. When the text area loses focus, update the list item to which the text corresponds (whose index you you have recorded). This may or may not be the currently selected item. If you do this, then you do not need to worry about the order of the events.

Good luck,
Henry
19 years ago
You can do the following on the Text Area:
theTextArea.getPreferredSize().height
That takes into account the space required for the borders.

However, I wouldn't recommend that as it would slow down the painting of the table. I would recommend, that you find out how much height each line requires by trial and error. Assuming that 18 pixels is appropriate, then set the row height to either 18, 36, or 54 based on the number of lines in the address. If the Text Area has a border, then add the space required at the top and bottom for the border.

Good Luck,
Henry
19 years ago
The height of each row in a JTable is by default fixed (16 pixels). In your table you have to specify the height of each row using the setRowHeight(int row, int rowHeight) method. If you know how many lines are in the row, then you can probably do this from the TableCellRenderer (not sure though as I have not actually done it).

I would recommend against the idea of changing the height of the dialog as the user scrolls down the table. It would probably not work well (other than to irritate the user of your dialog).

Good Luck,
Henry
19 years ago
Joe:

To eliminate the extra pixels make the change below to the RotatedContentPane constructor. By default, a JPanel uses a FlowLayout which has a 5 pixel inset on all four sides. The change specifies a Flow Layout without any inset.

To understand the difference between paint() and paintComponent() read the Javadoc for the paint() method in the javax.swing.JComponent class. Basically, the paint() method does everything needed to paint the component and all of its contents. One of the things it does is to call the paintComponent() method.

Regards,
Henry


19 years ago
Joe:

Reading your post made me realize that I did someting I had not inteded. I had intended to overload the paint() method not the paintComponent() method in the RotatedContentPane. (Careless cut and paste on my part.)

When I made the change (see below) it fixed the repaint problem. (Make sure to call super.paint(g) from this method not super.paintComponent(g))

Regards,
Henry


[ October 24, 2005: Message edited by: H Lander ]
19 years ago
I agree its a bit clumsy. Although if you define methods to set the Font Size, Family and other attributes, and call these methods from the GUI controls of your text editor it will work quite fine.

Good idea looking at what the Action does.

Regards,
Henry
19 years ago
If you can replace the entity names by their numeric equivalents then the JEditorPane will render them correctly. For example, "& bull;" can be replaced by "& 149;".

Good Luck,
Henry
19 years ago
I have not actually done this, but I read somewhere that you should scale the Graphics Context as displayed below.

Try it and let us know how it worked.

Good Luck,
Henry

19 years ago
One way you can do it is to use HTML. You can load the HTML into a JEditorPane which you can display on the screen. This will give you the full power of HTML for laying out the material to be printed. That's the easy part.

The hard part is printing the JEditorPane. I've used a commercial package which does this, its called the "Java Print Dialog Framework". See their web page for details: Soft Frame Works
19 years ago
The ability to print tables was introduced in Java 1.5. There is nothing corresponding to it in Java 1.4. However, I am sure that if you search the web you can find some code that will print your table under Java 1.4.

I've worked with a comercial package that prints tables under both Java 1.4 and 1.5, although it does not work in applets (only applications). Its called the "Java Print Dialog Framework".
19 years ago
You can do it using actions defined by javax.swing.text.StyledEditorKit.
The code below demonstrates this.

Good luck,
Henry

19 years ago
Here is something that gets you most of the way there. Basically, I've replaced the window's content pane with one that does the necessary rotation. This means that the individual panels do not need to be rotated.

The one remaining issue I noticed is that when part of the window is obscured, and then reshown it does not paint right. I suspect that some other method rather than the content pane paint() method I wrote is being called to repaint only portions of the window. When the entire window is repainted it works fine.

Good Luck,
Henry

19 years ago
The code looks fine to me. I suggest that the problem is somewhere else. There are two possibilities that occur to me:

1) Perhaps your Text Field is not really visible. Try giving is a background color or some text when you first create it so that you can confirm that it is in fact visible.

2) Perhaps somwhow you have two instances of the text field, and the one whose text you are setting is not the one on the screen.

Good luck.
19 years ago

Originally posted by Paul Wright:
I have this bit of code in my application. Its for a sudoku solver. When the user presses the solve button it should write to a JTextField stating that it is "solving" then once solved should rewrite to the same textfield "no errors". The problem I am having is that is it not writing the first solving and regardless of what I try it wont write.

You will see the System.out.prinln() functions. They work and write the exact thing that should be in the jtextfield.

Is there something about actionlisteners or jtextfields im not getting? Maybe something to do with the refresh rate or something....

Any help would be much appreciated.

19 years ago