java - getY() returning 0 upon adding a JComponent -
I'm new to swing so that I read through the Java tutorial and the API. I am playing with the subclass of Thank you. Below is my code: * Everything else has been initialized, declared, implemented. While calling this, the value is 0. When I run a GUI, then I have DTTexture objects spread vertically Layout Manager to determine the size / location of a component Is responsible. However, layout manager only applies when you use If you add an element to a visible frame, you must use the modified () method to declare the Layout Manager. Think about it, the layout manager can not do it until all the components have been added to the panel, because it will not know how much the size of each component is, especially in a grid In the case of all the components of the layout, the same size is made of the largest component. So how do you know that until all components have not been added, what is the biggest component? It will not be very efficient to make the layout every time the component is added. JComponent (
DTPicture -supports drag and drop). Actually I'll create a panel with
GridLayout . Then I populate the panel with the
DTPicture object I inherited the I code
getLocation () . When you call it, the value is 0. When I run a GUI, then I see the
DTPicture objects spread vertically, then why is returning
getLocation 0?
Public class Rackbluilder tool extends JPanel {// maplake slot # for JPNL public static point [] slot IDARRE = new point [42]; Public RackBuilderTool () {Super (New Grid Layout (42, 1)); // DTPICTURE [] Rack slotare = new dcPicture [42]; For (int i = 0; i <47; i ++) {// Add (new element label ()); DTPPrint temp = new DTP image (empty); Println (add (floating) .getLocation ()); // DTPCare Component Slot IDARA [i] = Template place (); }}
pack () or
setVisible (true) on one frame.
Comments
Post a Comment