awt

How to remove drop shadow of Java AWT Frame on OSX?

末鹿安然 提交于 2019-12-08 05:26:49
问题 Is it possible to disable the drop shadow of a Java AWT application on OS X? I want to create a transparent window, which works fine, but I cannot get rid of the drop shadow. If I was using a JFrame this could be done using: JRootPane root = frame.getRootPane(); root.putClientProperty( "Window.shadow", Boolean.FALSE ); Any similar possibility for an AWT Frame? I' using the Framework Processing and my code there looks like this: void setup(){ frame.removeNotify(); frame.setUndecorated(true); }

Finding keycode of multimedia key in java

我与影子孤独终老i 提交于 2019-12-08 05:22:49
问题 I want to capture key presses on Windows like Fn+Pause, Fn+VolumeUp in my Java Application but I am unable to detect their KeyCodes. addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { System.out.println(e.getKeyCode()); } }); Using this snippet it prints 0 for all the Multimedia Key Presses ! Kindly suggest a suitable method for finding the keyCode and thereby utilizing it in Java Application. 回答1: Use the JIntellitype library. This API is a Java JNI library that

How to disable position change of JSlider on mouse right click

只愿长相守 提交于 2019-12-08 04:42:57
问题 I am using a JSlider in my application. I want only left click to slide JSlider , and I want to disable right click for JSlider . I am able to get event on right click, but slider is changing its value to other position. jSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { //code } }); jSlider.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) { //code } else { //code } }

Java/AWT/Swing: about validation and sizes

三世轮回 提交于 2019-12-08 04:24:00
问题 I'm a bit confused at how to manage the layout of my components in Java (I want to do it manually and not handle it by a layout manager). There are these methods in a Component : layout , doLayout validate , invalidate , revalidate validateTree , invalidateTree setSize , setBounds , setPreferredSize getSize , getBounds , getPreferredSize paint , repaint , update updateUI Earlier, I have tried to overload various combinations of the above but I was not quite sure which one to overload and what

Using Mouse Click to Generate Balls

≡放荡痞女 提交于 2019-12-08 04:13:28
问题 I have below code, I need to alter it so that the balls are generated with a mouse click rather than all of them generating at once. I know I need to use a mouse listener but I do not know how I can integrate that into what I have without "breaking" the app. No changes needed import javax.swing.JFrame; import java.awt.Canvas; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferStrategy;

must all methods in AWT classes, i.e. non-Swing ones, be called in the EDT?

♀尐吖头ヾ 提交于 2019-12-08 03:56:37
问题 I recently learnt that Sun's/Oracle's most recent guidelines say that no Swing methods of any Swing objects, including constructors, must be called outside the EDT. Does the same standard of rigour apply to all "visual" AWT classes too? If not, what ** are ** the rules for them? later re Swing and EDT: discussion from 2009. http://www.velocityreviews.com/forums/t707173-why-does-jdk-1-6-recommend-creating-swing-components-on-the-edt.html quote: "Besides actual thread safety and associated

Drawing a selection box using Swing

只愿长相守 提交于 2019-12-08 03:54:49
问题 I have written an application with a panel and three buttons. I want to add selection this buttons using the mouse. I mean like we have in Windows on the Desktop. I press the left mouse button and with the movement of the mouse the area selection is growing. Is there a specific interface in this or do I have it manually call the appropriate methods for event listeners and there draw transparent rectangle? Here is a picture: So I have a problem when I paint rectangle using event mouse-dragged,

Why doesn't Graphics2D.setStoke() work for Graphics2D.drawString?

折月煮酒 提交于 2019-12-08 03:28:08
问题 I want the string to have different width so that I set the stroke of Graphics2D and the code is here: import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; public class StrokeTest { public static void main(String[] args) { StrokeTest test = new StrokeTest(); test.createUI(); } public void createUI(){ JFrame frame = new JFrame(); frame.add(new MainPanel());

Copy Image to Clipboard not working on Linux (Java AWT & SWT)

天涯浪子 提交于 2019-12-08 02:51:38
问题 I am developing an Eclipse RCP Application which includes JFreeChart. One of its features is to copy graphs to the clipboard in order to paste them into other applications but it does not work on Linux, There is a SWT sample where you can find a snippet that does not work in Linux. On the other hand JFreeChart implemented this on AWT as: Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Insets insets = getInsets(); int w = getWidth() - insets.left - insets.right;

Printing headers and footers in color?

廉价感情. 提交于 2019-12-08 02:48:02
问题 I am trying to create colored headers and footers when printing a JTable. Specifically, I am looking at getPrintable() in javax.swing.JTable, but MessageFormat does not give me the option to specify the color of the header or footer. How can I do it? clarification I am interested in setting the header/footers while printing. For example, notepad appends the filename as a header to what you print. update Seems like there is no standard way of doing this, can someone give me some workarounds?