|
text drawn over text
Sorry, hardwired, I probably did not phrase my question very well. I know, now, that indeed using a graphical content it is possible the use: drawString(String str, int x, int y)
To display a text line over a picture.
Thanks, Fubarable, that was relatively easy to do for the moment. I looked up opaque and found “not able to see through/ not transparent”. Setting Opaque false makes since (yes, sometimes a programming problem is in fact a language problem). I added some lines of your code:
infotextPanel = new JTextArea();
scrollpane = new JScrollPane(infotextPanel); // probably won´t use the scroll pane
infotextPanel.setOpaque(false);
scrollpane.setOpaque(false);
scrollpane.getViewport().setOpaque(false);
setLayout(null);
setPreferredSize(new Dimension(800, 485));
add(infotextPanel);
public void drawinfotext (String infotext, int infotextx, int infotexty) {
infotextPanel.setBounds(infotextx, infotexty, 300, 300); // when setting // the layout to null this method changes the position, correct?
infotextPanel.setBounds(infotextx, infotexty, 300, 300);
// infotextPanel.setText(infotext);
}
great, I do see the text without white square. Thanks for the suggestion.
But I still have another ¨tiny¨ problem each time I draw a new picture the new text of that picture is printed over the previous text (which does not disappear!). The reason lies probably in the fact that I do the drawing in another class.
The class SetimagePanel triggers all GUI components and the class Editimages does the image/ text drawing etc. Each time one selects another image in JList present in the SetimagePanel class the image/text drawing happens:
public void valueChanged(ListSelectionEvent e) { // reads the list selection
// and gets the array index
if(!e.getValueIsAdjusting()) { // basically reads out the JList
sizeSlider.setValue(100); // draws the image and updates
//textinfo and all data
index = Piclist.getSelectedIndex();
editImages.downloadImage(filepath + "/Imagestore/" + img[index].name);
editImages.displayImage(1.0);
infotextPane.setText(img[index].textinfo); // the text of the edit pane
editImages.drawinfotext(img[index].textinfo, img[index].infotextx, img[index].infotexty); // text displayed over image
etc.
The info text gets two time drawn, ones on the edit pane at the same class (so the text can be edited) and ones over the image in a different class (to see the result together with the image), and only the first draw works correct! I tried several things (like repaint()) to repair this problem, but sincerely I do not understand why this happens (in one pane and not in the other……both are JTextArea panes).
willemjav
|