将最小化/最大化按钮添加到JDialog或JPanel [英] To Add Minimize /Maximize button to JDialog orJPanel
问题描述
是否可以向JDialog添加最大化/最小化按钮?如果没有,那么我们可以将这些按钮添加到JPanel吗?
Is it possible to add maximize/minimize button to the JDialog? if not then can we add these buttons to JPanel?
我有一个JPanel,在该面板中有一个JDialog。我想添加一个最小化/最大化按钮,以便在单击该按钮时JDialog和JDialog下的组件根据JPanel进行调整。
就像当我点击最大化然后jpanel应该放大并且该面板内部的组件(JDialog)也被放大,反之亦然最小化按钮。
我从这里得到的解决方案是JFrame中的JPanel。但我的JPanel只是独立的。
I have a JPanel and inside that panel there is a JDialog.I want to add a minimize/maximize button such that when that button is clicked JDialog and the components under JDialog get adjusted according to the JPanel. like when i click maximize then jpanel should get enlarged and components inside that panel(JDialog) also get enlarged and vice versa for minimize button. The solution I got from here is for JPanel inside a JFrame. But my JPanel is standalone only.
推荐答案
是否可以添加最大化/最小化按钮JDialog?
Is it possible to add maximize/minimize button to the JDialog?
- 不,不要这样做,(即使有一些肮脏的黑客)你可以
JDialog.setUndecorated
并添加所需的Windows装饰,注意来自Native OS的JDialog / JWindow资源,适用于SystemLookAndFeel
仅可以CrossPlatfor
m敏感 - not, don't do that, (even there are a few dirty hacks) you can to
JDialog.setUndecorated
and add required Windows decoration back, notice resources for JDialog/JWindow came from Native OS, valid forSystemLookAndFeel
only and could beCrossPlatfor
m sensitive - 是的,但你可以使用
JOptionPane
并且修改后的内容,你可以放任何JComponents
和/和返回值 - yes, but you can to use
JOptionPane
and with modified contents, there you can put anyJComponents
and/with returns value too
如果没有那么我们可以将这些按钮添加到JPanel吗?
if not then can we add these buttons to JPanel?
这篇关于将最小化/最大化按钮添加到JDialog或JPanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!