awt

How do you simulate a click on a JTextField? Equivalent of JButton doClick()?

三世轮回 提交于 2019-12-19 12:11:57
问题 I am working on a Java project and need to have a keypress simulate a click on a JTextField. What I'm looking for is the equivalent of the JButton doClick() method. I am trying to have the keypress "enter" perform the exact same function as a click on the JTextField. Not sure what other info to provide. Thanks in advance. 回答1: public void simulateKey(KeyEvent e, Component c) { Field f = KeyEvent.class.getField("focusManagerIsDispatching"); f.setAccessible(true); f.set(e, Boolean.TRUE); c

Converting BufferedImage pixel data into a readable output?

♀尐吖头ヾ 提交于 2019-12-19 11:59:13
问题 I'm trying to make a program to divide the map of an old GBA game into 16x16 tiles, save each tile, and then compare the raw image data of each grabbed tile to another list of saved tiles and automatically determine if it's the same image. So far I've managed to divide the map into 16x16 tiles, automatically save each 16x16 tile into a new image file, and then load all of these image files as BufferedImages into an array. public TileSorter() { for (int a = 0; a < 1269; a++) { try { img[a] =

BUG: Java Swing Key Bindings Lose Function with JDK 7 in OSX with awt setFullScreenWindow

六月ゝ 毕业季﹏ 提交于 2019-12-19 11:29:44
问题 EDIT 1/16/2013: The original question has been deleted. This seems to be a bug with the JDK 7 on mac OSX. I have filed a bug report with Sun (Oracle). The file below uses the awt class GraphicsEnvironment and the method setFullScreenWindow to display an image to fullscreen. No images are included, so the screen will be gray when running the code. The key bindings should, however, still work. There are two key bindings. Pressing 'ENTER' should print "Enter was pressed." to stdout. Pressing

How to change diagram Scale in Java

大兔子大兔子 提交于 2019-12-19 11:28:11
问题 I have a diagram in which x axis shows the time and the y axis shows my data. I want to change the Scale by choosing different metrics for x axis. e.g second, minute and hour scale. the default is second. therefore if I choose the minute the diagram should be smaller and be more curved. Any idea? The UI is not completed however you suppose that the there would be x and y axis. The parameter degree determines that It should be scaled to second(degree=1), minute (degree=60) or hour(degree=3600)

Java Graphics: Constructing FontMetrics from Font, without a Graphics2D

瘦欲@ 提交于 2019-12-19 10:53:06
问题 Known Given FontMetrics There is a protected constructor for FontMetrics from Font . Question: Given a Font object, is there a way to construct a FontMetrics object without going through Graphics2D.setFont , Graphics2D.getFontMetric() ? Context I'm playing with a TeX like rendering algorithm. I need to calculate bounding boxes & the such for various characters from a *.pfb file. I can construct a Font object from the *.pfb file. I need a FontMetrics object to get the ascent, descent, width.

Any workaround to getting Copy/Paste working in JDK 7 AWT Applet on Mac?

倖福魔咒の 提交于 2019-12-19 10:16:38
问题 Since Apple forced the update to JDK 7 on Mac, old AWT applets no longer support copy/paste. For example, if you visit: Simple AWT Textfield Example you cannot copy and paste into the applet text field on that page. I've confirmed that you can still copy/paste in AWT on Windows with JDK 7. Anybody know a workaround? 回答1: Oracle released Java 6 Update 24 in February 2011 to remedy 21 vulnerabilities: Announcement As part of this security release, the ability to copy & paste from a computer's

Any workaround to getting Copy/Paste working in JDK 7 AWT Applet on Mac?

流过昼夜 提交于 2019-12-19 10:15:05
问题 Since Apple forced the update to JDK 7 on Mac, old AWT applets no longer support copy/paste. For example, if you visit: Simple AWT Textfield Example you cannot copy and paste into the applet text field on that page. I've confirmed that you can still copy/paste in AWT on Windows with JDK 7. Anybody know a workaround? 回答1: Oracle released Java 6 Update 24 in February 2011 to remedy 21 vulnerabilities: Announcement As part of this security release, the ability to copy & paste from a computer's

One JFrame opening another

☆樱花仙子☆ 提交于 2019-12-19 09:48:12
问题 I have a JFrame and JPanel full of Jsomethings with an actionlistener. When the user clicks an object I want to open another JFrame. Here is what I did: public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == rejectionbutton){ RejectApp ra = new RejectApp(); ra.main(null); } } (RejectApp calls a new JFrame.) So another JFrame opens on the screen with more options. It works OK (so far), but I want to know is this standard? I mean calling the main method like

Common Action Listener for 3 Buttons

只谈情不闲聊 提交于 2019-12-19 08:56:42
问题 I am having trouble with the design of my code. I have 3 buttons not in a button group. I want to - based on the selected button - perform an action. Now the action requires a modification of an object in the class. This means i cannot use an inner class because this does not have access to the outer. If i could add an event listener to a button group this would be much easier but as i see it i will need an event handler for each radio button, is this correct? If not how else can i do it?

Catch exceptions in javax.swing application

≡放荡痞女 提交于 2019-12-19 07:22:18
问题 I'm working with javax.swing to make an aplication which generates forms from XML Schema (using JAXFront library) and stores the data filled by the user them into XML documents. I have put try-catch-finally blocks when I need it, but I have a little problem catching exceptions when the main thread ends (The AWT threads are still running). I have two classes which do the main work and other classes which aren't important for the question: Main class : It has the following structure.