Dynamically resize a text component
I am trying to build a simple twitter application. I pull in the feed from twitter and set it to an arrayCollection. This information is passed to a list component as a dataProvider. The list contains a itemRenderer that pulls in a custom component for displaying the information I want from Twitter. Here is the code for the component called Tweet:
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" verticalScrollPolicy="off">
<mx:Image width="50" height="50" source="{data.link[1].href}" />
<mx:Text width="100%" id="twitterText" text="{data.title} {'\n'} {data.author.name} {data.published}" />
</mx:HBox>
pretty simple. The problem is, the text componnent does not resize its height to the amount of text, so my text is cut off. If i set a static height, I have too much white space on short tweets. I have tried changing the height with AS3 but can't seem to get it to work. Any ideas?
Here is the the list component I am using:
<mx:Canvas width="100%" height="100%" x="0" y="100" backgroundColor="#FF0000" borderStyle="none">
<mx:List dataProvider="{ac}" itemRenderer="Tweet" top="58" left="0" right="0" bottom="40" id="theList"></mx:List>
</mx:Canvas>
Oh and if it helps, I am using the same method Lee Brimelow teaches in his 3 beginner Flex tutorials on his site gotoandlearn.com
I finally figured out the problem. The problem was not with the text component but rather the list component. Here is my list component now:
<mx:List dataProvider="{ac}" itemRenderer="Tweet" id="tweetList" top="0" left="0" right="0" bottom="145" themeColor="#A5A5A5" variableRowHeight="true"></mx:List>
I ran across the property variableRowHeight. It defaults to false. When set to true, each item in the list can be a different size. The textarea was resizing correctly.
Similar Messages
-
How to dynamically resize a display component to avoid vertical scroll bars?
Hi,
I have a Flex 2 chart embedded within my html page. I have a
hard coded height and width for the object tag. The problem is that
my Flex 2 chart application is created dynamically based on the
meta-data and as such may or may not be bigger in size than the
size that I have set. In such cases, Flex shows the scroll bar.
On creationComplete, I want to be able to detect the true
size of the flex app i.e size that includes both the view area and
the area that is hidden but scrollable. I have tried height, width,
verticalScrollBar.maxHeight etc. but none of them give me the
height and width of the whole app. Is there a way to get that in
ActionScript?
Thank you,
ANHi!
Try to read this:
http://blogs.sun.com/winston/entry/button_header_table
I hope it will help You.
Thanks,
Roman. -
Issue using JS to change the value of an output text component dynamically
I am developing an application and I need to change the output text component value at run time when the mouse moves over a field. I am using javascript and then using UIComponent.setproperty to change the value.
I am not able to do this and am getting nothing.
Kindly let me know what am I doing wrong
I am using ADF 11g (10th November release).
Regards,
DeepakHi i'm doing the same thing with an input text
here is my code
jspx:
<af:inputText value="#{bindings.MiddleName.inputValue}"
label="#{bindings.MiddleName.hints.label}"
required="#{bindings.MiddleName.hints.mandatory}"
columns="#{bindings.MiddleName.hints.displayWidth}"
maximumLength="#{bindings.MiddleName.hints.precision}"
shortDesc="#{bindings.MiddleName.hints.tooltip}"
id="it4" autoSubmit="true">
<f:validator binding="#{bindings.MiddleName.validator}"/>
<af:clientListener type="valueChange" method="mo_UpperCase"/>
</af:inputText>
js:
function mo_UpperCase(event){
var inputField = event.getSource();
if (event.getNewValue().toUpperCase()!=event.getNewValue())
inputField.setValue(event.getNewValue().toUpperCase());
In my case i change the input text to upercase when the value is changing
I hope it works with output text also,
change my examples clientlistener type from valueChange to mouseOver
If you have more than one component and you need to pass parameters check this thread also:
bug at af:clientAttribute 11.1.1.2.0
Tilemahos -
Dynamic datatable in custom component
hi all,
i'm working on a custom jsf component and this component will create a datatable dynamically. (you can see component details from http://www.jroller.com/page/hasant?entry=creating_dynamic_datatable_inside_of AND http://www.jroller.com/page/hasant?entry=jsf_question_for_community_what)
the question is; when i want to add a selection column(dynamically), how can i handle its selected values?
i mean, if i have created this datatable in a page with designer, i would bind an Integer[] to that selection column's checkboxes. But i have to add this selection column dynamically from my component. So, how can i GET and SET the selection columns values. Since this is a custom component, there is no backing bean for value binding to this component.
when i resolve the request param string to get the selected rows, it's working(=i can see the selected rows somehow..) but, i can not set that values again while encoding that column after a submit.
here is my row selection column encoding code;
private void addSelectionColumnToTable(FacesContext context, UIData table) {
UIColumn column = new UIColumn();
HtmlInputRowSelect rowSelect = new HtmlInputRowSelect();
rowSelect.setId("rowSelect1");
rowSelect.setStyleClass("inputRowSelect");
rowSelect.setValue(m_selectedRows);
column.getChildren().add(rowSelect);
table.getChildren().add(column);
}In the code above, rowSelect.setValue(m_selectedRows); part not effecting anyhing. m_selectedRows variable includes row numbers(in an Integer array) that i want to see as selected.
any solution/recommendation?Well if you are still interested in using a text component
instead of a Button the way you would go about this is using
textWidth. Here's how I've done it before using a text / label
whatever you want that shows text.
// => Set our text we got from database
myText.text = "This is the text I got from the DB";
// => Validate it so that way we make sure we get right
numbers
myText.validateNow();
// => Find out how wide our text really is.
var textWidth:Number = myText.textWidth
// => Reset the width of our text component and add 20 for
a little buffer
myText.width = textWidth + 20;
Now my suggestion is if your going to be dynamically creating
these on the fly from a database call you throw it into a method /
class and have that do all the work for you so all you have to do
is pass the text to it and it resizes itself based on the example
above. -
Dynamic linking within TextArea component
how can i include an MC or button inline within the HTML text
of a TextArea component -- and also have that object link to an AS
function? i want to have icons within the text of my TextArea that
open pop-up windows within the Flash application (MC linkage).
is this possible?
is asfunction used? if so how?Well if you are still interested in using a text component
instead of a Button the way you would go about this is using
textWidth. Here's how I've done it before using a text / label
whatever you want that shows text.
// => Set our text we got from database
myText.text = "This is the text I got from the DB";
// => Validate it so that way we make sure we get right
numbers
myText.validateNow();
// => Find out how wide our text really is.
var textWidth:Number = myText.textWidth
// => Reset the width of our text component and add 20 for
a little buffer
myText.width = textWidth + 20;
Now my suggestion is if your going to be dynamically creating
these on the fly from a database call you throw it into a method /
class and have that do all the work for you so all you have to do
is pass the text to it and it resizes itself based on the example
above. -
Center text in a text component with line wrapping
I need to display dynamic text in a text component. I need line wrapping (on work boundaries) and also need horizontal and vertical center alignment.
How do I do this? I saw a previous post on aligning text in a JTextArea that said to use a JTextPane but I don't see in JTextPane how to do word wrapping.
Thanks,
John// File: SystemInfoWindow.java.java
// Classes: SystemInfoWindow
// Package: utilities.msglib
// Purpose: Implement the SystemInfoWindow class.
// Author: JJB
// Revision History:
// Date By Rel# Description of change
// ============= === ==== ===============================================
// Jul 3, 2006 JJB 1.00 Original version
// Public Types / Classes Type Description
// ======================== =============================================
// SystemInfoWindow
package utilities.msglib;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
* TODO Enter description
class SystemInfoWindow extends JDialog {
* @param args
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Test thisClass = new Test();
thisClass.setVisible(true);
SystemInfoWindow window = new SystemInfoWindow(thisClass);
window.setMessage("System shutdown in progress ... lot sof atatarte athis tis a sa logoint of tesxt it keeps going and going and going thsoreoiat afsjkjslakjs fshafhdskrjlkjsdfj");
window.setVisible(true);
// ------------------------ Inner Classes ---------------------
static class Test extends JFrame {
private JPanel jContentPane = null;
* This is the default constructor
public Test() {
super();
initialize();
* This method initializes this
* @return void
private void initialize() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
* This method initializes jContentPane
* @return javax.swing.JPanel
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
return jContentPane;
// ------------------------ Static Fields ---------------------
private static final long serialVersionUID = -8602533190114692294L;
// ------------------------ Static Methods --------------------
// ------------------------ Public Fields ---------------------
// ------------------------ Non-Public Fields -----------------
private JPanel jContentPane = null;
private JTextPane textField = null;
public SystemInfoWindow(JFrame frame) {
super(frame);
initialize();
//setUndecorated(true);
setLocationRelativeTo(frame);
pack();
// ------------------------ Interface Implementations ---------
// ------------------------ Public Methods --------------------
public void setMessage(String text){
textField.setText(text);
adjustSize();
// ------------------------ Non-Public Methods ----------------
private void adjustSize(){
Dimension oldSize = textField.getPreferredSize();
textField.setPreferredSize(new Dimension(
oldSize.width, oldSize.height + 30));
pack();
// ------------------------ Generated Code --------------------
* This method initializes this
* @return void
private void initialize() {
this.setSize(300, 200);
this.setModal(true);
this.setContentPane(getJContentPane());
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent e) {
//setLocationRelativeTo(MsgLibGlobals.parent);
pack();
* This method initializes jContentPane
* @return javax.swing.JPanel
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.setMaximumSize(new java.awt.Dimension(50,2147483647));
jContentPane.add(getTextField(), java.awt.BorderLayout.CENTER);
return jContentPane;
* This method initializes textField
* @return javax.swing.JTextPane
private JTextPane getTextField() {
if (textField == null) {
textField = new JTextPane();
textField.setEditable(false);
textField.setMaximumSize(new java.awt.Dimension(20,2147483647));
return textField;
}Message was edited by:
BaltimoreJohn -
Hi All,
I am using JDev 11.1.2.4.0 and bounded taskflows.
In my fragment I have a popup with panel Window. I want to set the content width & height of this as per the browser
I followed the steps as per this http://www.ateam-oracle.com/dynamic-resizing-for-popup-dialogs/
My popup code is as below
<af:popup id="pdfPopup" autoCancel="disabled" partialTriggers="cb1"
popupCanceledListener="#{rLBean.closeDetachPopup}"
contentDelivery="lazyUncached">
<af:panelWindow id="pdfWindow" title="Label Design" modal="true"
stretchChildren="first">
<af:panelStretchLayout id="psl7" startWidth="0px" endWidth="0px"
topHeight="0px" bottomHeight="0px">
<f:facet name="bottom"/>
<f:facet name="center">
<af:inlineFrame id="if2"
source="/pdfservlet?#{bindings.LId.inputValue}*#{bindings.LVn.inputValue}"/>
</f:facet>
<f:facet name="start"/>
<f:facet name="end"/>
<f:facet name="top"/>
</af:panelStretchLayout>
</af:panelWindow>
</af:popup>
This popup is invoked as below
<af:commandButton text="Maximize" id="cb1" partialSubmit="true"
clientComponent="true"
icon="/images/maximize_detach.png"
shortDesc="Maximize" blocking="true">
<af:clientListener type="action"
method="openPopup('pt1:pdfPopup','pt1:pdfWindow')"/>
</af:commandButton>
Javascript method is as below
function openPopup(popupId, panelWindowId) {
return function (event) {
try {
var agent = AdfAgent.AGENT;
var windowWidth = agent.getWindowWidth();
var windowHeight = agent.getWindowHeight();
//alert('maximize.............');
var region = AdfPage.PAGE.findComponentByAbsoluteId('r1');
//alert(region +' ------------ '+popupId+' --------------- '+panelWindowId);
var popup = region.findComponent(popupId);
//alert(popup);
var panelWindow = popup.findComponent(panelWindowId);
alert(panelWindow);
panelWindow.setContentWidth(Math.max(100, windowWidth - 100));
panelWindow.setContentHeight(Math.max(100, windowHeight - 100));
if (popup != null)
popup.show();
else
popup.hide();
catch (err) {
alert(err);
When alert is there, I am getting the ID of panel window and everything works fine.
But if I comment the alerts, its returning null. I dont know whats going wrong.
Kindly HelpIssue is, with the above code, I am not able to get the panel window ID.
As you'll can see in the javascript code, I have commented the alerts. Magically, if i uncomment one of the alerts, its able to find the ID.
Yes..!! I have tried this code by setting the clientComponent=true for the pop-up as well as panelWindow. But it didn't help.....
Kind Regards -
Dynamic resize of JButton and JFrame in response to Font
Im supposed to increase the font size of the text with JButton by 1 within each click.
Eventually the text becomes shorter and less visible like WORD becomes WOR... then WO... etc
How to make the button always resize with text so that the text is fully visible and JFrame always resize with button so that the button doesn't change its position within the Frame ?
edit:
I managed to make buttons resize with increasing font
by making
JButton b = new JButton("button");
b.setHorizontalTextPosition(CENTER);
b.setVerticalTextPosition(CENTER);However the window size doesnt increase with components ;[
any help would be appretiated.
Edited by: pimpcane on Dec 11, 2007 12:16 PMOk I managed to get it working moreless by
adding pack() to the actionPerformed(...) function
public void actionPerformed(ActionEvent e)
int index = Integer.parseInt(e.getActionCommand());
int size = buttons[index].getFont().getSize();
size++;
buttons[index].setFont(new Font(name, style, size));
pack();
}The problem is in the task im given it is forbidden to use pack();
Is there any other method to obtain the same result of JFrame resizing dynamically in response to components resize ?
Edited by: pimpcane on Dec 12, 2007 12:13 PM
Edited by: pimpcane on Dec 12, 2007 12:15 PM -
Dynamically resizing DefaultMutableTreeNode
Does anyone know how to resize a DefaultMutableTreeNode after it's been created and initially sized? I have a tree that can be resized, but if I dynamically resize it so that some nodes are wider than the tree, I'd like the last few visible characters within the nodes to be replaced by three dots "..." instead of just clipping the text. The JTable does this when you resize a column.
Thanks,
Steve SinaiI change the two lines below:
1. This: textField.text = val to this: textField.htmlText = val;
2. This: return textField.text; to this: return textField.htmlText;
Here we go:
import flash.events.Event;
import flash.text.StyleSheet;
import mx.controls.TextArea;
public class DynamicTextArea extends TextArea
public function DynamicTextArea(){
super();
super.horizontalScrollPolicy = "off";
super.verticalScrollPolicy = "off";
this.addEventListener(Event.CHANGE, adjustHeightHandler);
private function adjustHeightHandler(event:Event):void{
//trace("textField.getLineMetrics(0).height: " + textField.getLineMetrics(0).height);
if(height <= textField.textHeight + textField.getLineMetrics(0).height){
height = textField.textHeight;
validateNow();
override public function set htmlText(val:String):void{
textField.htmlText = val;
validateNow();
height = textField.textHeight;
validateNow();
override public function set height(value:Number):void{
if(textField == null){
if(height <= value){
super.height = value;
}else{
var currentHeight:uint = textField.textHeight + textField.getLineMetrics(0).height;
if (currentHeight<= super.maxHeight){
if(textField.textHeight != textField.getLineMetrics(0).height){
super.height = currentHeight;
}else{
super.height = super.maxHeight;
override public function get htmlText():String{
return textField.htmlText;
override public function set maxHeight(value:Number):void{
super.maxHeight = value; -
Dynamically resizing slideshow with ken burns needed
Hi,
does anyone here know a free or commercial slideshow component for AS3 (must work with flex 3) which does the following:
cross-fading,
ken burns zooming and panning with per image definition (eg. with xml file)
scale-to-fill resizing of images
dynamically resizable frame size (so it can be used as a browser background)
It should work like on the following site
http://www.timhupe.com/
My client wants this, but programming it from scratch will take rather long, so if anyone can help out here, that would be great.
thanks
jqChris:
The export method you used creates a 640 x 480 QT file. If you use the Share->Send to iDVD menu option that will create a 720 x 540 QT file, save it in the Movies folder and automatically put it in iDVD. That should produce a higher image quality final product. If you have an iDVD project already started open it before starting the Share procedure so it will be the selected destination. In any case the larger QT movie will be saved to your Movies folder so you can include it manually is desired.
Do you Twango?
TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
G5 Dual Core 2GHz, 2G RAM, 250G HD; G4 Dual 1Ghz, 1.5G RAM, 80G HD, Mac OS X (10.4.7) 22 LCD Display, 200G & 160G FW HDs, Canon S400, i850 & LIDE 50, Epson R200 -
Getting dynamic id of a component bound to a datatable, using javascript
Hi....
I am using Sun Studio Creator to develop a small application.
I have a problem in getting the dynamic id of a component in Javascript, which is bound to a column of a datatable.
In the jsp page, I have a datatable and it is bound to a list in the backing bean.The datatable has 2 columns.One column is a checkbox and the other column is a dropdownlist. The values of the checkbox and the dropdown are taken from the list for a button click.The list data are taken from database.Now, I want to enable/disable the dropdownlist according to the check box value(the user checks/unchecks) and I want to do it on the change/onclick of the checkbox.That is, I want to get the dynamic id of the check box in a Javascript. I tried using the j4j idProxy as well. But that also failed to help me.
In Javascript,
function changeCheckboxValue() {
var i = document.getElementById('checkboxStatus').title;
alert(i);
This alert message is "undefined".
In jsp,
<h:column binding="#{AssignVals.column1}" id="column1">
<h:selectBooleanCheckbox binding="#{AssignVals.checkbox1}" id="checkbox1"
onchange="changeCheckboxValue()" value="#{currentRow['status']}">
<j4j:idProxy id="checkboxStatus" />
</h:selectBooleanCheckbox>
</h:column>
How can I get the dynamic id of the check box in the javascript?
I don't want to do this in the backing bean, as it causes more server trips.
Thanks & regards,
Menaka.What about using this in your js script?
onchange="changeCheckboxValue(this)"
Names generated by JSF implementation have the format:
<form>:<component>
For data table is like:
<form>:<datatable>:<row #>:<component>
For example:
form1:dataTable1:1:outputText1
You could parse the name of "this" and found what row and form the other component name, for example:
name = "form1:dataTable1:" + row + outputText1;
this.form[name].text = "hello";
Regards. -
Wrapping JavaFx Text Component
I am using Text component to display some text looks like there is no way to automatic wrapping like label component. I only found
text.setWrappingWidth(double d)
But this needs a number as a constraint. I have some other component next to the text element whose size is dynamic so I can't give a fixed number to limit the text wrap. Is there any way to automatically wrap if the space is not enough ?
Note : I am using Text instead of label because it honors \n character for deliberate next line wrapping but it is not possible to go through the whole text file and make sure it has a \n so that it wraps to next line.Label also recognizes the \n character.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.LabelBuilder;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class LabelTest extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane root = new BorderPane();
root.setCenter( LabelBuilder.create()
.text("This is line 1.\n\nThis is line 2. "
+"If there is not enough horizontal space "
+"this line will wrap.")
.wrapText(true)
.build() );
Scene scene = new Scene(root, 400, 400);
primaryStage.setScene(scene);
primaryStage.show();
public static void main(String[] args) {launch(args);}
} -
Moving object to back after dynamic resize
I am running Crystal Reports 2008 on a Business Objects 3.1 environment.
I have a textbox in a report that grows (width) depending on the number of records shown. The report is a cross tab, and I change the width change is to display a u201CSilveru201D box behind certain fields (to break up the report).
I recieved help from Vinay to get the fields to expand correctly (Thank you), but now it appears the dynamic resizing is the final step taken befroe publiushing the report. I need the silver text field to go to the back of the report, allowing information in the cross tab itself to appear on top.
Is there a cr command (code) that sends the field to the back of the report?
ThanksPlease re-post if this is still an issue or purchase a case and have a dedicated support
engineer work with you directly:
http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryID=11522300?resid=-Z5tUwoHAiwAAA8@NLgAAAAS&rests=1254701640551 -
Annoying Text component.
I have a class with a function that dynamicly creates some Text components and sets their properties. This works fine. They turn up where they should.
However, the e.target.x property in the event handler returns 0 for all the Text components. When testing e.target.width and e.target.toString() I get correct, individual values.
Is this a bug ??
Simplified code:
private
function createLeftBoard():void
for(var i:int = 0; i < 6; i++) {
var t:Text = new Text();
t.width = _w + i; // adding i to width here for debugging purposes
t.x = _x;
_x += _w;
t.addEventListener(MouseEvent.CLICK, assignPoints);
addChild(t);
// this doesnt work because e.target.x returns 0 for all components:
private function assignPoints(e:Event):void{
sh_marker.x = e.target.x;
sh_marker.visible =
true;Short, simplified answer: The currentTarget property is the component you attached the listener to. The target property could/is the component you were interested in's parent/container.
I hope that helps.
Ben Edwards -
How to embed a URL in a text component
Hi,
How would you embed a url within a text component such as static text?
thanks, paul.,Hello,
I would like to embed an external url (such as http://google.com) inside a panel
My application is using several panels.
In a panel, I add dynamically different ImageHyperlink components.
I succeed to display in a different panel the expected infos when I click on a link.
Now for some kind of Hyperlink components, I would like to be able to embed an external site within a container of my application.
I read about <iframe> (http://www.codeproject.com/useritems/CreatorFrames.asp) but since I building most of my components dynamically. But I do not think that it could fit my needs.
Today, when I put a panel id as a target of an hyperlink component, the external website is open in a new browser window.
Thanks,
Val
Maybe you are looking for
-
Oracle 9i database server for AIX 32 bit
Hello, I tried to download from OTN Oracle 9i database. Will there be possible to download for 32bit AIX? I feel little depressed because such stable OS I am forced to switch to Windows if I want to prepare myself little advance on future Oracle arch
-
I can not sighn in. I get the message A network error has occurred while attempting to sign in.
-
Good Day, Im looking for a way to see if it is possible to view a list or see the file names of the attachments added to a new mail message instead of icons. as when adding multiple attachments it makes it hard to see the file names. I know thunderbi
-
How to avoid or replace a sub query from Exists statement.
Hello all, I have a query regarding sql query. DB 1 Table A Table B ID Code HeaderID ID 1 100 1 1 2 200 1 2 3 100 2
-
Powerbook & Macbook Pro sitting next to each other on my desk. I used to have a connection for file sharing, but it ceased to work last week, & I have no idea why. I have tried the Finder/Go/Connect to server etc but that gives me the 'Connection Fai