awt

The import java.awt cannot be resolved

白昼怎懂夜的黑 提交于 2019-12-01 07:38:05
问题 I have installed the Eclipse [Version: Photon Release (4.8.0)] and JDK 10 on a MacBookPro with macOS 10.13.5 When I write in my code: import java.awt.*; I get the error: The import java.awt cannot be resolved Is the java.awt included in JDK 10 ? If yes where is and how can I make visible to Eclipse? If no how can I add java.awt? 回答1: Is the java.awt included in JDK 10? Ye, the package does exist. The Java10 API docs do confirm the same as well. If yes where is and how can I make visible to

How do I center a JTextfield

孤人 提交于 2019-12-01 06:29:38
I'm having trouble centering a JTexfield in my program.The Textfield does not appear aligned with the JButton. I've tried using the x.setHoriontalAlignment(JTextfield.CENTER); but to no avail. Any ideas? import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JPanel; import java.awt.Container; import java.awt.GridLayout; import java.awt.GridBagLayout; public class WidgetProject implements

Image transformation results in a red image?

孤者浪人 提交于 2019-12-01 05:51:04
I am trying to transform an image by flipping it horizontally and resizing it. The problem is that when the transformation is done the picture's colors are all weird, it has gotten this reddish tone. Is it possible to fix this somehow, I think I read somewhere that it might be some bug in the AWT library but I am not sure? Here is the code: import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class LocalImageSizeFlip {

Reserving the edge of the screen in Java

只愿长相守 提交于 2019-12-01 05:20:17
How can I make a window (such as a java.awt.Frame , javax.swing.JFrame , java.awt.Dialog , javax.swing.JDialog , etc.) reserve the edge of the screen, like a dock, taskbar, Trillian, or Microsoft OneNote can? I aim to only use standard JDK libraries if possible. This behaviour is very specific to the Windows operating system, and as such there is no way to do this in the standard JDK or with AWT/Swing, since these need to work consistently across a number of different operating systems. The closest equivalent to what you want is to get the current screen's boundaries and move/resize your

How do I center a JTextfield

一世执手 提交于 2019-12-01 05:06:04
问题 I'm having trouble centering a JTexfield in my program.The Textfield does not appear aligned with the JButton. I've tried using the x.setHoriontalAlignment(JTextfield.CENTER); but to no avail. Any ideas? import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JPanel; import java.awt.Container;

JVM(Thread/Stack)

↘锁芯ラ 提交于 2019-12-01 04:52:56
JVM Thread/Stack Memory Size -Xss1024K JVM Thread/Stack Object states (6 states) new new Thread() runnable java.lang.Thread.start() blocked syncronized + java.lang.Object.wait() waiting java.lang.Object.wait() java.lang.Thread.join() java.util.concurrent.locks.LockSupport.park() timed_waiting 时间过后自动恢复 java.lang.Thread.sleep(long time) java.lang.Object.wait(long timeout) java.lang.Thread.join(long millis) java.util.concurrent.locks.LockSupport.packNanos(long nanos) java.util.concurrent.locks.LockSupport.packUntil(long deadline) terminated java.lang.Thread.start()方法结束,在内存中的Thread堆对象状态

Custom Fonts in Java

混江龙づ霸主 提交于 2019-12-01 04:52:53
How to fix problem with custom fonts in Java? For example, my app uses font, that isn't on all computers. Can I somehow include it in compiled executable and then call it from there, if it doesn't exists on clients computer? What are other alternatives? I could make all fonts chars as images (before, in some graphics app) and then display image for each char... is it ok? Here's an utility method I'm using to load a font file from a .ttf file (can be bundled): private static final Font SERIF_FONT = new Font("serif", Font.PLAIN, 24); private static Font getFont(String name) { Font font = null;

Java (native) print dialog - change icon

邮差的信 提交于 2019-12-01 03:47:53
I use PrinterJob.printDialog() to let the user select a printer and change various print settings. However the dialog is always displayed using the standard Java coffeecup icon and not the one from my main window (JFrame). How can I change the icon for that dialog? I'm using the following piece of code: PrinterJob pj = PrinterJob.getPrinterJob(); pj.printDialog(); // how do I change the icon for the dialog that is displayed here ... // process the selection from the dialog Normally a JDialog inherits the icon from the "parent" JFrame, but in this case I cannot pass or specify a parent window

Image transformation results in a red image?

↘锁芯ラ 提交于 2019-12-01 03:39:23
问题 I am trying to transform an image by flipping it horizontally and resizing it. The problem is that when the transformation is done the picture's colors are all weird, it has gotten this reddish tone. Is it possible to fix this somehow, I think I read somewhere that it might be some bug in the AWT library but I am not sure? Here is the code: import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import

Reserving the edge of the screen in Java

寵の児 提交于 2019-12-01 03:18:55
问题 How can I make a window (such as a java.awt.Frame , javax.swing.JFrame , java.awt.Dialog , javax.swing.JDialog , etc.) reserve the edge of the screen, like a dock, taskbar, Trillian, or Microsoft OneNote can? I aim to only use standard JDK libraries if possible. 回答1: This behaviour is very specific to the Windows operating system, and as such there is no way to do this in the standard JDK or with AWT/Swing, since these need to work consistently across a number of different operating systems.