- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我曾多次因建议使用以下方法而受到批评:
setPreferredSize()
setMinimumSize()
setMaximumSize()
在 Swing
组件上。当我想定义显示组件之间的比例时,我没有看到任何替代方法。有人告诉我:
With layouts the answer is always the same: use a suitable LayoutManager.
我在网上搜索过,但没有找到任何对该主题的全面分析。所以我有以下问题:
最佳答案
Should I completely avoid the use of those methods?
对于应用程序代码是的。
The methods have been defined for a reason. So when should I use them? In which context? For what purposes?
我不知道,我个人认为这是一个 API 设计意外。稍微受到对子尺寸有特殊想法的复合组件的影响。 “稍微”,因为他们应该使用自定义的 LayoutManager 来实现他们的需求。
What exactly are the negative consequences of using those methods? (I can only think adding portability between systems with different screen resolution.)
例如,Rules (hehe) 中提到了一些(不完整,不幸的是,由于 SwingLabs 迁移到 java.net,链接已损坏)技术原因。或在 link @bendicott 在他/她对 my answer 的评论中发现。在社交方面,给你不幸的同事带来大量的工作,他必须维护代码并找到损坏的布局。
I don't think any LayoutManager can exactly satisfy all desired layout needs. Do I really need to implement a new LayoutManager for every little variation on my layout?
是的,有足够强大的布局管理器来满足“所有布局需求”的非常好的近似。三大布局是 JGoodies FormLayout、MigLayout、DesignGridLayout。所以不,在实践中,除了简单的高度特化的环境之外,您很少编写 LayoutManager。
If the answer to 4 is "yes", won't this lead to a proliferation of LayoutManager classes which will become difficult to maintain?
(4的答案是“否”。)
In a situation where I need to define proportions between children of a Component (for example, child 1 should use 10% of space, child 2 40%, child 3 50%), is it possible to achieve that without implementing a custom LayoutManager?
三巨头中的任何一个都可以,甚至 GridBag 都不能(从来没有费心去真正掌握,太麻烦,太少力量)。
关于java - 我应该避免在 Java Swing 中使用 set(Preferred|Maximum|Minimum) 大小方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29451863/
为了使用androidx.preference,我应该将依赖添加到build.gradle 图片 A 来自 https://developer.android.com/jetpack/androidx
我正在尝试从我的应用程序设置 (preferences.xml) 的布局中检索 SeekBarPreference。但是,当我尝试将 findPreference("font_size") 转换为 S
我的需求 拥有一个充满偏好的主屏幕 (main_screen) 单击此 main_screen 中的一个首选项(pref1)会打开一个 设置子屏幕(sub_screen) 在这个 sub_screen
我正在使用 Eclipse 3.7 (Indigo) 作为 Eclipse 插件。该插件将通过产品文件打包为独立应用程序。安装将是多用户安装,如 this link 的场景 2 中所述。 。这样就会有
Preferences.flush() 和 Preferences.sync() 有什么区别? 来自Javadoc(flush()): Forces any changes in the conten
在我的 AppDelegate.m 中,如果用户还没有进入设置面板,我会尝试从我的 Preference Bundle 中初始化默认值。初始化运行,我看到了符合我偏好的正确数量的对象,但它们都是空的,
我有 CheckBoxPreference 和其他 2 个:一个是 Edit Test Pref。另一个是 ListBox Pref。我如何启用列表框首选项和禁用编辑文本首选项。 CheckBoxPr
我想使用“prefer source”选项安装所有由我维护的依赖项,以及使用“prefer dist”选项安装所有其他非我维护的依赖项。 Composer 可以吗?我在想可能有这样的东西,但我找不到:
查看PHP Composer的install命令的帮助,看到以下两个选项 $ composer help install Options: --prefer-source Fo
我无法解决错误的问题: incompatible types: no unique maximal instance exists for type variable T with upper bou
我的任务是使用 POSIX 线程编写读写实现。我想知道我的实现对于这两种情况是否正确: 已删除可怕的尝试 2 号尝试 读者首选: 变量: int readersActive_; sem_t lock_
我正在尝试使用上面的工具栏为我的应用创建一个设置窗口,以输入“后退”按钮等。但是我总是这个错误。 错误 呈现期间引发的异常:android.support.design.widget.AppBarLa
Coverity 实例详细信息: SA 版本:8.6连接:8.7 尝试将缺陷上传到 coverity 实例时,出现以下错误 正在连接到服务器 xxx.xxx.com:9090[错误] SSL 请求失败
在我当前的应用程序中,我已将偏好设置的导入从“android.preference.Preference”更改为“android.support.v7.preference.Preference”,因
在学习旧教程 (Créez des applications pour Android -> openclassroom) 时,我被 PreferenceActivity 类中的这个已弃用的方法 ad
我想在我的应用程序中使用“API Demos/app/preferences/1.preferences from XML”布局,但我不知道在哪里可以找到源文件。我在 API 演示示例中进行了搜索,但
我必须使用 weblogic.xml 在 Weblogic 12c 服务器 (12.2.1) 上 它是基于 Jersey 1.9 的 REST 应用程序。 (Jersey 1.x JAX-RS RI)
我有一些简单的代码,我正在使用它来学习使用路标库的 OAuth 身份验证。我正在尝试使用 java.util.prefs.Preferences 将请求 token 、 token secret 和
如果没有特殊要求,我们可以使用android提供的框架来创建系统样式的preference screen,在其内部可以包含preferencecategory和preference<con
我需要基于另一个应用构建一个应用。在我的 PreferenceScreen 中,我有 2 个 ListPreference 对象。第二个依赖于第一个并禁用,直到选择第一个(仍然需要弄清楚) 我想将第一
我是一名优秀的程序员,十分优秀!