Java Fx styles in css file cannot be hot deployed - javafx-2

I am creating a desktop application with just JavaFX and CSS (no Scene Builder). When I run the application in the Debug Mode all Java Changes are reflected in the application. But CSS changes are reflected only after I restart.
Is there a way to reflect the CSS changes also.

I found a work around..
It is not a clear solution but it should work.
Suppose I have to hot deploy and change this css
.pop_wizard_Top{
-fx-border-width: 5 0 0 0;
-fx-padding: 10 5 0 0;
}
Corresponding Java Code
topPanel = new HBox();
//topPanel.getStyleClass().add("pop_wizard_Top"); - Adding class here
Instead of that write down the styles like below in java class.
topPanel.setStyle("-fx-border-width: 5 0 0 0; -fx-padding: 10 5 0 0; ");
Now we can change the styles.
Once we finalze copy the styles and paste in css.
This is just a work around. !

Related

Application bar color for MDI in VC++ (MFC)

How to define a system theme to be applied that matches the new style and apply it. Please find the attached image for the actual and expected style.
MDI Frame window color:
The following approaches i have tried so far, it was not yielded expected result.
1: Setting Application caption using Windows API The following code sets the color for application title bar for the session. But with theme settings and such on Windows 8.1 and 10, it does not come into effect.
int aElement = COLOR_ACTIVECAPTION;
DWORD aOldColor;
DWORD aNewColor;
aOldColor = GetSysColor(aElement);
aNewColor = RGB(0x04, 0x04, 0x04);
SetSysColors(1, &aElement, &aNewColor);
2: Using theme/DWM API
With a Windows theme in effect, changing the application title bar alone does not become successful. Have tried:
2-a: Getting theme handle, defining a captionbar and using the captionbar in a call to CMFCVisualManager::GetInstance()->OnDrawCaptionBarBorder()
2-b: DwmSetWindowAttribute() was used for setting rendering policy disabled.
3: Using CMFCVisualManager
Defining a CMFCCaptionBar and assigning it to CMFCVisualManager. This too does not get the effect needed.

vaadin 7: layout displaced after opening/closing dialog window

I am new to the forum and to programming so hopefully I give you enough details and precise information needed to understand my question.
I am working with vaadin 7 in java EE web aplication and I have a layout problem/phanomena that I cannot explain and I could not find a solution on the net. Basically, when I start the server and test my application on localhost everything looks right. When I open a dialogue window and close it again, the layout of the site looks displaced. I could not find a pattern as to which click causes this effect. Sometimes it happens also when I only change a view. This is how it should look like and this is how it does look like after working in the application.
I looked through the devloper tool in the browser and noticed that in the working html, the attributes "top" and "left" are set for the gridlayout-slot. In the displaced layout these attributes are not set. Furthermore, it seems that the problem occurs more often in chrome. It does also happen in firefox but less often.
I use VerticalLayout, GridLayout and FormLayout.
Did you have similar experience? I am wondering how and when the html files are generated from the vaadin code to find out why they change and how I can fix it.
I am not sure which code exactly is causing the problem, so I am not sure what to post. If you have an idea where to look, I can add more code. Here is how the Dialog is set up:
public class Dialog extends Window implements ClickListener
public Dialog(CustomController controller, String title)
{
super(title);
setModal(true);
setStyleName("dialogWindow");
this.controller = controller;
setWidth("65.0%");
setHeight("90.0%");
// top level component properties
panLayout = new GridLayout();
panLayout.setWidth("100%");
panLayout.setHeight("100%");
buildPanToolbar();
panLayout.addComponent(panToolbar);
buildPanTop();
panLayout.addComponent(panTop);
buildPanTabs();
panLayout.addComponent(tabsheet);
panLayout.setComponentAlignment(tabsheet, Alignment.MIDDLE_CENTER);
panLayout.setRowExpandRatio(2, 1.0f);
tfThema.focus();
setContent(panLayout);
}
The buildSomething() functions are all a combination of GridLayout, FormLayout, HorizontalLayout and VerticalLayout. Below is the buildPanToolbar() function as an example
private void buildPanToolbar()
{
panToolbar = new HorizontalLayout();
panToolbar.setImmediate(false);
panToolbar.setWidth("100%");
panToolbar.setHeight("25px");
panToolbar.setMargin(false);
panToolbar.setSpacing(true);
panToolbar.setStyleName("toolbar");
HorizontalLayout panHelpToolbar = new HorizontalLayout();
panHelpToolbar.setImmediate(false);
panHelpToolbar.setWidth("-1px");
panHelpToolbar.setHeight("25px");
panHelpToolbar.setMargin(false);
panHelpToolbar.setSpacing(true);
panHelpToolbar.setStyleName("toolbarButtons");
panToolbar.addComponent(panHelpToolbar);
pbButton1 = new Button();
pbButton1.setCaption("Button1Text");
pbButton1.setStyleName(BaseTheme.BUTTON_LINK);
pbButton1.setImmediate(true);
pbButton1.setWidth("100px");
pbButton1.setHeight("-1px");
pbButton1.setIcon(new ThemeResource("../images/pic1.gif"));
pbButton1.addClickListener(controller);
panHelpToolbar.addComponent(pbButton1);
panHelpToolbar.setComponentAlignment(pbButton1, Alignment.MIDDLE_LEFT);
pbButton2= new Button();
pbButton2.setCaption("Button2 Text");
pbButton2.setImmediate(true);
pbButton2.setWidth("100%");
pbButton2.setHeight("-1px");
pbButton2.setStyleName(BaseTheme.BUTTON_LINK);
pbButton2.setIcon(new ThemeResource("../images/pic.gif"));
pbButton2.addClickListener(this);
panHelpToolbar.addComponent(pbButton2);
panHelpToolbar.setComponentAlignment(pbButton2, Alignment.MIDDLE_LEFT);
}

Set Font globally in JavaFX

How can I set the Font type globally in a JavaFX application?
Is there any solution that I can use? In JavaFX 8 the default Font has changed, and I would like to use the same Font used in JavaFX 2.2.
You can skin your application with CSS as described on the Oracle Website.
Using following syntax you may set the general theme for your application:
.root{
-fx-font-size: 16pt;
-fx-font-family: "Courier New";
-fx-base: rgb(132, 145, 47);
-fx-background: rgb(225, 228, 203);
}
You include the css as followed:
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
Changing the Default Font for a Scene
This is the solution outlinked in nyyrikki's answer.
You can change the default font used for most things in any given scene by applying the following CSS stylesheet to the scene:
.root {
-fx-font: 28px Vivaldi;
}
Substitute whatever settings you require for the -fx-font value according the font definition in the JavaFX CSS reference guide.
Changing the Default Font for an Application
If you want to change the default font used for most things in a JavaFX application, you can override the default style sheet using Application.setUserAgentStylesheet. Using this method you can set the default style for a JavaFX 8 application to the caspian stylesheet which was default for JavaFX 2.2 rather than the modena stylesheet which is default for JavaFX 8. If you want some hybrid of the two default styles or some custom default stylesheet such as AquaFX, then you will need to perform the customization yourself.
Switching Font Rendering Technology
Additionally, on some platforms, JavaFX 2.2 uses a different font rendering mechanism than JavaFX 8, which can account for subtle differences in font rendering between the two. There is an undocumented and unsupported command line switch which can be used to switch between font rendering mechanisms in JavaFX 8, but I don't know what the switch is off-hand and, even if I did, I wouldn't recommend deploying an application using the switch as it is unsupported.
FWIW, if you want to make the font change programmatically (no external css files involved), you can make a "global" change by using the .setStyle() method on the top parent node.
Example, I wrote a quick GUI (a bare bones testing framework) that both a Windows and a Mac user needed to run (and I'm writing on Linux/Ubuntu). The Mac user complained that the fonts were too small. So I added the following:
String os = System.getProperty("os.name","generic").toLowerCase(Locale.US);
if (os.indexOf("mac") > 0) {
root.setStyle("-fx-font-size: 14pt");
}
In this case, root is the Parent node in the Scene instantiation. All nodes connected to root will share this font size setting, unless the setting is overwritten.
Just a TornadoFX example
package bj
import tornadofx.*
class MyView : View() {
override val root = vbox {
button("天地玄黄")
button("宇宙洪荒")
}
}
class MyStylesheet : Stylesheet() {
init {
root {
fontFamily = "Noto Sans CJK SC Regular"
}
}
}
class MyApp : App(MyView::class, MyStylesheet::class)
fun main(args: Array<String>) {
launch<MyApp>(*args)
}

How to change the border style of applications main window in visual c++ win32 API

I have an application in Visual c++ (Win32 API). In my application the main window boarder is displayed in old windows styled. I have tried changing the wndWc.style values to WS_OVERLAPPED,WS_POPUP and other which are given in WinUser.h but there is no change in the appearance of the main window were as all my pop-up window are displayed in windows 7 style how this can be rectified. Any help in this regards will be highly appreciated. I have attached both the images the main window and the pop up window.
Code :
// our window class
WNDCLASS wndWc;
// ---------------------------------------------------------
// fill window class members
// ---------------------------------------------------------
wndWc.style = CS_GLOBALCLASS;
wndWc.lpfnWndProc = (WNDPROC) WndProc;
wndWc.cbClsExtra = 0;
wndWc.cbWndExtra = 0;
wndWc.hInstance = GetModuleHandle(NULL);
wndWc.hIcon = NULL;
wndWc.hCursor = LoadCursor(0, IDC_ARROW);
wndWc.hbrBackground = (HBRUSH)GetStockObject(0);
wndWc.lpszMenuName = NULL;
wndWc.lpszClassName = "XYZ";
// register class
if (!RegisterClass(&wndWc)) return false;
// ---------------------------------------------------------
// get actual screen resolution
int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); // height
int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN); // height
// make a rectangle on the center of the screen
RECT rc = {(iSw - iWidth)/2, (iSh - iHeight)/2, width, height};
// create the window. the spaces on the window title
// are just to make sure this will be visible when the region
// is active. just run the app and you'll understand. =)
hWnd = CreateWindow("XYZ", "XYZ",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT, width,height,
NULL, NULL, GetModuleHandle(NULL), NULL);
It could be that your EXE has been flagged to run in compatibility mode for a previous OS version. Right-click the EXE, choose Properties, then ensure everything is switched off on the Compatibility tab. (Especially "Disable visual themes" and "run this program in compatibility mode for...")
Failing that...
It's unusual to need to do anything at all, but try this at the start of the app:
SetThemeAppProperties(STAP_ALLOW_NONCLIENT|STAP_ALLOW_CONTROLS)
If that doesn't work, try explicitly setting the theme for your window:
SetWindowTheme(hWnd, "WINDOW", NULL);
FWIW, I pasted your code in to a new Visual Studio 2008 project created using the "Win32 project" wizard, and it came out with a Windows 7 border. You usually have to go out of your way not to get the border, in fact.
There could be something unusual about the EXE you are building, like a flag in the EXE's header being set incorrectly. e.g. If it isn't specifying that it is a Windows GUI app, or maybe there are some version fields...
The EXE's manifest may also play a part, but I just tried deleting the manifest completely and my program still got a themed window, so it's probably not that.
If you look closely, you'll see that it's not just the border. The close button also uses the old visual style. Therefore, it's not sufficient that you change the window style. You must indicate that your app is Vista- and Aero-aware

iOS 4.2 Block Animation --> Why do I get these warnings: -[UIApplication beginIgnoringInteractionEvents] overflow. Ignoring

I've got some code that wobbles UIViews, much like when you edit your iOS home screens.
I have the 2 following methods to achieve this wobble effect:
- (void)wobble {
int amountInRadians = (self.tag % 2) == 0 ? 2.0 : -2.0;
containerView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-amountInRadians));
[UIView animateWithDuration:0.10
delay:0.0
options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)
animations:^ {
containerView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(amountInRadians));
}
completion:NULL
];
}
- (void)stopWobble {
[UIView animateWithDuration:0.01
delay:0.0
options:(UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear)
animations:^ {
containerView.transform = CGAffineTransformIdentity;
}
completion:NULL
];
}
When I stop the wobble, I get the warning (many times over):
-[UIApplication beginIgnoringInteractionEvents] overflow. Ignoring.
then (many times over, matching number of begin ones):
-[UIApplication endIgnoringInteractionEvents] called without matching -beginIgnoringInteractionEvents. Ignoring.
What on earth is going on? If I comment out the stopWobble animation, it's fine, but naturally my animations don't stop. If I remove the "UIViewAnimationOptionAllowUserInteraction" option when I begin the animation, I get the beginIgnoringInteractionEvents warning, but this is also no good because I need to interact with these views while they wobble.
The behaviour works fine, so should I just ignore this? Seems to me like something I should fix, if only I can find out what causes it.
Try adding UIViewAnimationOptionAllowUserInteraction to stopWobble. I've gotten that error message before and it seems to have to do with two animations trying to execute simultaneously when they are not explicitly set to do so. Adding UIViewAnimationOptionAllowUserInteraction to my second animation fixed this problem for me.
I guess it happens when you have too many views that will animated at the same time, like a grid of custom views in viewDidAppear.
a. Under iOS4 they all try to disable UIApplication interactions at the same time and to avoid problems UIApplication overflows and ignores some of them.
b. After animating all views tell again UIApplication to enable interactions but UIApplication doesn't recognize some of the enable calls as they were ignored in (a).

Resources