Search Results

Search found 26 results on 2 pages for 'layoutmanager'.

Page 1/2 | 1 2  | Next Page >

  • How to use RelativeLayout to make a custom component on Android

    - by Styggentorsken
    I'm trying to make a custom component based on buttons without having to deal with all the layout myself. The problem is that i can't find a way to make use of RelativeLayout to draw the thing. This is my latest attempt. A bitmap is returned by layoutManager.getDrawingCache(), but it does not show any buttons. canvas.drawColor(...) however works. public class MyView extends View { Button myButton; RelativeLayout layoutManager; public MyView(Context context) { super(context); initMyView(); } public MyView(Context context, AttributeSet attrs) { super(context); initMyView(); // ... } public void initMyView() { layoutManager = new RelativeLayout(getContext()); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension( MeasureSpec.getSize(measureSpec), MeasureSpec.getSize(measureSpec) ); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); myButton = new Button(layoutManager.getContext()); myButton.setVisibility(VISIBLE); myButton.setDrawingCacheEnabled(true); layoutManager.addView(myButton); layoutManager.setDrawingCacheEnabled(true); layoutManager.layout(0, 0, 150, 150); layoutManager.setVisibility(VISIBLE); layoutManager.buildDrawingCache(); layoutManager.draw(canvas); canvas.drawBitmap(layoutManager.getDrawingCache(), 0.0f, 0.0f, null); } }

    Read the article

  • SWT Layout for absolute positioning with minimal-spanning composites

    - by pure.equal
    Hi, I'm writing a DND-editor where I can position elemtents (like buttons, images ...) freely via absolute positioning. Every element has a parent composite. These composites should span/grasp/embrace every element they contain. There can be two or more elements in the same composite and a composite can contain another composite. This image shows how it should look like. To achive this I wrote a custom layoutmanager: import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Layout; public class SpanLayout extends Layout { Point[] sizes; int calcedHeight, calcedWidth, calcedX, calcedY; Point[] positions; /* * (non-Javadoc) * * @see * org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite * , int, int, boolean) * * A composite calls computeSize() on its associated layout to determine the * minimum size it should occupy, while still holding all its child controls * at their minimum sizes. */ @Override protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { int width = wHint, height = hHint; if (wHint == SWT.DEFAULT) width = composite.getBounds().width; if (hHint == SWT.DEFAULT) height = composite.getBounds().height; return new Point(width, height); } /* * (non-Javadoc) * * @see * org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, * boolean) * * Calculates the positions and sizes for the children of the passed * Composite, then places them accordingly by calling setBounds() on each * one. */ @Override protected void layout(Composite composite, boolean flushCache) { Control children[] = composite.getChildren(); for (int i = 0; i < children.length; i++) { calcedX = calcX(children[i]); calcedY = calcY(children[i]); calcedHeight = calcHeight(children[i]) - calcedY; calcedWidth = calcWidth(children[i]) - calcedX; if (composite instanceof Composite) { calcedX = calcedX - composite.getLocation().x; calcedY = calcedY - composite.getLocation().y; } children[i].setBounds(calcedX, calcedY, calcedWidth, calcedHeight); } } private int calcHeight(Control control) { int maximum = 0; if (control instanceof Composite) { if (((Composite) control).getChildren().length > 0) { for (Control child : ((Composite) control).getChildren()) { int calculatedHeight = calcHeight(child); if (calculatedHeight > maximum) { maximum = calculatedHeight; } } return maximum; } } return control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y + control.getLocation().y; } private int calcWidth(Control control) { int maximum = 0; if (control instanceof Composite) { if (((Composite) control).getChildren().length > 0) { for (Control child : ((Composite) control).getChildren()) { int calculatedWidth = calcWidth(child); if (calculatedWidth > maximum) { maximum = calculatedWidth; } } return maximum; } } return control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x + control.getLocation().x; } private int calcX(Control control) { int minimum = Integer.MAX_VALUE; if (control instanceof Composite) { if (((Composite) control).getChildren().length > 0) { for (Control child : ((Composite) control).getChildren()) { int calculatedX = calcX(child); if (calculatedX < minimum) { minimum = calculatedX; } } return minimum; } } return control.getLocation().x; } private int calcY(Control control) { int minimum = Integer.MAX_VALUE; if (control instanceof Composite) { if (((Composite) control).getChildren().length > 0) { for (Control child : ((Composite) control).getChildren()) { int calculatedY = calcY(child); if (calculatedY < minimum) { minimum = calculatedY; } } return minimum; } } return control.getLocation().y; } } The problem with it is that it always positions the composite at the position (0,0). This is because it tries to change the absolute positioning into a relative one. Lets say I position a image at position (100,100) and one at (200,200). Then it has to calculate the location of the composite to be at (100,100) and spanning the one at (200,200). But as all child positions are relative to their parents I have to change the positions of the children to remove the 100px offset of the parent. When the layout gets updated it moves everything to the top-left corner (as seen in the image) because the position of the image is not (100,100) but (0,0) since I tried to remove the 100px offset of the partent. Where is my error in reasoning? Is this maybe a totally wrong approach? Is there maybe an other way to achive the desired behavior? Thanks in advance! Best regards, Ed

    Read the article

  • How can I control the width of JTextFields in Java Swing?

    - by Jonas
    I am trying to have several JTextFields on a single row, but I don't want them to have the same width. How can I control the width and make some of them wider than others? I want that they together take up 100% of the total width, so it would be good if I could use some kind of weigthing. I have tried with .setColumns() but it doesn't make sense. Here is my code: class Row extends JComponent { public Row() { this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); JTextField fld1 = new JTextField("First field"); JTextField fld2 = new JTextField("Second field, should be longer"); JTextField fld3 = new JTextField("Short field"); JTextField fld4 = new JTextField("Another field"); fld1.setBorder(null); fld2.setBorder(null); fld3.setBorder(null); fld4.setBorder(null); fld1.setFocusable(false); fld2.setFocusable(false); fld3.setFocusable(false); fld4.setFocusable(false); fld1.setColumns(5); // makes no sense this.add(fld1); this.add(fld2); this.add(fld3); this.add(fld4); } } this.setLayout(new GridLayout(20,0)); this.add(new Row()); this.add(new Row()); this.add(new Row());

    Read the article

  • Best Practice Guide: Swing

    - by wishi_
    Hi! Does anybody know Swing related GUI guidelines - specifically on how to design Swing apps and which components I should use? I'm not looking for an official standard, but pragmatic tips I can use to set a good standard for my projects. I haven't used too much of Swing by myself. Surely clicking a GUI with a GUI designer isn't a big deal. However I'd like to get some insights from people who have experience with Swing and know what to avoid. Swing lately (in Java 6- 10) got decent changes. So there isn't too much specific standardization out there currently.

    Read the article

  • How can I "pack()" a printable Java Swing component?

    - by Jonas
    I have implemented a Java Swing component that implements Printable. If I add the component to a JFrame, and do this.pack(); on the JFrame, it prints perfect. But if I don't add the component to a JFrame, just a blank page is printed. This code gives a great printout: final PrintablePanel p = new PrintablePanel(pageFormat); new JFrame() {{ getContentPane().add(p); this.pack(); }}; job.setPrintable(p, pageFormat); try { job.print(); } catch (PrinterException ex) { System.out.println("Fail"); } But this code gives a blank page: final PrintablePanel p = new PrintablePanel(pageFormat); // new JFrame() {{ getContentPane().add(p); this.pack(); }}; job.setPrintable(p, pageFormat); try { job.print(); } catch (PrinterException ex) { System.out.println("Fail"); } I think that this.pack(); is the big difference. How can I do pack() on my printable component so it prints fine, without adding it to a JFrame? The panel is using several LayoutManagers. I have tried with p.validate(); and p.revalidate(); but it's not working. Any suggestions? Or do I have to add it to a hidden JFrame before I print the component?

    Read the article

  • How do I keep JTextFields in a Java Swing BoxLayout from expanding?

    - by Matthew
    I have a JPanel that looks something like this: JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); ... panel.add (jTextField1); panel.add (Box.createVerticalStrut(10)); panel.add (jButton1); panel.add (Box.createVerticalStrut(30)); panel.add (jTextField2); panel.add (Box.createVerticalStrut(10)); panel.add (jButton2); ... //etc. My problem is that the JTextFields become huge vertically. I want them to only be high enough for a single line, since that is all that the user can type in them. The buttons are fine (they don't expand vertically). Is there any way to keep the JTextFields from expanding? I'm pretty new to Swing, so let me know if I'm doing everything horribly wrong.

    Read the article

  • Flex 3 Value aware combo box error

    - by user1057094
    I am using a value aware combobox, it was working fine, but recently i started getting the below error, when I try to click on combobox, and the error is random. I am not sure of it is because of any changes i have done in the coding, or some changes in data provider etc any help is appreciated... TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.controls::ComboBox/destroyDropdown() at mx.controls::ComboBox/styleChanged() at mx.core::UIComponent/setBorderColorForErrorString() at mx.core::UIComponent/commitProperties() at mx.controls::ComboBase/commitProperties() at mx.controls::ComboBox/commitProperties() at custom.controls::ComboBox/commitProperties()[D:\workspace\eclipse\indigo\ams\flex_src\custom\controls\ComboBox.mxml:13] at mx.core::UIComponent/validateProperties() at mx.managers::LayoutManager/validateProperties() at mx.managers::LayoutManager/doPhasedInstantiation() Debugger throws TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.controls::ComboBox/destroyDropdown() at mx.controls::ComboBox/styleChanged() at mx.core::UIComponent/setBorderColorForErrorString() at mx.core::UIComponent/commitProperties() at mx.controls::ComboBase/commitProperties() at mx.controls::ComboBox/commitProperties() at custom.controls::ComboBox/commitProperties()[D:\workspace\eclipse\indigo\ams\flex_src\custom\controls\ComboBox.mxml:13] at mx.core::UIComponent/validateProperties() at mx.managers::LayoutManager/validateProperties() at mx.managers::LayoutManager/doPhasedInstantiation() at mx.managers::LayoutManager/validateNow() at mx.controls::ComboBox/displayDropdown() at mx.controls::ComboBox/downArrowButton_buttonDownHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.controls::Button/http://www.adobe.com/2006/flex/mx/internal::buttonPressed() at mx.controls::Button/mouseDownHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.controls::ComboBase/textInput_mouseEventHandler()

    Read the article

  • Actionscript project that loads a Flex SWF, "Could not find resource bundle" Error when using Layout

    - by Leeron
    Hi guys. I'm using an actionsciprt only project (under FlashDevelop) to load an .swf flex file built by another department of the company I work for. Using the follwing code: var mLoader:Loader = new Loader(); var mRequest:URLRequest = new URLRequest('flexSWF.swf'); mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); mLoader.load(mRequest); That worked fine until I wanted to use Flex's mx.managers.LayoutManager. I've added the this line to my class: import mx.managers.ILayoutManagerClient; import mx.managers.LayoutManager; . . . private var _layoutManager:LayoutManager; And I get this run time error: Error: Could not find resource bundle messaging at mx.resources::ResourceBundle$/getResourceBundle()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\resources\ResourceBundle.as:143] at mx.utils::Translator$cinit() at global$init() at mx.messaging.config::ServerConfig$cinit() at global$init() at _app_FlexInit$/init() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:3217] at mx.managers::SystemManager/docFrameListener()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:3069] commenting the LayoutManager line, the swf works fine. But I do want to use LayoutManager. Any hints?

    Read the article

  • How to paint background of specific range of text in NSTextView

    - by Rui Pacheco
    Hi, This is not a specific bug, its more about not knowing how to do something. I've an NSTextView and I need to paint the background of specific ranges of text when the user clicks on a specific part of the text view. I've tried this but I just get erratic behaviour in the sense that sometimes text loses the foreground color or the background doesn't span the whole range: NSLayoutManager *layoutManager = [myTextView layoutManager]; [layoutManager removeTemporaryAttribute:NSBackgroundColorAttributeName forCharacterRange:range]; [[myTextView layoutManager] setTemporaryAttributes:attributes forCharacterRange:range]; For the sake of simplicity assume that range is always a valid string (it is in my testing environment).

    Read the article

  • Draw text with in a rect with given width

    - by Forchita
    I'm trying to draw text on NSView subclass. I'm using an NSTextStorage, an NSLayoutManager, and an NSTextContainer. I followed Apple's doc and here's the method I use to calculate the necessary height for each text: NSSize newSize= NSMakeSize(width, 0.0); NSLayoutManager* layoutManager= [[textStorage layoutManagers] objectAtIndex:0]; NSTextContainer* textContainer= [[layoutManager textContainers] objectAtIndex:0]; [textContainer setContainerSize:newSize]; [textStorage addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, [textStorage length])]; [textContainer setLineFragmentPadding:0.0]; [layoutManager glyphRangeForTextContainer:textContainer]; return [layoutManager usedRectForTextContainer:textContainer].size.height; The only problem is that I don't know how to draw in an NSRect with the layout manager. Can you help me please? Thanks in advance!

    Read the article

  • Problem to display 3D google map.

    - by nemade-vipin
    hello friends, I have implemented one Flex application in which I want to display 3D google map.In which I am getting the error the NUll object reference during map display. Here is my code:- import com.google.maps.controls.MapTypeControl; import adobe.utils.XMLUI; import mx.rpc.events.FaultEvent; import mx.controls.Alert; import generated.webservices.*; import mx.collections.ArrayCollection; import mx.controls.*; import generated.webservices.*; import com.google.maps.LatLng; import com.google.maps.Map3D; import com.google.maps.MapEvent; import com.google.maps.MapMouseEvent; import com.google.maps.services.GeocodingEvent; import com.google.maps.services.ClientGeocoder; import com.google.maps.overlays.Marker; import com.google.maps.InfoWindowOptions; import com.google.maps.MapOptions; import com.google.maps.MapType; import com.google.maps.View; import com.google.maps.controls.NavigationControl; import com.google.maps.geom.Attitude; import mx.controls.Alert; [Bindable] private var childName:ArrayCollection; [Bindable] private var childId:ArrayCollection; private var photoFeed:ArrayCollection; private var trackinginfochild:TrackingInfo; private var arrayOfchild:Array; private var newEntry:GetSBTSMobileAuthentication; private var trackinginfo:GetSBTSTrackingInfo; private var childObj:Child; private var UserId:int; private var lat:int; private var long:int; private var latlong:LatLng; public var user:SBTSWebService; public function authentication():void { // Instantiate a new Entry object. user = new SBTSWebService(); if(user!=null) { user.addSBTSWebServiceFaultEventListener(handleFaults); user.addgetSBTSMobileAuthenticationEventListener(authenticationResult); newEntry = new GetSBTSMobileAuthentication(); if(newEntry!=null) { newEntry.mobile=mobileno.text; newEntry.password=password.text; user.getSBTSMobileAuthentication(newEntry); } } } public function handleFaults(event:FaultEvent):void { Alert.show("A fault occured contacting the server. Fault message is: " + event.fault.faultString); } public function authenticationResult(event:GetSBTSMobileAuthenticationResultEvent):void { if(event.result != null && event.result._return>0) { if(event.result._return > 0) { UserId = event.result._return; loginform.enabled = false; getChildList(UserId); viewstack2.selectedIndex=1; } else { Alert.show("Authentication fail"); } } } public function getChildList(userId:int):void { var childEntry:GetSBTSMobileChildrenInfo = new GetSBTSMobileChildrenInfo(); childEntry.UserId = userId; user.addgetSBTSMobileChildrenInfoEventListener(sbtsChildrenInfoResult); user.getSBTSMobileChildrenInfo(childEntry); } public function sbtsChildrenInfoResult(event:GetSBTSMobileChildrenInfoResultEvent):void { if( event.result._return!=null) { arrayOfchild = event.result._return as Array; photoFeed = new ArrayCollection(arrayOfchild); childName = new ArrayCollection(); for( var count:int=0;count<photoFeed.length;count++) { childObj = photoFeed.getItemAt(count,0) as Child; childName.addItem(childObj.strName); } } } private function trackingInfo():void { for( var count:int=0;count user.getSBTSTrackingInfo(trackinginfo); } } } } private function getTrackingInfo(event:GetSBTSTrackingInfoResultEvent):void { if(event.result._return != null) { trackinginfochild = event.result._return as TrackingInfo; lat = trackinginfochild.dblLatitude; long = trackinginfochild.dblLongitude; latlong = new LatLng(lat,long); } } private function onMapPreinitialize(event:MapEvent):void { var myMapOptions:MapOptions = new MapOptions(); myMapOptions.zoom = 12; myMapOptions.center = latlong; myMapOptions.mapType = MapType.NORMAL_MAP_TYPE; myMapOptions.viewMode = View.VIEWMODE_PERSPECTIVE; myMapOptions.attitude = new Attitude(20,30,0); buslocation.setInitOptions(myMapOptions); buspath.setInitOptions(myMapOptions); } private function onMapReady(event:MapEvent):void { this.buslocation.addControl(new NavigationControl()); this.buslocation.addControl( new MapTypeControl()); } ]]> <mx:Move id="hideEffect" yTo="-500" /> <mx:Move id="showEffect" xFrom="500"/> <mx:Panel width="100%" height="100%" headerColors="[#000000,#FFFFFF]" hideEffect="{hideEffect}" showEffect="{showEffect}"> <mx:TabNavigator id="viewstack2" selectedIndex="0" creationPolicy="all" width="100%" height="100%"> <mx:Form label="Login Form" id="loginform" hideEffect="{hideEffect}" showEffect="{showEffect}"> <mx:FormItem label="Mobile NO:" creationPolicy="all"> <mx:TextInput id="mobileno"/> </mx:FormItem> <mx:FormItem label="Password:" creationPolicy="all"> <mx:TextInput displayAsPassword="true" id="password" /> </mx:FormItem> <mx:FormItem> <mx:Button label="Login" click="authentication()"/> </mx:FormItem> </mx:Form> <mx:Form label="Child List" id="childForm" hideEffect="{hideEffect}" showEffect="{showEffect}"> <mx:Label width="100%" color="blue" text="Select Child."/> <mx:RadioButtonGroup id="radioGroup" itemClick="trackingInfo()"/> <mx:Repeater id="fieldRepeater" dataProvider="{childName}"> <mx:RadioButton groupName="radioGroup" label="{fieldRepeater.currentItem}" value="{fieldRepeater.currentItem}"/> </mx:Repeater> </mx:Form> <mx:Form label="Child Information" hideEffect="{hideEffect}" showEffect="{showEffect}"> <mx:FormItem> <mx:DataGrid id="childinfo"> <mx:columns> <mx:DataGridColumn headerText="Child Name" dataField="strName"/> <mx:DataGridColumn headerText="School Name" dataField="strSchoolName"/> <mx:DataGridColumn headerText="Pick Up Point" dataField="strPickUpPointName"/> <mx:DataGridColumn headerText="Drop Down Point" dataField="strDropDownPointName"/> </mx:columns> </mx:DataGrid> </mx:FormItem> <mx:FormItem> <mx:Button label="click here to see bus location"/> </mx:FormItem> </mx:Form> <mx:Form label="Bus Location" hideEffect="{hideEffect}" showEffect="{showEffect}"> <maps:Map3D xmlns:maps="com.google.maps.*" mapevent_mappreinitialize="onMapPreinitialize(event)" id="buslocation" width="100%" height="100%" url="http://code.google.com/apis/maps/" key="ABQIAAAAXuX6aG-r_N0-tQNxUEV-vRSE8al1BQssMxLXJiP75kIjR3ssLxT3D52_u94hI-dMIkD72FmnK-P4og"/> </mx:Form> <mx:Form label="Bus path" hideEffect="{hideEffect}" showEffect="{showEffect}"> <maps:Map3D xmlns:maps="com.google.maps.*" mapevent_mappreinitialize="onMapPreinitialize(event)" id="buspath" width="100%" height="100%" url="http://code.google.com/apis/maps/" key="ABQIAAAAXuX6aG-r_N0-tQNxUEV-vRSE8al1BQssMxLXJiP75kIjR3ssLxT3D52_u94hI-dMIkD72FmnK-P4og"/> </mx:Form> </mx:TabNavigator> </mx:Panel> I am getting this error :- TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.google.maps.geom::Geometry$/computeSeparatingAxes() at com.google.maps.geom::TileEnumerator/enumerateTiles() at com.google.maps.core::PerspectiveTilePane/computeOptimalSet() at com.google.maps.core::PerspectiveTilePane/render() at com.google.maps.core::PerspectiveTilePane/configure() at com.google.maps.managers::PerspectiveTileManager/updateView() at com.google.maps.managers::PerspectiveTileManager/initializePanes() at com.google.maps.managers::PerspectiveTileManager/onInitialize() at MethodInfo-190() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298] at com.google.maps.wrappers::BaseEventDispatcher/dispatchEvent() at com.google.maps.wrappers::EventDispatcherWrapper/dispatchEvent() at com.google.maps.core::MapImpl/size() at com.google.maps.core::MapImpl/setSize() at com.google.maps.wrappers::IMapWrapper/setSize() at com.google.maps::Map/internalSetSize() at com.google.maps::Map/onUIComponentResized() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298] at mx.core::UIComponent/dispatchResizeEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:7077] at mx.core::UIComponent/setActualSize()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6706] at mx.containers.utilityClasses::BoxLayout/updateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\containers\utilityClasses\BoxLayout.as:219] at mx.containers::Form/updateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\containers\Form.as:375] at mx.core::UIComponent/validateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6351] at mx.core::Container/validateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2677] at mx.managers::LayoutManager/validateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:622] at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:695] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628] at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568] Please resolve my issue.

    Read the article

  • Flex 3 : UIComponent.addChild issue

    - by Frank
    Hello SOers, I've run into a nice problem with the UIComponent.addChild(...) function. First of all, I'm using ESRI Api for Flex. In this API you find a class called Graphic that inherits UIComponent. Basically, I'm trying to add, as a child, a Graphic 'g' to another graphic 'parent'. So that when you delete the 'parent' graphic the 'g' graphic deletes as well. private function writeMeasurements(parent:Graphic):void { var g:Graphic; if(parent.geometry.extent != null) g = new Graphic(parent.geometry.extent.center); else g = new Graphic(parent.geometry); g.initialize(); g.name = UIDUtil.createUID(); g.symbol = txtSym; graphicsLayer.add(g); parent.addChild(g); } graphicsLayer class This code actually runs pretty fine. The problem is after... it's like if the addChild function was asynchronious. This is the error I get : TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul. at com.esri.ags::Graphic/updateDisplayList()[C:\checkout\flex_api\api\src\com\esri\ags\Graphic.as:346] at mx.core::UIComponent/validateDisplayList() at mx.managers::LayoutManager/validateDisplayList() at mx.managers::LayoutManager/doPhasedInstantiation() at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2() at mx.core::UIComponent/callLaterDispatcher() I know this is a very specific question, but I think you guys are the BEST! Thanks.

    Read the article

  • Background image in a JFrame.

    - by thepandaatemyface
    Hi, This question has been asked a lot but everywhere the answers fall short. I can get a JFrame to display a background image just fine by extending JPanel and overriding paintComponent, like so: class BackgroundPanel extends JPanel { private ImageIcon imageIcon; public BackgroundPanel() { this.imageIcon = Icons.getIcon("foo"); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(imageIcon.getImage(), 0,0,imageIcon.getIconWidth(),imageIcon.getIconHeight(),this); } } But now, how do you add a component on top of that background? When I go JFrame w = new JFrame() ; Container cp = w.getContentPane(); cp.setLayout(null); BackgroundPanel bg = new BackgroundPanel(); cp.add(bg); JPanel b = new JPanel(); b.setSize(new Dimension(30, 40)); b.setBackground(Color.red); cp.add(b); w.pack() w.setVisible(true) It shows the little red square (or any other component) and not the background, but when I remove cp.setLayout(null);, the background shows up but not my other component. I'm guessing this has something to do with the paintComponent not being called by the null LayoutManager, but I'm not at all familiar with how LayoutManagers work (this is a project for college and the assignment specifically says not to use a LayoutManager) When i make the image the background has to display null (and so, transparant (??)) the red square shows up so it might be that the background is actually above my other components) Does anyone anyone have any ideas? Thanks

    Read the article

  • loaderInfo null inside creationComplete handler function

    - by Thiago
    Hi, I've coded this small snippet to show what I'm not understanding: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> public function init():void { txtName.text = this.loaderInfo.toString(); } </mx:Script> <mx:TextInput x="50" y="10" id="txtName"/> </mx:Application> I'm getting the following error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Teste/init()[C:\Lucas\flex\AppName\src\Teste.mxml:5] at Teste/___Teste_Application1_creationComplete()[C:\User\flex\CornetaRecorder\src\Teste.mxml:2] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298] at mx.core::UIComponent/set initialized()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1169] at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628] at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568] Shouldn't I be able to read loaderInfo inside the creationComplete handler? I'm trying to pass a string from the html to my flash component, that's why I have to get loaderInfo working.

    Read the article

  • Flex NetConnection error: Property onDirtyList not found on flash.net.NetConnection

    - by David Wolever
    I'm having some trouble with NetConnection. The following code makes a connection without issue… var n:NetConnection = new NetConnection(); n.objectEncoding = ObjectEncoding.AMF0; n.addEventListener(NetStatusEvent.NET_STATUS, function(...args):void { trace("HERE"); }); n.connect("rtmp://...host...", ...args); But as soon as the NET_STATUS event handler finishes (ie, hitting "step into" with the debugger), I get this error: ReferenceError: Error #1069: Property onDirtyList not found on flash.net.NetConnection and there is no default value. Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onDirtyList. error=ReferenceError: Error #1069: Property onDirtyList not found on flash.net.NetConnection and there is no default value. at Test/___Test_Application1_creationComplete()[/Users/wolever/Workspace/Test/src/Test.mxml:13] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9440] at mx.core::UIComponent/set initialized()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1168] at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8744] at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8684] Which is kind of scary because onDirtyList only yields two hits on Google. So... Any suggestions?

    Read the article

  • Best approach for a flexible layout for ASP.NET application

    - by Rohith Nair
    I am looking for a best approach for designing a dynamic page. I want my users to be able to determine the position of set of controls to be loaded into a page. Should be able to add new controls or swap in and out new controls into an existing page. Eg: Portal based applications,iGoogle kind of websites I am afraid that I will be re-inventing the wheel if I go and create a portal structure for my web application. There are a couple of things in my mind to look into: Good third-party suites which can do the same Should I look into Silverlight RIA application? I have researched about the Infragistics and Telerik controls and the price is high for just a control like LayoutManager which I need. Any alternatives? What is the best approach for this kind of situation, to add to the list?

    Read the article

  • NSLinguisticTagger on the contents of an NSTextStorage- crashing bug

    - by Remy Porter
    I'm trying to use an NSLinguisticTagger to monitor the contents of an NSTextStorage and provide some contextual information based on what the user types. To that end, I have an OverlayManager object, which wires up this relationship: -(void) setView:(NSTextView*) view { _view = view; _layout = view.layoutManager; _storage = view.layoutManager.textStorage; //get the TextStorage from the view [_tagger setString:_storage.string]; //pull the string out, this grabs the mutable version [self registerForNotificationsOn:self->_storage]; //subscribe to the willProcessEditing notification } When an edit occurs, I make sure to trap it and notify the tagger (and yes, I know I'm being annoyingly inconsistent with member access, I'm rusty on Obj-C, I'll fix it later): - (void) textStorageWillProcessEditing:(NSNotification*) notification{ if ([self->_storage editedMask] & NSTextStorageEditedCharacters) { NSRange editedRange = [self->_storage editedRange]; NSUInteger delta = [self->_storage changeInLength]; [_tagger stringEditedInRange:editedRange changeInLength:delta]; //should notify the tagger of the changes [self highlightEdits:self]; } } The highlightEdits message delegates the job out to a pool of "Overlay" objects. Each contains a block of code similar to this: [tagger enumerateTagsInRange:range scheme:NSLinguisticTagSchemeLexicalClass options:0 usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) { if (tag == PartOfSpeech) { [self applyHighlightToRange:tokenRange onStorage:storage]; } }]; And that's where the problem is- the enumerateTagsInRange method crashes out with a message: 2014-06-04 10:07:19.692 WritersEditor[40191:303] NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds This problem doesn't occur if I don't link to the mutable copy of the underlying string and instead do a [[_storage string] copy], but obviously I don't want to copy the entire backing store every time I want to do tagging. This all should be happening in the main run loop, so I don't think this is a threading issue. The NSRange I'm enumerating tags on exists both in the NSTextStorage and in the NSLinguisticTagger's view of the string. It's not even the fact that the applyHighlightToRange call adds attributes to the string, because it crashes before even reaching that line. I attempted to build a test case around the problem, but can't replicate it in those situations: - (void) testEdit { NSAttributedString* str = [[NSMutableAttributedString alloc] initWithString:@"Quickly, this is a test."]; text = [[NSTextStorage alloc] initWithAttributedString:str]; NSArray* schemes = [NSLinguisticTagger availableTagSchemesForLanguage:@"en"]; tagger = [[NSLinguisticTagger alloc] initWithTagSchemes:schemes options:0]; [tagger setString:[text string]]; [text beginEditing]; [[text mutableString] appendString:@"T"]; NSRange edited = [text editedRange]; NSUInteger length = [text changeInLength]; [text endEditing]; [tagger stringEditedInRange:edited changeInLength:length]; [tagger enumerateTagsInRange:edited scheme:NSLinguisticTagSchemeLexicalClass options:0 usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) { //doesn't matter, this should crash }]; } That code doesn't crash.

    Read the article

  • swing layout: vertical flow

    - by pstanton
    Hi All, What LayoutManager should I use to achieve a transposed version of FlowLayout? Essentially, I want a vertical list which occupies multiple columns if it can't fit all of it's components within one column. +------------------------+ | item 1 | | item 2 | | item 3 | | item 4 | | item 5 | | item 6 | | item 7 | | item 8 | +------------------------+ or +------------------------+ | item 1 item 7 | | item 2 item 8 | | item 3 | | item 4 | | item 5 | | item 6 | +------------------------+

    Read the article

  • Why does adding a Flex DateChooser component throw an index out of bounds error?

    - by Lo'
    I'm facing an issue with the flex Application I'm currently working on. When I open a pop-up using the 'createPopUp' method, I've got this index out of bounds error message : RangeError: The supplied index is out of bounds. at mx.core::FTETextField/getLineMetrics()[E:\dev\4.y\frameworks\projects\spark\src\mx\core\FTETextField.as:2169] at mx.core::UIFTETextField/get baselinePosition()[E:\dev\4.y\frameworks\projects\spark\src\mx\core\UIFTETextField.as:784] at mx.controls::DateChooser/get baselinePosition()[E:\dev\4.y\frameworks\projects\mx\src\mx\controls\DateChooser.as:994] at spark.components::Group/get baselinePosition()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:282] at spark.layouts::ConstraintLayout/parseElementConstraints()[E:\dev\4.y\frameworks\projects\spark\src\spark\layouts\ConstraintLayout.as:1818] at spark.layouts::ConstraintLayout/parseConstraints()[E:\dev\4.y\frameworks\projects\spark\src\spark\layouts\ConstraintLayout.as:1632] at spark.layouts::ConstraintLayout/measure()[E:\dev\4.y\frameworks\projects\spark\src\spark\layouts\ConstraintLayout.as:414] at spark.components.supportClasses::GroupBase/measure()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\supportClasses\GroupBase.as:1148] at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::measureSizes()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:8506] at mx.core::UIComponent/validateSize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:8430] at spark.components::Group/validateSize()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1012] at mx.managers::LayoutManager/validateClient()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:987] at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:382] at mx.managers::PopUpManagerImpl/createPopUp()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:232] at mx.managers::PopUpManager$/createPopUp()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\PopUpManager.as:139] at views::AddProjects/loadAddProjectPopUp()[C:\Users\Laura\Web\spidermak\spidermak\src\views\AddProjects.mxml:184] at views::AddProjects/___AddProjects_Button1_click()[C:\Users\Laura\Web\spidermak\spidermak\src\views\AddProjects.mxml:838] It seems that this error is caused by a "dateChooser" component in my popup : <mx:DateChooser id="endDate"/> When I comment this line, the error is no longer thrown and the popup loads correctly. It's really weird because I didn't have this issue until this morning. All I did in the meantime was changing some layout-related stuff, but I don't see what is would have to do with this problem. I don't get it... Does anyone have a clue about how to fix this ? I need my DateChooser ! Thanks ! Laura EDIT - It seems that the problem is not caused by the DateChooser itself, but by the FormItem around it. Here's what my code looks like : <Form width="100%"> [...] <s:HGroup width="100%"> <s:FormItem label="Date de début"> <mx:DateChooser id="startDate" firstDayOfWeek="1"/> </s:FormItem> <s:FormItem label="Date de fin"> <mx:DateChooser id="endDate" firstDayOfWeek="1"/> </s:FormItem> </s:HGroup> </Form> If I remove the two FormItems, it works. Could anyone explain me why? Thanks !

    Read the article

  • WPF Theming and dynamic controls

    - by Eduard
    Hello, I am trying to add control to ContentPresenter on then run, but control I've added does not apply theme. Theres is code with reference to theme in xaml file: <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources/PocGraphDataTemplates.xaml" /> </ResourceDictionary.MergedDictionaries> Also I've tried to set style in code behind, does not work: this.graphLayout.Content = analyzerViewModel.AnalyzedLayout = new PocGraphLayout() { LayoutAlgorithmType = "FR" }; ResourceDictionary rd = new ResourceDictionary(); rd.Source = new Uri("Resources/PocGraphDataTemplates.xaml", UriKind.Relative); analyzerViewModel.AnalyzedLayout.Style = new Style(typeof(PocGraphLayout)); analyzerViewModel.AnalyzedLayout.Style.Resources.MergedDictionaries.Add(rd); When control was static everything worked fine: <ViewModel:PocGraphLayout x:Name="graphLayout" Graph="{Binding Path=Graph}" LayoutAlgorithmType="{Binding Path=LayoutAlgorithmType}" Sample:LayoutManager.ManagedLayout="True" OverlapRemovalAlgorithmType="FSA" HighlightAlgorithmType="Simple" /> Any ideas? PS. I am newbie in wpf.

    Read the article

  • Image not loading onto JPanel?

    - by None None
    I have been trying to figure out how to add an image to a JPanel as a background, but still have complete control over the placing of JButtons, JLabels, and etc. This is one method I found, but it is crashing and not loading the image or buttons. Here is the code: import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JButton; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridLayout; public class PanelDemo extends JFrame { private static final long serialVersionUID = 1L; private JButton btn1 = new JButton("EASY"); private JButton btn2 = new JButton("MEDIUM"); private JButton btn3 = new JButton("HARD"); private JButton btn4 = new JButton("High Score"); public PanelDemo() { super("Image Panel Demo"); JPanel panel = new ImagePanel( new FlowLayout(FlowLayout.CENTER, 50, 180)); JPanel panelbtn = new JPanel(new GridLayout(4, 1)); btn1.setBackground(new java.awt.Color(0, 0, 0)); btn1.setFont(new java.awt.Font("Showcard Gothic", 1, 24)); btn1.setForeground(new java.awt.Color(0, 255, 102)); btn2.setBackground(new java.awt.Color(0, 0, 0)); btn2.setFont(new java.awt.Font("Showcard Gothic", 1, 24)); btn2.setForeground(new java.awt.Color(0, 255, 102)); btn3.setBackground(new java.awt.Color(0, 0, 0)); btn3.setFont(new java.awt.Font("Showcard Gothic", 1, 24)); btn3.setForeground(new java.awt.Color(0, 255, 102)); btn4.setBackground(new java.awt.Color(0, 0, 0)); btn4.setFont(new java.awt.Font("Showcard Gothic", 1, 24)); btn4.setForeground(new java.awt.Color(0, 255, 102)); panel.add(panelbtn); panelbtn.add(btn1); panelbtn.add(btn2); panelbtn.add(btn3); panelbtn.add(btn4); add(panel, BorderLayout.CENTER); setSize(640, 480); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String... args) { new PanelDemo().setVisible(true); } } ImagePanel.java import java.awt.Graphics; import java.awt.Image; import java.awt.LayoutManager; import javax.swing.ImageIcon; import javax.swing.JPanel; public class ImagePanel extends JPanel { private static final long serialVersionUID = 1L; String imageFile = "/rsc/img/background.jpg"; public ImagePanel() { super(); } public ImagePanel(String image) { super(); this.imageFile = image; } public ImagePanel(LayoutManager layout) { super(layout); } public void paintComponent(Graphics g) { ImageIcon imageicon = new ImageIcon(getClass().getResource(imageFile)); Image image = imageicon.getImage(); super.paintComponent(g); if (image != null) g.drawImage(image, 0, 0, getWidth(), getHeight(), this); } } Error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(Unknown Source) at ImagePanel.paintComponent(ImagePanel.java:27) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JLayeredPane.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paintToOffscreen(Unknown Source) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) at javax.swing.RepaintManager$PaintManager.paint(Unknown Source) at javax.swing.RepaintManager.paint(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source) at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source) at sun.awt.SunGraphicsCallback.runComponents(Unknown Source) at java.awt.Container.paint(Unknown Source) at java.awt.Window.paint(Unknown Source) at javax.swing.RepaintManager$3.run(Unknown Source) at javax.swing.RepaintManager$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.access$1000(Unknown Source) at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Also, if anyone knows of a better way to put a background image on a JPanel, pease do tell. Thank you in advance.

    Read the article

  • application-context.xml problem for Spring ActionScript

    - by jiri
    content of The application-content.xml is <?xml version="1.0" encoding="utf-8"?> <objects xmlns="http://www.springactionscript.org/schema/objects" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springactionscript.org/schema/objects http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd"> <property file="strings.properties" /> <object id="string1" class="String"/> <object id="string2" class="String"/> <object id="nlslzf" class="com.sgb.model.MyClass"/> </objects> content of strings.properties is: s1=Firststring s2=Secondstring but error: Main Thread (Suspended: Error: An object definition for 'string1' was not found.) org.springextensions.actionscript.ioc.factory.support::AbstractObjectFactory/getObject SpringActionScript/test SpringActionScript/onCreationComplete SpringActionScript/___SpringActionScript_Application1_creationComplete flash.events::EventDispatcher/dispatchEventFunction [no source] mx.core::UIComponent/dispatchEvent mx.core::UIComponent/set initialized mx.managers::LayoutManager/doPhasedInstantiation Function/http://adobe.com/AS3/2006/builtin::apply [no source] mx.core::UIComponent/callLaterDispatcher2 mx.core::UIComponent/callLaterDispatcher2 mx.core::UIComponent/callLaterDispatcher i can run normal if removed the '' why it is? springactionscript bug?

    Read the article

  • Switching textstorage of NSTextViews back and forth

    - by Jakob Dam Jensen
    I'm trying to make a feature in a product which gives the user the ability to split a textview into two. The way this is done is by removing the textview from it's superview, making a NSSplitView and adding the textview as well as a new NSTextView instance to this splitview. Lastly I make these two textviews share the same textstorage in order to make them share the same content. It works great. But the problem is when I want to make one of the two textviews change textstorage. The replaceTextStorage method in NSLayoutManager causes both NSTextView to change textStorage. The API documentation states: replaceTextStorage: All NSLayoutManager objects sharing the original NSTextStorage object then share the new one. This method makes all the adjustments necessary to keep these relationships intact, unlike setTextStorage:. So it makes sense that it would do this. But the question is how do I make it possible to have two (or more) textviews first share the same storage and after that having them using their own? I've tried replacing the layoutManager and even making new instances of NSTextViews but no luck... Any suggestions?

    Read the article

  • Why is BorderLayout calling setSize() and setBounds()?

    - by ags
    I'm trying to get my head around proper use of the different LayoutManagers to make my GUI design skills more efficient and effective. For me, that usually requires a detailed understanding of what is going on under the hood. I've found some good discussion of the interaction and consequences of a Container using BorderLayout containing a Container using FlowLayout. I understand it for the most part, but wanted to confirm my mental model and to do so I am looking at the code for BorderLayout. In the code snippet below taken from BorderLayout.layoutContainer(), note the calls to the child Component's setSize() method followed by setBounds(). Looking at the source for these methods of Component, setSize() actually calls setBounds() with the current values for Component.x and Component.y. Why is this done (and not entirely redudant?) Doesn't the setBounds() call completely overwrite the results of the setSize() call? if ((c=getChild(NORTH,ltr)) != null) { c.setSize(right - left, c.height); Dimension d = c.getPreferredSize(); c.setBounds(left, top, right - left, d.height); top += d.height + vgap; } I'm also tring to understand where/when the child Component's size is initially set (before the LayoutManager.layoutContainer() method is called). Finally, this post itself raises a "meta-question": in a situation like this, where the source is available elsewhere, is the accepteed protocol to include the entire method? Or some other way to make it easier for folks to participate in the thread? Thanks.

    Read the article

  • How to put a background image on GridBagLayout

    - by Loligans
    I am trying to work with layout managers for the first time, and they are just kicking me in the teeth. I am trying to make a background image and then put buttons on top, using GridBagLayout, if there is a a better layoutmanager please do tell. As for trying to learn how to use layout managers, its very difficult and any learning references would also be much appreciated. This is what it looks like currently, I can get the frame to show the full image, but when i use gridlayout manager, it does that public void addComponentsToPane(Container pane){ BackgroundImage image = new BackgroundImage(); JButton button1, button2, button3, button4, button5; pane.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); if(shouldFill){ c.fill = GridBagConstraints.NONE; } button1 = new JButton("Button 1"); if (shouldWeightX) { c.weightx = 0.5; } c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 0; button1.setOpaque(false); pane.add(button1, c); button2 = new JButton("Button 2"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 0; button2.setOpaque(false); pane.add(button2, c); button3 = new JButton("Button 3"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 2; c.gridy = 0; button3.setOpaque(false); pane.add(button3, c); button4 = new JButton("Long-Named Button 4"); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 40; //make this component tall c.weightx = 0.0; c.gridwidth = 3; c.gridx = 0; c.gridy = 1; pane.add(button4, c); button5 = new JButton("button 1"); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 0; //reset to default c.weighty = 1.0; //request any extra vertical space c.anchor = GridBagConstraints.PAGE_END; //bottom of space c.insets = new Insets(10,0,0,0); //top padding c.gridx = 1; //aligned with button 2 c.gridwidth = 2; //2 columns wide c.gridy = 2; //third row pane.add(button5, c); c.ipadx = 800; c.ipady = 400; pane.add(image, c); } This is what i'm trying to make it look like

    Read the article

1 2  | Next Page >