首页 \ 问答 \ JDialog及其所有者(JDialog and its owner)

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
更新时间:2022-08-10 22:08

最满意答案

由于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 ...
  • 你可以使用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 ...
  • 提供的代码看起来很好。 但是你可以尝试检查一些事情。 确保你不是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: ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)