Catching event on window resize?
Hello Gentlemen,
how do I do that?.
I have tried the proprty change events but they do not seem to work for me..I want to generate an event when window(frame) size is changed so that I can re-validate the contents
Thanks
nevermind...:-)
Similar Messages
-
Catch only the last resize event of a window
Hi
I've gone through the forums but can't find a solution.
Only for one of my JFrames I have to watch for component resize and trigger an action after mouse has been released.
I'm listening for componentResize but get all of them during dragging. As it is only for one window I cannot disable the dynamic layout property. Next I thought to catch the mouse release event and see that resize has been done before.
But I'm not able to get this event. Toolkit.addAWTEventListener() is not informed about this mouse event.
Any idea?
Thanks in advance
Wolfgang R.Ok, the example below produces only one final event on Windows but multiple events on Linux (jdk1.6.0)
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Sample {
private static int count = 0;
public static void main(String[] args) {
JFrame frame = new JFrame();
// System.out.println("dynamic layout: "
// + Toolkit.getDefaultToolkit().isDynamicLayoutActive());
// Toolkit.getDefaultToolkit().isDynamicLayoutActive();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(100, 100));
panel.setBackground(Color.BLUE);
frame.add(panel);
frame.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
System.out.println("count: " + count++);
frame.pack();
frame.setVisible(true);
} -
Node Container that does not resize with Window Resize Event
Hello,
I'm not new to Java but I am new to JavaFX.
I plan to have a container/Canvas with multiple shapes (Lines, Text, Rectangle etc) in it. This Container can be X times in the Szene with different Text Shapes. I need to Zoom and Pan (maybe rotation) the whole Szene and the Containers/Canvas.
So I was playing around with that but I have two issues.
1) all Canvas classes that I found (like Pane for example) do resize with the main window resize event. The content of the canvas isn't centered any more.
2) I added a couple of Rectangles to the canvas and both the rectangles and the canvas have a mouse listener which will rotate the item/canvas. Problem is, that even if I click the rectangle also the underlaying canvas is rotated...I think I need some kind of Z-Info to find out what was clicked.
Here is the little example program, it makes no produktiv sense but it demonstrates my problem.
Does anybody has a tip what canvas class would fit and does not resize with the main window and how to figure out what was clicked?
public class Test extends Application
Scene mainScene;
Group root;
public static void main(String[] args)
launch(args);
@Override
public void init()
root = new Group();
int x = 0;
int y = -100;
for(int i = 0; i < 5; i++)
x = 0;
y = y + 100;
for (int j = 0; j < 5; j++)
final Rectangle rect = new Rectangle(x, y, 30 , 30);
final RotateTransition rotateTransition = RotateTransitionBuilder.create()
.node(rect)
.duration(Duration.seconds(4))
.fromAngle(0)
.toAngle(720)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
rect.setOnMouseClicked(new EventHandler<MouseEvent>()
public void handle(MouseEvent me)
if(rotateTransition.getStatus().equals(Animation.Status.RUNNING))
rotateTransition.setToAngle(0);
rotateTransition.stop();
rect.setFill(Color.BLACK);
rect.setScaleX(1.0);
rect.setScaleY(1.0);
else
rect.setFill(Color.AQUAMARINE);
rect.setScaleX(2.0);
rect.setScaleY(2.0);
rotateTransition.play();
root.getChildren().add(rect);
x = x + 100;
public void start(Stage primaryStage)
final Pane pane = new Pane();
pane.setStyle("-fx-background-color: #CCFF99");
pane.setOnScroll(new EventHandler<ScrollEvent>()
@Override
public void handle(ScrollEvent se)
if(se.getDeltaY() > 0)
pane.setScaleX(pane.getScaleX() + 0.01);
pane.setScaleY(pane.getScaleY() + 0.01);
else
pane.setScaleX(pane.getScaleX() - 0.01);
pane.setScaleY(pane.getScaleY() - 0.01);
pane.getChildren().addAll(root);
pane.setOnMouseClicked(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event)
System.out.println(event.getButton());
if(event.getButton().equals(MouseButton.PRIMARY))
System.out.println("primary button");
final RotateTransition rotateTransition2 = RotateTransitionBuilder.create()
.node(pane)
.duration(Duration.seconds(10))
.fromAngle(0)
.toAngle(360)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(false)
.build();
rotateTransition2.play();
mainScene = new Scene(pane, 400, 400);
primaryStage.setScene(mainScene);
primaryStage.show();
}Edited by: 953596 on 19.08.2012 12:03To answer my own Question, it depends how you add childs.
It seems that the "master Container", the one added to the Scene will allways resize with the window. To avoid that you can add a container to the "master Container" and tell it to be
pane.setPrefSize(<child>.getWidth(), <child>.getHeight());
pane.setMaxSize(<child>.getWidth(), <child>.getHeight());
root.getChildren().add(pane);and it will stay the size even if the window is resized.
Here is the modified code. Zooming and panning is working, zomming to window size is not right now. I'll work on that.
import javafx.animation.Animation;
import javafx.animation.ParallelTransition;
import javafx.animation.ParallelTransitionBuilder;
import javafx.animation.RotateTransition;
import javafx.animation.RotateTransitionBuilder;
import javafx.animation.ScaleTransitionBuilder;
import javafx.animation.Timeline;
import javafx.animation.TranslateTransitionBuilder;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.ScrollEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Test extends Application
Stage primStage;
Scene mainScene;
Group root;
Pane masterPane;
Point2D dragAnchor;
double initX;
double initY;
public static void main(String[] args)
launch(args);
@Override
public void init()
root = new Group();
final Pane pane = new Pane();
pane.setStyle("-fx-background-color: #CCFF99");
pane.setOnScroll(new EventHandler<ScrollEvent>()
@Override
public void handle(ScrollEvent se)
if(se.getDeltaY() > 0)
pane.setScaleX(pane.getScaleX() + pane.getScaleX()/15);
pane.setScaleY(pane.getScaleY() + pane.getScaleY()/15);
System.out.println(pane.getScaleX() + " " + pane.getScaleY());
else
pane.setScaleX(pane.getScaleX() - pane.getScaleX()/15);
pane.setScaleY(pane.getScaleY() - pane.getScaleY()/15);
System.out.println(pane.getScaleX() + " " + pane.getScaleY());
pane.setOnMousePressed(new EventHandler<MouseEvent>()
public void handle(MouseEvent me)
initX = pane.getTranslateX();
initY = pane.getTranslateY();
dragAnchor = new Point2D(me.getSceneX(), me.getSceneY());
pane.setOnMouseDragged(new EventHandler<MouseEvent>()
public void handle(MouseEvent me) {
double dragX = me.getSceneX() - dragAnchor.getX();
double dragY = me.getSceneY() - dragAnchor.getY();
//calculate new position of the pane
double newXPosition = initX + dragX;
double newYPosition = initY + dragY;
//if new position do not exceeds borders of the rectangle, translate to this position
pane.setTranslateX(newXPosition);
pane.setTranslateY(newYPosition);
int x = 0;
int y = -100;
for(int i = 0; i < 5; i++)
x = 0;
y = y + 100;
for (int j = 0; j < 5; j++)
final Rectangle rect = new Rectangle(x, y, 30 , 30);
final RotateTransition rotateTransition = RotateTransitionBuilder.create()
.node(rect)
.duration(Duration.seconds(4))
.fromAngle(0)
.toAngle(720)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
rect.setOnMouseClicked(new EventHandler<MouseEvent>()
public void handle(MouseEvent me)
if(rotateTransition.getStatus().equals(Animation.Status.RUNNING))
rotateTransition.setToAngle(0);
rotateTransition.stop();
rect.setFill(Color.BLACK);
rect.setScaleX(1.0);
rect.setScaleY(1.0);
else
rect.setFill(Color.AQUAMARINE);
rect.setScaleX(2.0);
rect.setScaleY(2.0);
rotateTransition.play();
pane.getChildren().add(rect);
x = x + 100;
pane.autosize();
pane.setPrefSize(pane.getWidth(), pane.getHeight());
pane.setMaxSize(pane.getWidth(), pane.getHeight());
root.getChildren().add(pane);
masterPane = new Pane();
masterPane.getChildren().add(root);
masterPane.setStyle("-fx-background-color: #AABBCC");
masterPane.setOnMousePressed(new EventHandler<MouseEvent>()
public void handle(MouseEvent me)
System.out.println(me.getButton());
if((MouseButton.MIDDLE).equals(me.getButton()))
double screenWidth = masterPane.getWidth();
double screenHeight = masterPane.getHeight();
System.out.println("screenWidth " + screenWidth);
System.out.println("screenHeight " + screenHeight);
System.out.println(screenHeight);
double scaleXIs = pane.getScaleX();
double scaleYIs = pane.getScaleY();
double paneWidth = pane.getWidth() * scaleXIs;
double paneHeight = pane.getHeight() * scaleYIs;
double screenCalc = screenWidth > screenHeight ? screenHeight : screenWidth;
double scaleOperator = screenCalc / paneWidth;
double moveToX = (screenWidth/2) - (paneWidth/2);
double moveToY = (screenHeight/2) - (paneHeight/2);
System.out.println("movetoX :" + moveToX);
System.out.println("movetoY :" + moveToY);
//double scaleYTo = screenHeight / paneHeight;
ParallelTransition parallelTransition = ParallelTransitionBuilder.create()
.node(pane)
.children(
TranslateTransitionBuilder.create()
.duration(Duration.seconds(2))
.toX(moveToX)
.toY(moveToY)
.build()
ScaleTransitionBuilder.create()
.duration(Duration.seconds(2))
.toX(scaleOperator)
.toY(scaleOperator)
.build()
.build();
parallelTransition.play();
public void start(Stage primaryStage)
primStage = primaryStage;
mainScene = new Scene(masterPane, 430, 430);
primaryStage.setScene(mainScene);
primaryStage.show();
} -
Event "asynch descriptor resize" on windows
Hi,
I already found some information about the event "asynch descriptor resize" in google, but all of them were related to linux. I am using Windows Server 2008 and have the problem, that when I execute a statement (create materialized view), the event "asynch descriptor resize" is in wait state for a never ending time. I already restarted the instance but without any help. I don't know what I can do more...
Do you have any idea what's wrong with that event?
Thanks!I created a trace file, but I don't know how to interpret the result.
It mainly contains this text blocks
PARSING IN CURSOR #10 len=139 dep=0 uid=87 oct=3 lid=87 tim=7422400446868 hv=243523941 ad='7ff57e739b0' sqlid='1m5wnwh787sb5'
SELECT SID, SEQ#,EVENT,WAIT_TIME,SECONDS_IN_WAIT, STATE FROM v$session_wait WHERE sid = '66' or sid = '7' or sid = '100'
ORDER BY SID
END OF STMT
PARSE #10:c=0,e=18,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=2495754374,tim=7422400446867
EXEC #10:c=0,e=24,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=2495754374,tim=7422400446940
WAIT #10: nam='SQL*Net message to client' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=7422400446979
WAIT #10: nam='SQL*Net message from client' ela= 1082 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=7422400448095
WAIT #10: nam='SQL*Net message to client' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=7422400448213
FETCH #10:c=0,e=119,p=0,cr=0,cu=0,mis=0,r=3,dep=0,og=1,plh=2495754374,tim=7422400448242
WAIT #10: nam='SQL*Net message from client' ela= 14089 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=7422400462364After about 20minutes i see the event "db file sequential read" and it started a new trace file with
*** 2011-12-23 08:03:38.109
WAIT #6: nam='db file sequential read' ela= 4384 file#=5 block#=2092840 blocks=1 obj#=77661 tim=7422676905762
*** 2011-12-23 08:03:38.717
WAIT #6: nam='db file sequential read' ela= 335 file#=5 block#=2092825 blocks=1 obj#=77661 tim=7422677522093
WAIT #6: nam='db file sequential read' ela= 306 file#=5 block#=2092839 blocks=1 obj#=77661 tim=7422677867330
*** 2011-12-23 08:03:40.059
WAIT #6: nam='db file sequential read' ela= 374 file#=5 block#=2092838 blocks=1 obj#=77661 tim=7422678855430
WAIT #6: nam='db file sequential read' ela= 104 file#=5 block#=2093099 blocks=1 obj#=77661 tim=7422678953529
*** 2011-12-23 08:03:40.761
WAIT #6: nam='db file sequential read' ela= 398 file#=5 block#=2092823 blocks=1 obj#=77661 tim=7422679559057Do you have any idea? -
Is there any way to detect a window resizing event? When I grad the corner of a JFrame, I'd like to be able to tell that it is being resized. If anyone konw a way of doing this, please let me know.
AlanYou could have your window implement the ComponentListener interface. There is a method that gets called when the component's size changes.
-S- -
Newbie question - sorry. How do I capture the browser window
resize event?
I've tried variations on this code:-
<mx:Script>
<![CDATA[
import flash.events.Event;
function mylisten():void { trace('mylisten');
this.stage.addEventListener(Event.RESIZE,resizefn);
function resizefn():void {
trace('resize!');
]]>
</mx:Script>Hi brutfood,
you can add a handler to the resize event of the application
as an attribute of the Application tag.
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" resize="resizeHandler()">
Then add the handler ("t" is TextArea):
private function resizeHandler():void {
t.text = stage.width + " - " + stage.height;
t.text += "\n" + stage.stageWidth + " - " +
stage.stageHeight;
Note the difference between the width/height and
stageWidth/stageHeight properties: the first couple returns the
actual stage dimension while the second returns the visible area of
the stage.
regards,
Christophe -
How do we get mac to catch up to microsoft windows "window resizing"
This mac windows resizing stinks, you have to find the bottom right corner?!! what a joke!
I have had my g5 for 9 months and still can't get past this major flaw!
Microsoft windows is so far ahead!!
if you don't know what I mean (i.e. how easy microsoft has always allowed you to resize windows) you are really in the dark. any corner or window wall is "alive" for you to grab and resize
However, since I am new, perhaps I'm just missing something.
so here's my 2 part question
(1) Am i missing something basic?
(2) If the mac really stinks like I think it does (with window resizing), then how do we get them to change it?Actually, Sam. I agree on the window sizing thing. In OS 9 you could grab the edges to resize a window, not just the lower corner. While it's not that big a deal to be limited to using the lower right corner, it's just not as convenient as being able to grab most anywhere.
While OS X has been around for a few years now, each major release adds things that were in OS 9 (and earlier) that weren't in the initial release. It has to be a heck of a job taking what at the start was the generic BSD distribution of Unix and try to make the well know Apple GUI of before work on top of it seamlessly.
So far, I think they're doing a great job. But there are still some things that haven't made it back into the new OS. Window resizing is one of 'em. -
Hello all,
I'm a beginning Flex programmer and I've run into an issue I
don't know how to resolve. The problem is this: when my app is
compiled under Flex 2 all of my window components resize nicely
when the browser window is resized (<mx:Application width="100%"
height="100%">). However, when I compile under Flex 3 this
doesn't work; all components stay the same size and I get
scrollbars at the edges of the browser window if I shrink the
browser window.
The backwards compatibility and migration documentation
doesn't say anything about this functionality being changed. Anyone
have any idea why this is happening, and how I can get the older
functionality back?Setting the scroll policy to off certainly gets rid of the
scrollbars, but it doesn't actually fix the resize behavior of the
application.
I ended up fixing this problem by cheating: I set up a resize
handler for mx:Application that resizes the main Container in the
app.
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:custom="components.*" layout="absolute"
width="100%" height="100%" minWidth="780"
minHeight="580">
<mx:resize>
<![CDATA[
try { bpanel.width = width; bpanel.height = height; }
catch (err:Error) {}
]]>
</mx:resize>
A hack, yes, but at least things work again. -
When I open the event list window in Logic 7 (and 7.1) the arrow on the left,
which is supposed to point to the current event , points to the event BEFORE the current one unless i resize the event list numbers larger! Does this make sense?
It is most frustrating.Wouldn't it be easier to select a note value rather than typing in what the value is for the note? For example, wouldn't it be nice if there was a set of buttons with pictures of a whole note, 1/4 note, etc. (like in Cubase) or a drop down menu (like Logic's quantize menu) to select from? It's killing me to try and memorize the numerical values for each kind of note. What if I wanted a fixed duration of an 1/8th note tuplet? How would I calculate the value for that? Is there an option somewhere I can turn on to make setting note values easier? This is my only problem with the transform editor...
-
Catching events on Desktop , without using any AWT or Swing components.
How can I catch events(for eg: mouse clicks) on the Desktop? I do not want to use any AWT or Swing components in my application.
Also, i want to get events even some other java/non-java application windows are visible on desktop, as long as my application is running.Myrequirement is to capture all AWT events, regardless of on which component its being happened.
I mean I have to capture events outside the current running application (on desktop and any other java/no-java appliation windows also).
I couldn't find any other forum which discusses about event handling.
This is part of my app. other end extensively uses awt. -
VISA missing state change on window resize
My code is polling a memory location using VISA (viMoveIn16) over a VXI/VME bus running under Windows NT. This polling is done repeatedly as the memory location changes between values. This normally works quite well and is resistant to processor load. However, should another application be launched or a window resized, the memory location change in value is missed. I have run using NI-Spy and do see the viMoveIn16 commands repeatedly in that log, they just all return the same value (not the one I am looking for). Are there any PC command caching issues that would cause problems on window resize? Is there some reason why the commands would not actually make it to the bus under this scenario? DOesn't the success return
ed from viMoveIn16 indicate that the response has been received? Has anyone experienced a problem similar to this before?The address space being read is the A16_SPACE. In all of my testing, the failure occurs at a specific location in the code. There are 3 memory reads and 2 of them appear to work correctly. However, the 3rd will catch the resize each time it occurs. All 3 memory reads will work correctly if no resize is encountered. Still looking for the remaining requested data.
-
Acces function window.resize
Hi,
I want to acces a function from an Event 'window.resize' on the stage, and the function that I need to access is in a clip called 'Graduation" in the CreationCompleted of this clip (please excuse my english)
I tried without success that
sym.$("Graduation").MadeGraduation();
and
sym.getComposition().getStage().getSymbol("Graduation").MadeGraduation();
and
sym.getComposition().getStage().$("Graduation").MadeGraduation();
any idea ?
thanksHi,
I understood that you want to « call » a function from creationComplete (one symbol) to window.resize
==> A demo file can be downloaded here: https://app.box.com/s/xr35fqf9pogp84a1inw9
I apply Edge API: http://www.adobe.com/devnet-docs/edgeanimate/api/current/index.html#symbolinstance setVariable
creationComplete:
function MadeGraduation () { ... };
sym.setVariable("myGraduation", MadeGraduation);
window.resize:
sym.getComposition().getStage().getSymbol("Graduation").getVariable("myGraduation")(); -
Safari prevents JavaScript window resize?
Hello,
I'm working to integrate some streaming video into an intranet site via popup windows. It seems that Safari is not responding to the JavaScript self.resizeTo or self.moveTo methods when we attempt to put the streaming media player into fullscreen mode.
For additional context:
Tthe expansion to fullscreen is initiated by clicking on a button in a Flash media application, but there is a defined JavaScript event handler that will subsequently call the self.resizeTo and self.moveTo methods on the browser window. This is not working in Safari, though it works in IE and Firefox.
If there are considerations or caveats that relate to JavaScript and the manipulation of window size/placement, I would greatly appreciate any information.
I found this link (http://lists.evolt.org/archive/Week-of-Mon-20050228/170191.html) that may be relevant to this discussion, but I haven't seen it validated.
Thank you in advance.
Regards,
Benson
Macbook Pro Mac OS X (10.4.7)After some testing, it appears that my problem does not exist with basic JavaScript window resizing and movement. In test scenarios, when javascript commands are placed in anchor tags, clicking the links will result in appropriate window movement and resizing. The issue seems to be the fact that the window resizing is not directly user initiated (at least not by clicking on an HTML link).
Are there any features of Safari that would prevent Flash-driven events from successfully triggering JavaScript actions? -
Scrolling and windows resizing
Is there a way to turn off the feature where if you scroll up or down with your mouse positioned over a windows title bar it resizes the window. This "feature" works with both a standard mouse using a scrollwheel and also when using a touchpad with two finger scrolling.
The only third party program that I use which modifies the mouse is Sizeup and I have rigorously gone through its setting to determine if it was causing this behaviour. Also the behavior persists even when I shut down sizeup so I don't think it is the cause.
edit:
I would also add that this behaviour only appeared after I upgraded to 10.8. While I do have a lot of third party programs running and alot of them were updated when mountain lion was released so it is theoretically possible that this is behaviour is comeing from an external source I have no idea why any of the other programs I have running would affect window resizing. -
I am a loyal user of logic for 8 years now. yes I'm posting about an issue where logic crashes (as in: freezes for 30 seconds then closes even if other apps are reWired to it)
It does this SOMETIMES, when resizing any window in logic..
it says: UNEFINED RECURSION ERROR and then you know you'll be rebooting your mac g5 (tested on g4 too)
I sit here thinking of ten years of buying updates.
and by PURE LUCK alone, I buy every update hoping that certain issues will be fixed. Most are not.
On a mac there are two ways a window can be act when being resized:
1 - as you drag the re-sizer corner of the window, you see only a dotted outline of the window, then when you let go, the window resizes.
2 - as you drag, the entire contents of the window moves as you drag.
#2 causes crashes. #1 is fast and quick.
Mr. Moderator, you can delete this post as expected. But you do know as well as I do, these guys never do a user request.
I mean my $200 alone is enough to pay one developer to fix things like this.
Nevermind $200 from 2 million people!
What are you doing with your user requests and your users money?Might try removing your media files associated with the project... put them in another folder, or disconnect the fw drive that holds them...?
Do other project files do the same or just this one?
Jerry
Maybe you are looking for
-
Screen input not getting cleared
Hi All, I got a peculiar problem, In my dialog screen(ztcode), i have make a field input enable based on machine and position(Ztable). Now my problem is, when this field gets input enabled im getting some value with this(some 30.12), i really dont kn
-
Can't switch input layout in Contacts and other ap...
When Contacts is oepend, it's impossible to switch input language with Ctrl-Space. You have to enter 1 letter and then it is possible to switch layout. Any ideas how to fix this?
-
I recently ordered a television and I was told I'd get a phone call within 24 hours of delivery to let me know what time it would come. First, I emailed customer support, but the response was that I wouldn't hear anything back within 24 hours b/c of
-
I have got e 90 but i m not able to install any themes. can anybody help me for it. pls........................................
-
BRMS Connector - Transport Request Error
Hello BRF Experts, We are created a BRMS connector expression, but when we tried to save it in a transport request, we obtain tha following message errors: Might be an authorization problem; check Hot Package / S_CTS_ADMIN