awt

How to prevent parent frame closed when closing child frame (Java + iReport)?

落爺英雄遲暮 提交于 2019-12-17 19:36:57
问题 Basically I want to call JasperViewer from a button on my Main Application. I use this private void btnExportActionPerformed(java.awt.event.ActionEvent evt) { try { JasperPrint printer = JasperFillManager.fillReport(getClass().getResourceAsStream("reportRecharge.jasper"), params, new JREmptyDataSource()); JasperViewer jv = new JasperViewer(printer); jv.setVisible(true); } catch (JRException ex) { ex.printStackTrace(); } } When a JasperViewer appear and I close it, the main frame / parent also

Using Java to send key combinations

人盡茶涼 提交于 2019-12-17 18:40:43
问题 As per this previous link (How to send keyboard outputs) Java can simulate a key being pressed using the Robot class. However, how could a combination of key presses be simulated? If I wanted to send the combination "alt-123" would this be possible using Robot? 回答1: The simple answer is yes. Basically, you need to wrap the keyPress/Release of the Alt around the other keyPress/Release s public class TestRobotKeys { private Robot robot; public static void main(String[] args) { new TestRobotKeys

Show HTML file in JEditorPane

送分小仙女□ 提交于 2019-12-17 17:01:00
问题 I am working on a Swing application in which I have to show HTML files. I am using JEditorPane control for it. It is showing the content of HTML file but not in the same format as originally in the actual HTML file. JEditorPane does not support the object element. Rather than loading the object file its just showing ? . Is there any other inbuilt control in Swing to browse the HTML file rather than JEditorPane ? I am using the following code: JEditorPane HtmlPane= new JEditorPane(); File

Closing a Web Browser for a specific URL from the java program

杀马特。学长 韩版系。学妹 提交于 2019-12-17 16:53:50
问题 I want to close an open web browser/browser tab for a specific URL from the java program. I am able to open the URL in internet explorer using the Desktop API from java. Below is the code snippet to open the browser in IE java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); desktop.browse(new java.net.URI("http://www.xyzz.com")); Now When I run the program again I want to make sure that there is no already instance where the above URL is opened in the browser. If it is so, close it and

Java Double Buffering

跟風遠走 提交于 2019-12-17 16:49:26
问题 I'm working on a project and I've read up as much as I can on double buffering in java. What I want to do is add a component or panel or something to my JFrame that contains the double buffered surface to draw to. I want to use hardware acceleration if possible, otherwise use regular software renderer. My code looks like this so far: public class JFrameGame extends Game { protected final JFrame frame; protected final GamePanel panel; protected Graphics2D g2; public class GamePanel extends

Create rectangle with mouse drag, not draw

删除回忆录丶 提交于 2019-12-17 16:41:03
问题 I want create a rectangle using the whole screen. By using the whole screen, I mean something like this: To start, is that even possible in Java, using the whole screen like that? Second, how would I go about doing it? Another thing, I do not want to draw an actual rectangle, I want to create on, as in a new java.awt.Rectangle . 回答1: nb- First thing to note, this is done using Java 7, creating a transparent window in Java 6 is done differently and is not possible below update 10 (I believe)

Embed HWND (Window Handle) in a JPanel

≯℡__Kan透↙ 提交于 2019-12-17 16:39:28
问题 I am trying to embed a HWND (Window Handle) in a JPanel. Actually, I can embed my HWND into a JFrame, but the embedded window alway stay on top of the other component and I can't move it. If a try to remove all the child component of my JFrame, the HWND stay there. The HWND seems to be paint on top of the JFrame and not as one of is child. To embed the HWND into the JPanel I use User32 through jna: User32.SetParent(iage.getRenderHwnd(), (int) getGUIHwnd(j)); And I use this to get the HWND of

以java为剑,仗剑走江湖

跟風遠走 提交于 2019-12-17 15:56:58
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 以java为剑,仗剑走江湖 我不只是一个IT民工,我还是一个IT爱好者,对一件事情狂热的人往往会遐想连篇,热爱大海的人把大海想成各种凶猛野兽,一心想去征服;热爱天空的人把天空想象温文尔雅的美女,向之往之夜不能寐;而我,则把代码看作是逍遥自在的江湖,我自己也化作一名酒诗为伴,举剑轻畅,策马江湖的侠客,在这个世界里没有勾心斗角,有的,只是互相切磋技艺又互相研习武功,经常会被对方的招式惊羡到又或有时被打的鼻青脸肿,眼泪横流,但是这个江湖,始终没有盟主,有的只是绿水青山,百家绝技令人心驰神往... 上面的话摘自CSDN一个叫流云飞水的博主写的,这段话对于我这么一个热爱武侠小说的人来说有致命吸引力,有一种耳目一新的感觉,第一次觉得java还可以这么学。让我生出一种恨不得快去敲几个小时代码的冲动, 在我看来如果代码是一个江湖,那java就是逍遥在这个江湖中的侠客们手中的一件兵器,就像独孤求败手里的玄铁重剑,独步武林,亦或是倚天剑和屠龙刀,谁能拥有就能一统江湖。如此想来,学习java也像是一种江湖中的功法秘籍,人人可以习得,但以后成就还得看自我的不断努力和探索。 我决定以后每日记录自己的学习过程,分享一些我自己学习的基础知识,千里之行始于足下,我分享可能是网上随处可见的java基础知识,也可能是我自己的一些想法体会

Adding a point to polygon

五迷三道 提交于 2019-12-17 14:56:41
问题 I've created a class that extends the awt.Polygon class. I'm trying to write a method that given the PathIterator of the polygon and a Point representing a vertex, adds the point at the appropriate location in the path. For Example: A Polygon thats points are (0,0) (0,10) (10,10) (10,0) (A square), given the point (1,5) would make the polygon (0,0) (1,5) (0,10) (10,10) (10,0) Thanks in advance 回答1: Expanding on @normalocity's idea, this appears to be a possible approach. Addendum: For

Adding a point to polygon

空扰寡人 提交于 2019-12-17 14:56:02
问题 I've created a class that extends the awt.Polygon class. I'm trying to write a method that given the PathIterator of the polygon and a Point representing a vertex, adds the point at the appropriate location in the path. For Example: A Polygon thats points are (0,0) (0,10) (10,10) (10,0) (A square), given the point (1,5) would make the polygon (0,0) (1,5) (0,10) (10,10) (10,0) Thanks in advance 回答1: Expanding on @normalocity's idea, this appears to be a possible approach. Addendum: For