jdialog

How do I remove the maximize and minimize buttons from a JFrame?

懵懂的女人 提交于 2019-12-28 05:58:41
问题 I need to remove the maximize and minimize buttons from a JFrame. Please suggest how to do this. 回答1: import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Dlg extends JDialog { public Dlg(JFrame frame, String str) { super(frame, str); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); } public

JDialog doesn't respect dimensions of child components

坚强是说给别人听的谎言 提交于 2019-12-26 15:29:43
问题 I have a setup that usually works, but I'm finding it a bit of a pain at the moment. I have a JDialog (formerly a JFrame , but I've changed the UI flow recently to remove redundant JFrames ) set to BorderLayout that contains three main JPanels , header, content and footer. The header JPanel has a background image that is loading fine. However, I'm calling all manner of setMinimumSize / setPreferredSize / etc (I even tried setSize and setBounds out of desperation) and the JPanel isn't being

Unable to set a DefaultTableModel to a JTable contained in a JDialog

徘徊边缘 提交于 2019-12-25 19:37:24
问题 I have created a JDialog that contains a JTable, when I try to assign a DefaultTableModel to it, it gives me an exception and the JDialog does not even appear. java.lang.ArrayIndexOutOfBoundsException: 11 . Code to assign the table model: jTable1.setModel(new BomModel(GetBomForSetupMaterial.getPartPositionList())); My AbstractTableModel class: public class BomModel extends AbstractTableModel { private static List<JPartPosition> partPositionList = new ArrayList<JPartPosition>(); private String

Showing JDialog on taskbar does not look good

跟風遠走 提交于 2019-12-25 11:47:39
问题 Following the posts Showing JDialog in taskbar not working and Show JDialog on taskbar I have tried to show my JDialog in the taskbar. Although it worked, the behaviour is strange and it does not look good. So a button appears in the taskbar, but when I click on it a small window appears in the top left corner of my desktop. This window is so small that its content is not visible. When I enlarge it I can see it's empty. My JDialog only appears after I close this window. Is there a way to get

How to hide a JFrame when a JDialog class is open

强颜欢笑 提交于 2019-12-25 04:19:29
问题 I am tring to Hide a JFrame when a JDialog box opened, please how doi do this usuing the addActionListener(); 回答1: When you create a JDialog you should be specifying the JFrame as the owner of the dialog, then you can use the getOwner() method of the dialog to get the frame reference at any time. In you JDialog you should be able to use a WindowListener . In the windowOpened event you hide the frame in the windowClosed event you show the frame. 来源: https://stackoverflow.com/questions/22334749

My custom JDialog appears minimized and JScrollPane's scroll disappears

怎甘沉沦 提交于 2019-12-25 03:36:36
问题 I have created a basic swing program which displays an image in a JDialog box after it has been selected through a JFileChooser . I have used a JScrollPane inside the dialog box and a JLabel on which image is added as an icon, inside the pane. The following is the code I have used to construct the dialog box and its contents, the objects are already initialized with a simple new call: jDialog1.setTitle("Image"); jDialog1.setModal(true); jLabel1.setHorizontalAlignment(javax.swing

Should I use JFrame or JDialog?

浪子不回头ぞ 提交于 2019-12-25 02:03:13
问题 In my GUI, by clicking on the button "Help", I want to open a new window within it containing som text information stored in HTML via JEditorPane . My question is: Should I store an instance of JEditorPane object within JDialog or JFrame? What kind of pros/cons both components can offer? I do not want to make any operations within this window, it will just serve to show the text information. 回答1: The differences between JDialog and JFrame are, that JDialog has no maximize/minimize button, and

Incorrect cursor when outside of modal JDialog?

醉酒当歌 提交于 2019-12-24 16:00:13
问题 When using the method setCursor() , to change the cursor used by a component, everything works fine for all components, including JFrame and JDialog . The problem here resides with a modal JDialog . When the mouse is inside the dialog, the cursor is displayed right. But, when the mouse is moved outside the dialog, the cursor is re-set to the OS default, even though the underlying JFrame is using the same custom cursor as the dialog. I've searched A LOT, and found some related questions, but

Creating multiple instance of an object with same variable in Java

风格不统一 提交于 2019-12-24 14:34:54
问题 I have a modeless dialog which i need to show multiple instances of it displayed at the same time. I have kept the dialog as a member variable in a class which i new and show the dialog. Here there are multiple instances of dialog visible but i am assigning it to the same member variable.(I need to have it as member variable for some processing). It is working fine but i dont understand why this is working. Am i missig something very obvious? public class ABC { CMyDialog m_dlg; onSomeEvent()

How do I close a JDialog window using a JButton?

你。 提交于 2019-12-24 12:18:16
问题 I've tried a bunch of different ways to close the window, but since you can't send additional parameters to to Action Listener method I can't dispose the frame due to a pointer exception for the frame. This is my current code. import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class errorRequiredFieldMissing extends JDialog{ JLabel error; JButton exit; public static JFrame frame; public errorRequiredFieldMissing()