JDialog及其所有者(JDialog and its owner)
我正在尝试在我的表单JPanel中使用一些JDialog来通知用户不正确的数据和表单提交。
我只是对JDialog构造函数感到困惑。 我想将对话框链接到面板(仅因为它是创建它的地方),但显然唯一允许的所有者参数是顶级框架(我认为我不能从JPanel访问),或者对话(我看不到帮助我)。
我可以将Frame的引用传递给JPanel,但这不是一个有点奇怪的设计明智吗? 或者我是否误解了这个类,或者更常见的是JDialog应该被实例化的地方?
希望我已经明确表示,如果有帮助,我可以制作一个sscce。 谢谢。
I'm trying to use a few JDialogs inside my form JPanel to notify the user of incorrect data and form submission.
I'm just a bit confused with the JDialog constructor. I'd want to link the dialog to the panel (only because that's where it's created), but obviously the only owner parameters that are allowed are top level Frames (which I don't think I can access from the JPanel), or a Dialog (which I can't see helping me).
I could pass a reference for the Frame down to the JPanel, but isn't that a bit strange design wise? Or am I misunderstanding the class, or just more generally where the JDialog should be instantiated?
Hope I've made myself clear, I can make a sscce if it helps. Thanks.
原文:https://stackoverflow.com/questions/43984779
最满意答案
由于LearnCocos2D评论,找到了这个答案。
添加runBlock:action我能够更改zPosition。 最终的代码是:
[secondNode runAction: [SKAction repeatActionForever: [SKAction sequence: @[moveLeft, moveDown, flipRight, [SKAction runBlock:(dispatch_block_t)^(){ secondNode.zPosition = 9; }], moveRight, moveUp, flipLeft, [SKAction runBlock:(dispatch_block_t)^(){ secondNode.zPosition = 11; }]]]]];
This answer was found due to LearnCocos2D comment.
Adding a runBlock:action I was able to change the zPosition. The final code is:
[secondNode runAction: [SKAction repeatActionForever: [SKAction sequence: @[moveLeft, moveDown, flipRight, [SKAction runBlock:(dispatch_block_t)^(){ secondNode.zPosition = 9; }], moveRight, moveUp, flipLeft, [SKAction runBlock:(dispatch_block_t)^(){ secondNode.zPosition = 11; }]]]]];
相关问答
更多-
您可以在GameScene定义一个函数,如下所示。 func setCardState(state : Bool) { FaceUp = state if (!state) { Card.texture = Texture2 Player.texture = T2 } else { Card.texture = Texture1 Player.texture = T1 } } 并在新场景中从didMoveToV ...
-
首先得到投币节点。 它可以是contact.bodyA.node或contact.bodyB.node。 例如:- SKNode* coinNode = contact.bodyA.node; [coinNode removeFromParent]; //This should work 如果您只想隐藏节点,请使用 coinNode.hidden = YES; First get coin node. It can be either contact.bodyA.node or contact.bod ...
-
Sprite套件SKAction repeatActionForever随机等待持续时间(Sprite kit SKAction repeatActionForever random wait duration)[2023-09-04]
你可以使用waitForDuration:withRange: 持续时间参数代表平均等待时间,范围代表变化。 每次执行操作时,该操作都将计算该持续时间的新随机值。 持续时间可能会在任一方向上变化达durationRange参数值的一半。 例如,如果将持续时间设置为5.0并且范围为2.0,则会在4.0和6.0之间等待 You can use waitForDuration:withRange: Duration parameter represents average wait time, and range ... -
我的坏......我在创作的顺序上有一点逻辑错误。这就是我正在做的事情,以防其他人遇到同样的错误。 问题出在代码行中: monster.position = CGPointMake(self.currentMonsterX, ground.position.y + monster.frame.size.height); 正好在“ground.position.y”,因为节点“地面”尚未创建,因此怪物正在下降,因此-9000或更低。 对于那个很抱歉。 My bad .. I had a little log ...
-
Sprite Kit SKAction是否具有持续时间慢的功能执行?(Does Sprite Kit SKAction with time duration Slow Function Execution?)[2023-06-10]
提供的代码看起来很好。 但是你可以尝试检查一些事情。 确保你不是deathAnimation()调用deathAnimation() 。 确保在deathAnimation()之前没有执行enumerateChildNodesWithName 。 确保你没有在其他地方增加分数。 这些是我认为在你设置self.yourDead = true之后你的分数会继续上升的唯一原因。希望这有帮助。 The code provided looks fine. However you could try checking ... -
那么如何在设定的时间之后改变图片基本上是我要求的。 在Sprite Kit编程指南中更改Sprite的纹理演示了如何使用-animateWithTextures:timePerFrame:随着时间的推移循环遍历一系列纹理,这是您在精灵移动时为动画制作动画所需要的。 按照该部分中的示例,您应该创建一个使用纹理序列的动作。 假设你有三个纹理, texture1 , texture2和texture3 。 然后你将纹理放在一个数组中并创建一个像这样的动画动作: NSArray *walkingUpTextures ...
-
由于LearnCocos2D评论,找到了这个答案。 添加runBlock:action我能够更改zPosition。 最终的代码是: [secondNode runAction: [SKAction repeatActionForever: [SKAction sequence: @[moveLeft, moveDown, flipRight, [SKAction runBlock:(dispatch_block_t)^(){ secondN ...
-
我真的很烦恼这个问题,所以我创建了自己的自定义类JKAudioPlayer来暂时避免这个问题并为我处理我的所有音频。 它有2个AVAudioPlayer对象。 1播放音乐,1播放声音。 这是班级。 import Foundation import SpriteKit import AVFoundation /**Manages a shared instance of JKAudioPlayer.*/ private let JKAudioInstance = JKAudioPlayer() /**Pr ...
-
我不清楚你想要实现什么,但如果你的问题是为什么player和noel物体在分配相同的位置时会移动到不同的地方? 答案是你的变量player和noel是不同父母的孩子, player是self孩子。 self.map和noel是self孩子。 并且节点的位置相对于他的父节点。 I don't clearly understand what are you trying to acomplish, but if your question is why player and noel objects are m ...
-
好的,拿三个。 我不是100%确定旋转何时应该结束的具体细节等等,但所有部分都应该使用下面的代码。 它会: 根据第一次触摸的位置顺时针或逆时针开始旋转 如果用户再次触摸相同方向,则停止旋转 如果用户触摸屏幕的另一半,则切换旋转 import SpriteKit enum rotationDirection{ case clockwise case counterClockwise case none } class GameScene: ...