jcomponent

Why can't I validate a JComponent?

回眸只為那壹抹淺笑 提交于 2019-12-20 03:23:26
问题 From JavaDoc: public void validate() Validates this container and all of its subcomponents. Validating a container means laying out its subcomponents. That is what I want to do. With an as lightweight component as possible. But when I do this whith a JComponent a call to validate() doesn't make the component "valid". JComponent c = new JComponent() {}; System.out.println(c.isValid()); // false c.validate(); System.out.println(c.isValid()); // false Why can't I make a JComponent valid? 回答1: In

How to wrap text around components in a JTextPane?

妖精的绣舞 提交于 2019-12-19 19:55:18
问题 I don't understand the wrapping behavior in a JTextPane. If I insert a short text, then a JComponent and then again the short text I can see the inserted stuff in one line if the frame is large enough of course. But if the text is much longer so that it takes several lines the component is always placed in a new line. I have recognized that after a component has been inserted into a JTextPane its text gets longer by one character. So if a component is considered by a JTextPane as a character

Manually position JComponent inside JPanel

萝らか妹 提交于 2019-12-19 17:32:50
问题 I want to programmatically move my JLabel to a specific location inside my JPanel. I have tried setLocation(int x, int y) , but it doesn't work. I am trying to not use any layout manager. 回答1: Here is a great tutorial on how to layout your components without using a layout manager. http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html Creating a container without a layout manager involves the following steps. Set the container's layout manager to null by calling setLayout(null) .

Ball Animation in Swing

試著忘記壹切 提交于 2019-12-18 08:49:33
问题 The Problem is when I resize the JFrame the animation goes on with it's Pre supplied dimensions for JComponent . Is there a way that I can update my width and height variables as I resize the JFrame , so that the Animation can run along with the new Co-ordinates. In simpler terms, say the JComponent has initial width = 300 and height = 300 , so the BALL moves inside these specified Co-ordinates . Now if I resize my JFrame , the size for the JComponent still remains as is i.e. width = 300 and

Change Font at runtime

拥有回忆 提交于 2019-12-17 06:16:09
问题 Please is there another way how to change Font at runtime as using FontUIResource, for the whole AWT/Swing GUI, without any knowledge / interest about if there are local variables and type of JComponents import java.awt.*; import java.awt.event.*; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.*; import javax.swing.plaf.FontUIResource; import javax.swing.plaf.basic.BasicComboBoxRenderer; public class SystemFontDisplayer extends

Is MVC in Swing Thread Safe

不羁岁月 提交于 2019-12-17 03:42:08
问题 I'm trying to touch limits of MVC architecture in Swing, but as I tried everything all (from SwingWorker or Runnable#Thread ) are done on EDT my questions: is there some limits or strictly depends by order of the implementations (wrapped into SwingWorker or Runnable#Thread ) ? limited is if is JComponent#method Thread Safe or not ? essential characteristic of an MVC architecture in Swing, ? inc. Container Re-Layout ? note: for my SSCCE I take one of great examples by HFOE , and maybe by

Java JComponent lag on resize

空扰寡人 提交于 2019-12-13 23:36:40
问题 Can anyone give insight as to why a JPanel that is drawing simple shapes such as rectangles, in small quantity, could lag noticeably when resizing the frame? I think that by adding an event for window resize and timing the resize to 1/10 s or so, I could solve the problem. But I'm not so sure. EDIT: After reviewing the example code I found that the resize lag is due to having a handler that scales drawn objects by getting the height and width of the screen. this.addComponentListener(new

create a new installable zip from a ( already installed ) Joomla 1.7 component

陌路散爱 提交于 2019-12-13 20:36:34
问题 I've Joomla 1.7 and lots of component in it. I'd like to make a "reverse-engineering" of the install of a component. I've edited most part of it and i'd like to repack this to install in a new fresh Joomla installation. Any idea? thanks! 回答1: It's fairly straight forward - you download all the related files then zip them up with a new XML manifest. Of course you have to make sure that you get all of the files because they can be located in a couple different places. Luckily, the Joomla

coordinate system of JComponent relative to JPanel

有些话、适合烂在心里 提交于 2019-12-13 18:25:39
问题 println in the paintComponent prints out 497 971. in the view of JPanel, the red line's left-up point is supposed to be somewhere near JPanel's middle according that number pair, but in fact it's not. Is it caused by coordinate system conversion? Thanks in advance. Code shows below: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Calendar; import

Draw trail of circles with mouseDragged

社会主义新天地 提交于 2019-12-13 07:52:02
问题 I am trying to write a program that draws a line of circles with mouseDragged, like MS paint does. I have successfully gotten my program to draw a circle when I click. I have also been successful in getting my program to draw a circle when I drag the mouse; however, this doesn't leave a line of circles behind wherever I dragged. It simply drags the same circle around. I am trying to get my program to leave a trail of circles behind where I am dragging but I am pretty confused on why my