Setting width/height of a control with CSS
Hi,
I am styling a button a button in CSS and set a background-image for the button in my stylesheet.
The problem is, that the button should scale to the width/height of the image.
I added:
-fx-width: 32px;
-fx-height: 32px;
but it has no effect.
I also tried it with
-fx-min-width: 32px;
-fx-min-height: 32px;
If I use setMinWidth(32); in Java, it works.
But I rather want to set it in my stylesheets, because the image can change, if we use another skin.
CSS documentation (http://docs.oracle.com/javafx/2.0/api/javafx/scene/doc-files/cssref.html) states:
"JavaFX CSS does not support CSS layout properties such as float, position, overflow, and width. However, the CSS padding and margins properties are supported on some JavaFX scene graph objects. All other aspects of layout are handled programmatically in JavaFX code."
I thought you might be able to do something using the -fx-shape property, but the shape does not affect the size of the button - so that didn't work.
I had more luck with the -fx-graphic property - you could try to enhance the stylesheet below to get what you want.
.root { -fx-background-color: azure; -fx-padding: 20; }
#smurf-button { -fx-graphic: url("http://bluebuddies.com/smurf_fun/smurf_race/jpg/Smurf_Race_100x100.jpg"); -fx-background-color: transparent; }
#smurf-button:hover { -fx-effect: dropshadow( three-pass-box , rgba(184,134,11,0.6) , 20, 0.0 , 0 , 0 ); }
#smurf-button:armed { -fx-effect: innershadow( three-pass-box , rgba(0,200,0,0.6) , 30, 0.0 , 0 , 0 ); }
public class ButtonStyle extends Application {
public static void main(String[] args) throws Exception { launch(args); }
public void start(final Stage stage) throws Exception {
final Button button = new Button();
button.setId("smurf-button");
final Scene scene = new Scene(StackPaneBuilder.create().children(button).build());
scene.getStylesheets().add(this.getClass().getResource("style.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
Similar Messages
-
Set textRollover color for Text control from css (very urgent)
Hi,
I have text control . I need to set textRollovercolor for the text control from css. Is it possible.
regards,
Jayagopal.Jayagopal
We can set the text roll over color using css like shown below.
.txtColor{
text-selected-color: #000000;
text-roll-over-color: #FF0000;
Thanks
Raghu -
Setting width/height too early??
I noticed if I set width and/or height before adding it to
displayList, the displayObject simply won't show up. The following
code is a cut&paste from livedoc (SimpleButton), except that I
add a line of "button.width=20".
If, however, I move the line to after addChild(), things work
normally.
Why?:confused: :confused: :confused:
[CODE]
package {
import flash.display.*;
import flash.events.*;
public class SimpleButtonDemo extends Sprite {
public function SimpleButtonDemo( ) {
// Create a simple button and configure its location
var button:SimpleButton = new SimpleButton( );
button.x = 20;
button.y = 20;
//// ################# Added by me. Button won't show up any
more.
button.width = 80;
// Create the different states of the button, using the
// helper method to create different colors circles
button.upState = createCircle( 0x00FF00, 15 );
button.overState = createCircle( 0xFFFFFF, 16 );
button.downState = createCircle( 0xCCCCCC, 15 );
button.hitTestState = button.upState;
// Add an event listener for the click event to be notified
// when the user clicks the mouse on the button
button.addEventListener( MouseEvent.CLICK, handleClick );
// Finally, add the button to the display list
addChild( button );
//// ############### This works, if added here!!!!
// button.width = 20;
// Helper function to create a circle shape with a given
color
// and radius
private function createCircle( color:uint, radius:Number
):Shape {
var circle:Shape = new Shape( );
circle.graphics.lineStyle( 1, 0x000000 );
circle.graphics.beginFill( color );
circle.graphics.drawCircle( 0, 0, radius );
circle.graphics.endFill( );
return circle;
// Event handler invoked whenever the user presses the
button
private function handleClick( event:MouseEvent ):void {
trace( "Mouse clicked on the button" );
}[/CODE]You're using the simple button class. Just because you
instantiate an object of this class doesn't mean you've added
anything to the button.
What I'm trying to tell you is that addChild has nothing to
do with it. Simple Button just happens to be dependent on what is
defined inside the button states themselves.
For instance, comment out your hitStates leaving your width
call after the addChild and you should notice the same behavior as
before. By defining the button states, you are actually adding
content to the container that will be drawn to the display when
addChild is called.
You can define your height and width anytime after you have
defined the states for the button. At this point, Flash will then
have content to manipulate. Until you have drawable content to push
to the display list, nothing will happen when width and height are
called. -
How to set width/height of iPad app in ipa file
Hello,
I am developing an app for iPad in Flash Builder 4 and Packager for Iphone.
I set the width and height node values in the descriptor XML and compile the application. When I run the same in iPad, I am not able to see any effect on the app's width and height.
Also, in default load, app opens in dimensions as per the iphone view and not specifically for iPad.
Any help?
Tanuhi,
How does your application descriptor file look like? I also had the same problem, when I realised that I had a few things missing in my app desc. file. My file looks like this
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/2.0">
<id>IPadApp</id>
<filename>IPadApp</filename>
<name>IPadApp</name>
<version>v1</version>
<initialWindow>
<content>IPadApp.swf</content>
<fullScreen>true</fullScreen>
<autoOrients>true</autoOrients>
<title>IPadApp</title>
<aspectRatio>portrait</aspectRatio>
<systemChrome>none</systemChrome>
<transparent>false</transparent>
<visible>true</visible>
<!-- Portrait -->
<width>768</width>
<height>1024</height>
<!-- Landscape -->
<!--
<width>1024</width>
<height>768</height>
-->
<!--<x>100</x>
<y>100</y>-->
</initialWindow>
<supportedProfiles>desktop mobileDevice</supportedProfiles>
<iPhone>
<InfoAdditions>
<![CDATA[
<key>UIDeviceFamily</key>
<array>
<string>2</string>
</array>
]]>
</InfoAdditions>
</iPhone>
</application>
Check your desc. file.
-Vrushali -
How to set the size of a control with the mouse ?
hi all,
i am writing a sort of ide (editor which creates applets very easy....) - for this purpose i need some hints from you guys:
of course i need to create some controls like buttons...
no prob - i am able to create buttons and place them at any place.
BUT WHAT ABOUT THE SIZE ?
ok, i have some ideas to realize this but what i want is a thick border arround the control with spots at each corner - when i place the cursor at one of these spots, my mouse cursor should change and it must be able to change the size of the control (while pressing and moving the mouse - you all know that from any ide).
so how to do that?
go on brains!!!
THANX,
andiI thought about creating dynamically resizable components, but gave it up as the effort seems too much for the benefit. I did a search for info on it and found a lot of people who wanted to do it, but not any who had actually done it completely. Here's some of my thoughts on the subject. You are right on about creating 'sizing handles', it seems to me the way to do this is to create your own container for any component (extend JPanel?) which can switch between no border and your new sizing border at some event. You will need to respond to mouse clicks on this border and follow the 'drag' event to find out where it was dropped. The java drag/drop events probably won't be of any use to you because each component will need an event handler. You need to catch them all.
Finally, you need to figure out how to interact with some LayoutManager or write your own. Most LayoutManagers want to do their own resizing and you will have to deal with this. For example, GridBagLayout will not only resize all of the other components on the affected row and column, but unless you resize the other components, you won't be able to drag the top higher or the left lefter? -
Column height control with css?
If I have a design with 3 columns, is there a way that all 3
columns have the same height even if 1 or 2 columns have less
content than the 3rd? Right now each column ends where the content
ends which gives it a funny look.Check PVII for an equal column height extension -
http://www.projectseven.com/
It would have to be done with javascript, or with faux
columns (Google
that).
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"OBJ" <[email protected]> wrote in message
news:e9r783$91j$[email protected]..
> If I have a design with 3 columns, is there a way that
all 3 columns have
> the
> same height even if 1 or 2 columns have less content
than the 3rd? Right
> now
> each column ends where the content ends which gives it a
funny look.
> -
How to Set default value for taxonomywebtagging control with terms and nested terms
Hi,
I have created taxonomy control in custom aspx page and I am able to select terms but I am trying to setup default value to that control.
Can anybody let me know how to set the default value for TaxonomyWebTagging control in custom.aspx page with nested terms?
Any help would be greatly apprecited.
Control code in aspx page:
<td>
<asp:Label runat="server" ID="lblLanguages">Field A: </asp:Label><asp:Label runat="server" ID="rfvlblLanguages" CssClass="errorMsg" ForeColor="Red">*</asp:Label>
</td>
<td>
<Taxonomy:TaxonomyWebTaggingControl ID="term" Width="385px" runat="server" /></td>Mapping metedata code:TaxonomySession session = new TaxonomySession(SPContext.Current.Site);
//Set the Business Unit Field
SPSite site = SPContext.Current.Web.Site;
TermStore termStore = session.TermStores["Managed Metadata Service"];
Group group = termStore.Groups["GROUPName"];
TermSet termSet = group.TermSets["TERMSETNAME"];
Term term = termSet.Terms["TermA"];
Guid termGuid = term.Id;
term.SspId.Add(termStore.Id);
term.TermSetId.Add(termSet.Id);
term.AllowFillIn = true;
term.AnchorId = countryGuid;
term.IsMulti = true;
Thank you.
AA.Hi,
According to your description, you want to set default value for TaxonomyWebTaggingControl.
I have a test in my environment. It could be achieved by setting the Text Property of TaxonomyWebTaggingControl.
Here is the code snippet:
TaxonomySession session = new TaxonomySession(SPContext.Current.Site);
SPSite site = SPContext.Current.Web.Site;
TermStore termStore = session.TermStores["Managed Metadata Service"];
Group group = termStore.Groups["GroupA"];
TermSet termSet = group.TermSets["A"];
Term term = termSet.Terms["A1"];
TaxonomyWebTaggingControl1.SspId.Add(termStore.Id);
TaxonomyWebTaggingControl1.SSPList = termStore.Id.ToString();
TaxonomyWebTaggingControl1.TermSetId.Add(termSet.Id);
TaxonomyWebTaggingControl1.TermSetList = termSet.Id.ToString();
TaxonomyWebTaggingControl1.AllowFillIn = true;
TaxonomyWebTaggingControl1.IsAddTerms = true;
TaxonomyWebTaggingControl1.IsMulti = false;
TaxonomyWebTaggingControl1.Text = string.Format("{0}|{1}", term.Name, term.Id.ToString());
Here is a detailed article for your reference:
http://blog.bugrapostaci.com/2010/09/23/taxonomywebtaggingcontrol-sharepoint/
Feel free to Reply the test result.
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Patrick Liang
TechNet Community Support -
StyleName for a Button - can I set width & height?
Hi folks,
I've declared a style in my app's css file like this:
.styButtonSmall {
width: 15;
height: 35;
And declared a button like this:
<mx:Button id="bSave" click="doSave()" label="Save"
styleName="styButtonSmall"/>
The style seems to have no effect - I get standard size
buttons. I've also tried specifying numbers like "15px" rather than
15, and also tried setting maxHeight and maxWidth in the style
specification. No luck. However, if I set height and width directly
on the button, they size themselves correctly.
So my question is: How do I use a style to specify button
height and width?
Thanks,
wsChanging the width and height of components is not supported
in styles in Flex:
http://www.adobe.com/devnet/flex/quickstart/styling_components -
Stretching the width & height of a div in CSS
I have a page with a navigation bar div (at the top), and a
content div (everything underneath), and I would like the content
div to take up the rest of rest of the page.
Setting the the content div height & width to 100%
stretches the height too much, adding scroll bars. Do I have to
somehow subtract the height of the navigation bar div?
Anyone?Anyone know what I am doing wrong?
-
Action performs % scale instead of setting width & height
Hi
I'm trying to create an action to scale an object to an width of 1024 pixel and then save if for web.
But the actions saves the percents, making it useless when applied to another object.
Can someone tell me what I'm doing wrong?
Noties in pictures, that I set the width to 1024 pixel, but in the Action it performs an Scaling of 1233,73%Record setting the width or height in the Transform palette (or Control Panel) instead of in the Scale dialog.
JET -
Setting the height of detail section with RAS SDK
Hi, all,
is it possible to locate a section (CrystalDecisions.ReportAppServer.ReportDefModel.Section) in a reportk you and set its maximum height?
When I find a detail section in question like so section = reportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[counter];
it just gives me the height of one row.
Is there a way to set a maximum size of it?
Thank you!Hi Jelena,
see the below sample to add a new section to the report.
http://scn.sap.com/docs/DOC-6025
in the sample, see below code how the section properties are set.
//Set the properties for the section
boSection.Kind = CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindDetail;
boSection.Name = "Detail2";
boSection.Height = 1000;
boSection.Width = 11520;
Refer to above sample and write your own code to identify the section and then set the properties.
Othe RAS SDk samples are here.
http://scn.sap.com/docs/DOC-28646
- Bhushan
Senior Engineer
SAP Active Global Support
Follow us on Twitter
Got Enhancement ideas? Try the SAP Idea Place
Getting started and moving ahead with Crystal Reports .NET applications. -
Problem found in setting width of javafx.scene.control.Slider
I am trying to set the width of Slider control. But does not change whatever the value I provide.
I tried width value from 1 upto 100. It displays with constant width always.
Sample : Slider{width : 10.0}
Anyone have idea how to control the width of a Slider?Yes, I found the issue when I tried to use layout on the excellent application written by Baechul: [Node Bounding Rectangles & Coordinates|http://blogs.sun.com/baechul/entry/node_bounding_rectangles_coordinates]. Looks at comments for my version.
I found out that when in a layout, you have to set the width using the layoutInfo field. -
Changing the color of the text in a Menu control with CSS
I want to change the text color of the Menu control in JavaFX. When I create a MenuBar in Scene Builder - it comes with 3 Menu controls by default ("*File*", "*Options*", "*Help*"). I have tried assigning a separate CSS id for each Menu control and using various combinations of properties to influence the text color, but can't seem to get it right whatsoever. What I want to achieve is, i.e., display *"File*" in black, instead of default white.
FXML here:
<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml">
<children>
<MenuBar id="modBar" layoutX="176.0" layoutY="122.0" styleClass="modBar">
<menus>
<Menu id="modItem" mnemonicParsing="false" styleClass="modItem" text="File" />
</menus>
<stylesheets>
<URL value="test.css" />
</stylesheets>
</MenuBar>
</children>
</AnchorPane>CSS here:
.modBar
-fx-background-color: white;
.modItem
-fx-color: black;
}I have also tried extracting the caspian CSS and playing with various properties related to *.menu* and *.menu-bar*, but still can't see the one responsible for the color of the text in menu controls?
Any help would be greatly appreciated.I think I have found the answer (just sad that it took me half a day):
.menu .label
-fx-text-fill: black;
} -
Get width/height or layer bounds with decimals values
is it possible to retrieve size or bounds of objects with decimal values?
Thank youA shape layer or any other layer with a vector mask could have decimal pixel values if you only want the area defined by the mask.
But if the paths are curved it might be difficult to determine the extreme values.
The points’ coordinates are easy enough to determine but determining the most high, left etc. expansion of a curve seems difficult to me.
The only work-around that I know is calculating a number of points along the path and evaluating those. -
Width*height vals changing in save for web ??
Hi all
I've opened an EPS file in illustrator cs4. And its width & height values are differing with width & height values in "save for web" option.
For example, normally in width & height boxes shows as
width : 247.499 pt
height : 116.524 pt
but in save for web
width : 249
height : 117
I've checked with various figures too.Script lan : javascript
thanks for ur help!
Actually I've to resize the figure for the width 175, 525, 1400 and the height should change proportionally. So I tried, but I couldn't resize the figures using save for web. Becoz its horizontalScale & verticalScale treats values as percentage. eg. 175 treats as 175%. Then I grouped all items and changed its "width" and foud out the values' corresponding "height" values. But the problem is, exported file's values are changing nearly 3pts.
could u help on this?
Maybe you are looking for
-
Anyone created a new skin/style?
Hello, has anybody tried to create its own skin or style and apply it on a Dashboard? I've followed instructions on presentation server documentation: copy s_oracle10 and sk_oracle10 folders from source folder (C:\ORACLE\BI\web\app\res) to "data" fol
-
After run a beta version and finally download the iOS 6,0 the system flopped and now i can't activate the iPAD because "the activation server do not respond". I try to restore the entire system i couldn't: always appears an error message while trying
-
Revaluation error"posting are in batch input session"
HI All, we are using 6.0 version and user has executed revaluation for FEB month,they were practised to use the online postings, but when they excute the revaluation there was an error message for 3 accts " valauation kept in batch input session "a
-
Hi everybody, I run Lightroom 5.6 on Windows 8.1. It's been a while since I exported anything and now I find that I cannot export to JPG. I get an internal error, " attempt to perform arithmetic on a nil value" . I remember that I used to have this s
-
TS3992 i-cloud backup message?
When I try to open my i-pad mini I get an i-cloud Backup message saying the i-pad has not been backed up for 3 weeks and must be plugged in, locked and connected to wi fi for back-ups to happen. I have tried plugging it in to my laptop but nothing se