swing

Deselect selected text in JTextPane

拟墨画扇 提交于 2021-02-20 11:23:44
问题 I have an editor in which I want to check that selected text will not contain some words. If it contains those particular words, then I need to deselect the selection made by user. Is there any way to do that in JTextPane ? 回答1: Text selection is temporaray and contiguous. You can't unselect some text in the middle of a larger string of selected text. Maybe you are talking about highlighting. Check out the API for getHighlighter(). You can add/remove highlights and specify the start/end

Change JButton focus area

左心房为你撑大大i 提交于 2021-02-20 05:14:25
问题 How do i change the area of focus on a JButton so that when i hover my cursor over the button my costume rollover Icon isn't activated slightly before my cursor is over the actual button itself. 回答1: The contains(x, y) method of the button determines when the mouse enters the button. If your custom button is not rectangular then you would need to override this method. Here is an old example that demonstrates this concept: // Old example code found on the internet somewhere // to paint a Round

Change JButton focus area

跟風遠走 提交于 2021-02-20 05:14:15
问题 How do i change the area of focus on a JButton so that when i hover my cursor over the button my costume rollover Icon isn't activated slightly before my cursor is over the actual button itself. 回答1: The contains(x, y) method of the button determines when the mouse enters the button. If your custom button is not rectangular then you would need to override this method. Here is an old example that demonstrates this concept: // Old example code found on the internet somewhere // to paint a Round

Java Swing, all images appear pixelated

微笑、不失礼 提交于 2021-02-20 04:23:25
问题 Every image in my Java Swing Programs will appear in low quality as shown below: As you can see from the image, it is not just images I am having problem with, it's graphics in general displaying like this. In the right portion you can see the problem reflected to a JFreeChart Graphic. Has anyone else had this problem, is it related to the graphics card or maybe windows DPI? The same programs will render perfectly fine in other machines so I am pretty sure it is not related to the code. 回答1:

Java Swing, all images appear pixelated

早过忘川 提交于 2021-02-20 04:23:17
问题 Every image in my Java Swing Programs will appear in low quality as shown below: As you can see from the image, it is not just images I am having problem with, it's graphics in general displaying like this. In the right portion you can see the problem reflected to a JFreeChart Graphic. Has anyone else had this problem, is it related to the graphics card or maybe windows DPI? The same programs will render perfectly fine in other machines so I am pretty sure it is not related to the code. 回答1:

Java Swing Apache POI make Word Document read only

五迷三道 提交于 2021-02-19 23:15:56
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

老子叫甜甜 提交于 2021-02-19 23:10:57
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

二次信任 提交于 2021-02-19 23:08:36
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

旧城冷巷雨未停 提交于 2021-02-19 23:08:26
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

How to use a JPanel as JButton?

泪湿孤枕 提交于 2021-02-19 08:41:27
问题 I must use a swing-ui designer tool to create my UI, that only supports graphically editing JPanels. Those panels (they basically contain complex button designs) to work like a JButton. I cannot use anything other than JPanel as base class of these panels (UI editor limitation). What is the most generic solution to do this? Create a custom button that uses the panel's draw method instead of it's own? Create a base-panel class that reimplements the whole button? Another more elegant solution?