awt

Disabling awt/swing debug (fine) log messages

霸气de小男生 提交于 2019-12-10 02:43:03
问题 I'm using java logging to write log messages of my application to a log file and other destinations. Having set the log level to FINE , I also get (unwanted) messages from AWT/Swing, such as: {0}, when grabbed {1}, contains {2} and others. Looking at the JDK source code (see e.g. here), one sees that the name of the corresponding logger is sun.awt.X11.grab.XWindowPeer . What I understood from the Java logging framework is that this logging handler should inherit its loglevel from its parents

java简单的用户登录界面+mysql

孤街醉人 提交于 2019-12-10 02:11:15
1.概述 一个简单的swing登录界面,使用了简单的JDBC. 如图: 2.UI (1)主界面 主界面使用了3 1网格布局+三个JPanel,中间的JPanel使用了2 2网格布局: import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; import java.util.Enumeration; import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.plaf.FontUIResource; public class UserManagement { private JFrame mainFrame = new JFrame("登录"); private Container

serialVersionUID field warning in eclipse

随声附和 提交于 2019-12-10 02:08:47
问题 I have just started on AWT and made a simple program in it, it works fine but it shows a warning message in eclipse which i don't understand: The serializable class TestGUI does not declare a static final serialVersionUID field of type long I know that the warning message is not related to AWT and there was no need to post my whole code but when i tried to make a SSCCE of the code the warning also disappeared. Since I don't know why this warning is generated i didn't knew which part to retain

Why does swing draw simple component twice?

被刻印的时光 ゝ 提交于 2019-12-09 16:43:07
问题 Here is simple example of drawing an oval. public class SwingPainter extends JFrame{ public SwingPainter() { super("Swing Painter"); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); getContentPane().add(new MySwingComponent()); setSize(200, 200); setVisible(true); } public static void main(String[] args) { new SwingPainter(); } class MySwingComponent extends JComponent { public void paintComponent(Graphics g) { System.out.println("paintComponent"); super.paintComponent(g); g.setColor

Can you increase line thickness when using Java Graphics for an applet? I don't believe that BasicStroke works [duplicate]

倖福魔咒の 提交于 2019-12-09 14:45:52
问题 This question already has answers here : Java2D: Increase the line width (2 answers) Closed 6 years ago . I am having trouble adjusting line thickness. Can I do that in Graphics or do i have to do it in Graphics2D? If so, how do I alter the program to make it run? Thanks! import java.applet.Applet; import java.awt.*; public class myAppletNumberOne extends Applet { public void paint (Graphics page) { //Something here??? } } 回答1: Yes you have to do it in Graphics2D, but that's hardly an issue,

JFileChooser from a command line program and popping up Underneath all windows

穿精又带淫゛_ 提交于 2019-12-09 10:13:50
问题 Ive implemented the jFileChooser in my command line program and it works, just as it should with only one annoying issue. It seems that it opens underneath every window with no alert of any kind. In fact I even missed it a couple of times at first leading me to believe that i had implemented it wrong. I have implemented this as follows: System.out.println("Please select the file"); JFileChooser fc = new JFileChooser(); int retValue = fc.showOpenDialog(new JPanel()); if(retValue ==

Why can't I get KeyEvent.VK_TAB when I use Key Binding for a JPanel

会有一股神秘感。 提交于 2019-12-09 03:43:52
问题 I will print related info if users focus on current window and press a key. However, it works for some keys like 'a' but not for 'tab'. Here is a simple demo: import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import javax.swing.AbstractAction; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.KeyStroke; public class KeyBindingTest { public static void main(String[] args) { KeyBindingTest test =

How to generate multiple circle shapes and animate those shapes going down the frame

邮差的信 提交于 2019-12-09 02:10:31
问题 I am having trouble generating multiple oval shapes when clicking the panel of the frame. What I want is that it will generate many oval shapes and those shapes will move downward. One of the requirement is to use two multi threading. However in my case, the program I created is that, it will only generate one oval shape and the position is randomly changing. Can anyone please help me one this. package ovalrandomcolors; import java.awt.Color; import java.awt.Component; import java.awt

Drawing certain parts of image offset from the corner?

纵饮孤独 提交于 2019-12-09 01:53:17
问题 I'm using a sprite sheet of sorts to load in spaceships. The documentation of Graphics.drawImage() states the arguments are boolean Graphics.drawImage(Image img, int dstx1, int dsty1, int dstx2, int dsty2, int srcx1, int srcy1, int srcx2, int srcy2, ImageObserver observer); However, the documentation says that dstx1 and dsty2 are the coordinates of the top left corner, and when you use dstx2 and dsty2 to specify the area drawn, the dimensions are (dstx2- dstx1) and (dsty2 - dsty1). Unless I'm

JPanels don't completely stretch to occupy the available space

落爺英雄遲暮 提交于 2019-12-08 22:13:05
问题 I have a panel where I place several mini-panels, side-by-side, with different sizes and colors, and they should occupy the entire parent panel (horizontally). For this I use BorderLayout (for the parent panel), and BoxLayout for a sub-panel where I place all the mini-panels (see code below). It does work and behave correctly uppon resizing and everything. However, as the number of mini-panels becomes larger, a strange behaviour occurs: empty space appears at the end of the parent panel. I