awt

How to create Java Custom Web Controls?

て烟熏妆下的殇ゞ 提交于 2019-12-12 12:11:45
问题 This question was originary in my head as "Can I use AWT controls in a Servlet?" , which will show all my ignorance on the subject. I am new to JAVA technologies but after a bit of reading, I seem to understand AWT controls directly hook up the OS GUI elements so there is no way to use or extend JPanels, JButtons and so forth in a Servlet to be injected in a JSP and let the browser render those controls (an alternative could probably be embedding an applet in a JSP but I don't wanna do that).

Why Desktop.Open() doesn't work with MagicISO being installed

China☆狼群 提交于 2019-12-12 11:06:27
问题 Here's my code if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { try { desktop.open(file.getCanonicalFile()); } catch (Exception ex) { ex.printStackTrace(); } } else { System.out.println("Desktop open action is not supported"); } } else { System.out.println("Desktop is not supported"); } I know that installing MagicISO (got it from this Java bug) will make this code doesn't work. But why? What does MagicISO

Getting Image from Clipboard Awt vs FX

不打扰是莪最后的温柔 提交于 2019-12-12 11:06:10
问题 Lately our Java-FX application can't read Images from the clipboard anymore. For example the user selects a part of an Image in Microsofts-Paint and presses copy. I am not talking about copied image files, those work fine. I'm pretty sure it worked already in the past, but I still need to verify that. Nevertheless I created a small example and compared the AWT with the FX clipboard to reproduce the behaviour: public class ClipBoardFxApp extends Application { @Override public void start( final

Java Toolkit Screen resolution descrepensies

本秂侑毒 提交于 2019-12-12 10:48:51
问题 I'm using java to get the dimensions and resolution of my screen. When I run the following code, I get the output below. Toolkit toolkit = Toolkit.getDefaultToolkit (); Dimension dim = toolkit.getScreenSize(); System.out.println("Width of Screen Size is "+dim.width+" pixels"); System.out.println("Height of Screen Size is "+dim.height+" pixels"); int resolution =Toolkit.getDefaultToolkit().getScreenResolution(); System.out.println(resolution); output: Width of Screen Size is 1920 pixels Height

Swing/JFrame vs AWT/Frame for rendering outside the EDT

隐身守侯 提交于 2019-12-12 10:48:04
问题 What are the principle differences between using an AWT Frame and a Swing JFrame when implementing your own rendering and not using standard Java GUI components? This is a follow on from a previous question: AWT custom rendering - capture smooth resizes and eliminate resize flicker The typical talking points on Swing vs AWT don't seem to apply because we're only using frames. Heavyweight vs Lightweight goes out the window (and JFrame extends Frame), for example. So which is best, JFrame or

Adding Text to Screen with OpenGL

爱⌒轻易说出口 提交于 2019-12-12 10:09:39
问题 Currently, I am working on a OpenGL project and here is the screenshoot what I did The question is, I want to add texts(degrees) to compass and want to do that with pure OpenGl methods. I found TextRenderer class however, couldn't manage to download it and use it. How to use TextRenderer class in my Java project? If there is any other way of adding text besides TextRenderer, would love to hear it. My second and most important question is about merging swing/awt methods with OpenGL and using

Eliminating Initial keypress delay

怎甘沉沦 提交于 2019-12-12 09:37:59
问题 When you type into a textbox and hold a key, you get (a.......aaaaaaaaaaaaaaa), depending on the initial key press delay. addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { // Handle key press here } I'm creating a game in which the user's reflexes are very important. How can I eliminate this delay completely? The above code does not work. I have also tried overriding processKeyEvent with no luck. 回答1: These events are generated by the JVM / operating system, and unless

Java headless bicubic image resize

♀尐吖头ヾ 提交于 2019-12-12 08:48:53
问题 I need to perform java image crop and resize without an X server. I tried several methods. the first method below works, but outputs a fairly ugly resized image (probably using nearest neighbor algorithm for the resize: static BufferedImage createResizedCopy(Image originalImage, int scaledWidth, int scaledHeight, boolean preserveAlpha) { int imageType = preserveAlpha ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB; BufferedImage scaledBI = new BufferedImage(scaledWidth,

How to import a custom java.awt.Font from a Font family with multiple TTF files? (An example is included)

送分小仙女□ 提交于 2019-12-12 08:27:32
问题 I know that you can import a Font in Java with something like this: File file = new File(fontPath); Font font = Font.createFont(Font.TRUETYPE_FONT, file); // alternative: // Font font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(file)); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.registerFont(font); Then you would use for example font.deriveFont(Font.PLAIN, 20); to get the desired style and size. Example But now let's look as an example at the

Java Glass pane

对着背影说爱祢 提交于 2019-12-12 08:05:02
问题 I have a problem. I want to ask you how can I implement GlassPane to paint on it. I mean, if I click mouse button, in mouseClicked event, my transparent glass pane should be created, because I want to see all my components behind glassPane and I can paint on it using mouseDragged event. When I release mouse button my glassPane disappears. I have another question too. When I will paint on glass pane all my components behind them will be refreshing and repainting? Maybe somebody have nice