How to set a JavaFX Stage/Frame to Maximized - frame

I'm using JavaFX 2. I want my frame to open maximized but I'm not seeing a way. I searched a bit on the internet without success. For the stage I see setFullScreen() and setIconified() but I don't see anything like setMaximized().

The Java 8 implementation of the Stage class provides a maximized property, which can be set as follows:
primaryStage.setMaximized(true);

When evaluating the sourcecode of the Ensemble.jar provided with the samples of JavaFX 2.0 SDK, the currently valid way to achieve window maximizing is
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
primaryStage.setX(bounds.getMinX());
primaryStage.setY(bounds.getMinY());
primaryStage.setWidth(bounds.getWidth());
primaryStage.setHeight(bounds.getHeight());
(you find similar code in WindowButtons.java)
The 'maximize' button is still enabled and when clicking it, the windows will grow a bit more (Windows OS). After this the 'maximize 'button is disabled. In the provided example the standard buttons are replaced. Maybe this is still an issue.

Better use Multi-Screen compatible maximize logic:
// Get current screen of the stage
ObservableList<Screen> screens = Screen.getScreensForRectangle(new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()));
// Change stage properties
Rectangle2D bounds = screens.get(0).getVisualBounds();
stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());

try this simpler code
primaryStage.setMaximized(true);
and it fills up the whole screen
. note that if you remove maximize/minise buttons the application will fill the whole screen as well as remove the taskbar so mnd your initStyles if you have any

Use this to remove the Minimise, Maximise Buttons :
primaryStage.initStyle(StageStyle.UTILITY);
Where primaryStage is your Stage object.

Related

Scene rendering goes dark after calling LoadScene/LoadLevel [duplicate]

I completed Unity's roll-a-ball tutorial and it works fine. I changed a couple of materials to make it look better. I also added a C# script that should restart the level when the player falls off of the ground (I disables the walls). I am using Unity 5.5.
It initially looks like this:
But when I go off the edge and the level restarts, it looks like this:
It sometimes looks like this for a few seconds after opening unity when the editor is loading.
Here is the script:
using UnityEngine;
using System.Collections;
public class DeathTrigger : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter (Collider other)
{
if (other.gameObject.CompareTag("Player"))
Application.LoadLevel(Application.loadedLevel);
}
}
Any ideas on what's causing this?
The colors and materials are loaded. This is a lighting problem because lighliting is still calculating in the background. This will likely occur in the Editor only. This should not happen in the build.
Depending on your Unity version, you can fix this by going to Windows --> Lighting --> Settings then go to the Scene tab. Scroll down and disable Auto Generate checkbox then click the Generate Lightning button.
For older version of Unity with no Auto Generate checkbox, see here.
After play with Lighting tools, only one thing should be change on Lighting Setting for every scene.
Window > Rendering > Lighting (Unity 2020)
Click at Environment Tab
At Environment Lighting, change Source from Skybox to Color.
Select white color from Ambient Color.
Done. Try test it.
Before
After
I found many solutions online but I was missing out a step, so I hope this helps.
Most solutions indicated to go to Windows->Lightning, then untick Auto and Click Generate Lighting. My problem was that while I was pressing the generate button I did not have all of my scenes loaded for preview (at least not the scene I had problems with), so it was only applying light generation to the loaded scenes. Make sure all scenes are loaded when generating the lights.
Try Clearing Baked Data if you are using unity version around 5.5
Go to Windows->Lightning->Untick Auto->Now Click dropdown arrow of Build Button which is near Auto(Check Box) -> Select Clear Baked Data.
Now try Your code which looks fine although SceneManager.LoadScene (1); is enough.
Also unloading the previous scene and setting new scene as active scene is a good practice.
This worked for me.
File > Build settings > player Settings > (on the left) Graphics > (Top-Right) gear icon > Reset
I'm a newbie and none of the advice on web helped me. However when I went to Window > Rendering > Lightning > scene tab; If "lightning setting" says “none”, click on it and choose “demo”- setting. Press “generate”.
So it seems like it was missing settings all together which made the scene go dark when loaded.
I encountered the exact same problem. What worked for me was to set Directional Light > Light > Mode to Realtime. (it was Baked, for some reason)
I hope this can help someone in the future.

Controlling level and focus of windows other apps with CGPrivate functions

Question
How to use these private functions on other windows? It would be nice to have this knowledge back in the wild. I am specifically trying to get CGSOrderWindow and CGSSetWindowLevel to work.
I was trying in the direction of:
temporarily register as the dock and then register the dock as the dock again immediately afterwards
or
code injection into the Dock process per this comment:
Also, the author of the above project seems determined to make all core functionality available as a framework. It seems to be implemented as code injection into the Dock process.
Reason I know this is possible
I have been doing work on trying to setLevel on window of another app, and focus window of another app if focused. I am posting this again with the info I learned because from my searching online, I know this was done in the past, its just the knowledge is not publicly out there anymore. The sourceforge pages are no longer there. So I was wondering if you could help me make this information public again.
This is the topic I read that gave me this information - http://cocoadev.com/HowtoControlOtherAppsWindows
Here you see comments like:
You cannot control an another app's windows from a user-level process, unfortunately.
SlavaKarpenko
You can, Slava, you just need to register as the Dock. It might be possible to temporarily register as the dock and then register the dock as the dock again immediately afterwards, not sure. I think the call you'd be wanting to investigate as CoreDockRegisterDockOwner in HIServices.framework.
FinlayDobbie
You could also use APE or similar to do control the windows, or (as mentioned above) register as the Dock (look for the private APIs with Universal Connection in their name). Has anyone found a polite way of getting the Dock to give up its universal connection? The only way I can find is to force quit the Dock and grab the universal connection when it's not looking (which prevents the dock reloading).
SamTaylor
There's an open source project up on sourceforge.net that looks much more like the window managers I've used on Unix boxes than Space.app (or Space.dock): http://wsmanager.sourceforge.net/
SteveCook
Verifying things work
This is what I learned, from the sources at bottom of this post, we see all these functions work with CGWindowIds, so how do I get that, this is how:
Get all windows with CGWindowListCopyWindowInfo. Then access each element from that array with CFArrayGetValueAtIndex and then get the CGWindowId with objectForKey:, kCGWindowNumber, and then integerValue.
Now if I try to focus or set level of a window that is OWNED by the app running the code, it works fantastic. For instance:
MY_TARGET_CGWINDOW_ID = 179;
rez_CGError = CGSOrderWindow(_CGSDefaultConnection, MY_TARGET_CGWINDOW_ID, kCGSOrderAbove, 0);
Will focus it, rez_CGError is 0. Even if the window is minimized, it is unminimized, without animation, and shown.
Now however, if I try this on a window of a different app we get some errors:
MY_TARGET_CGWINDOW_ID_of_other_app = 40;
rez_CGError = CGSOrderWindow(_CGSDefaultConnection, MY_TARGET_CGWINDOW_ID_of_other_app, kCGSOrderAbove, 0);
This fails and rez_CGError is 1000, which I suspect means "cid (CGSConnection) used does not have permission to modify target window". The same happens if I first do [app activateWithOptions: (NSApplicationActivateIgnoringOtherApps | NSApplicationActivateAllWindows)] before making the call above.
So I first get the cid of that owning window like this:
var rez_CGError = CGSGetWindowOwner(_CGSDefaultConnection, MY_TARGET_CGWINDOW_ID_of_other_app, &ownerCid);
This works good and I get ownerCid is set to a value. Then I do the focus command with this new connection:
rez_CGError = CGSOrderWindow(ownerCid, MY_TARGET_CGWINDOW_ID_of_other_app, kCGSOrderAbove, 0);
However this gives rez_CGError of 268435459, which I suspect means "current app does not have permission to use this ConnectionId (cid)". (Same happens if I call activateWithOptions first.
My Sources for the Private Functions
Here is the sources for some private functions I found - https://code.google.com/p/undocumented-goodness/source/browse/trunk/CoreGraphics/CGSPrivate.h
This one source here contains a function that is not in the above link - CGSGetConnectionIDForPSN - i test it and it exists - from - https://github.com/mnutt/libqxt/blob/767498816dfa1742a6f3aee787281745afec11b8/src/gui/qxtwindowsystem_mac.h#L80

Unreal Engine 4 Blueprint

Im new to unreal
I have a problem with the communication from Hud_Blueprint to Level_Blueprint.
I want to have a slider in the Hud which controls the rotation of a cube in the level.
In the Hud_Blueprint i have the slider I made in a Widget_Blueprint.
Works perfect, printline values from 0 to 1.
I tried to use a Interface_Blueprint, like in the following link without success.
https://answers.unrealengine.com/questions/22126/pass-variable-from-hud-blueprint-to-level-blueprin.html
my Blueprints:
https://www.dropbox.com/s/k30ah9fjuwlff6x/zusammen.jpg?dl=0 (404 response)
Seems like i have no connection between the Blueprints.
The function works just in the Hud_Blueprint.
Well, your problem is maybe solved, but someone can find it helpful:
First, create new WidgetBlueprint and name it "Slider".
In Slider editor create Event Dispatcher called "ValueChanged" with float input. In designer, add slider and add it's OnValueChanged. From that node you must call ValueChanged with obtained Value as parameter.
In level blueprint, on EventBeginPlay create SliderWidget and Add (return value) To Viewport. You must promote Slider to variable to use it in next step - Assign ValueChanged with new event which will cover up rotation login in it's execution. See image at Dropbox
If you select your cube in the level outliner and drag that into your HUD_BP you can obtain a reference to the object that way. You can then drag a pin off the object reference and call SetActorRotation

Node-Webkit - Starting Maximized

I don't want a fullscreen application, but I would like to start a Node-Webkit application maximized. Can this be done? I am guessing its something to do with package.json, but can't seem to find what needs to be done.
I don't think the manifest has an option to do that. Instead, call nw's Window.maximize() on startup. Something like:
// Load native UI library
var ngui = require('nw.gui');
// Get the current window
var nwin = ngui.Window.get();
Sometime later, in onload or some other point where you're ready to show the window:
onload = function() {
nwin.show();
nwin.maximize();
}
This is described in the node-webkit wiki. I don't think you can call maximize before showing the main window though (if it's hidden in manifest), but I haven't really dug into it.
You may want to consider saving the window position, from a UX standpoint. The wiki has an example for doing this.

Find out Easing Functions for WinRT Theme Animations

A slightly odd question, but is there anyway to find out what easing functions are used in the WinRT XAML Theme Animations - more specifically I'm trying to replicate that of the EntranceThemeTransition (which I can't use directly).
I naively thought using something like .NET reflector would help, but I'd gather I'd need the actual source code rather than what .Net Reflector shows.
Anyone any ideas?
You might like to take a look at the AnimationMetrics sample on MSDN.
There is an AnimationDescription class that will tell you all sorts of info on the built in animation types, basically anything in the Windows.UI.Core.AnimationMetrics.AnimationEffect enum.
For example:
var animationDescription = new AnimationDescription(AnimationEffect.EnterPage, AnimationEffectTarget.Incoming);
var s = new System.Text.StringBuilder();
s.AppendFormat("Stagger delay = {0}ms", animationDescription.StaggerDelay.TotalMilliseconds);
s.AppendLine();
s.AppendFormat("Stagger delay factor = {0}", animationDescription.StaggerDelayFactor);
s.AppendLine();
s.AppendFormat("Delay limit = {0}ms", animationDescription.DelayLimit.TotalMilliseconds);
s.AppendLine();
s.AppendFormat("ZOrder = {0}", animationDescription.ZOrder);
s.AppendLine();
s.AppendLine();
//etc
Link: http://code.msdn.microsoft.com/windowsapps/Animation-metrics-sample-acb0220c
I believe these built in animations are implemented in a different way and they run independently from regular Storyboard + child animations, so you would need to approximate these with some tests that compare these with regular Storyboard animations that you implement running side by side.
One way to visualize easing functions is to run a theme transition moving a UI element in one axis while you run another one that moves the element in a perpendicular axis in a linear motion (with no easing function applied).