jdialog

Make Java Swing Modal Dialog Behave Like Mac OSX Dialogs

断了今生、忘了曾经 提交于 2019-12-02 02:58:00
I am writing a small app that requires a ProgressBar to appear centred under the frame's TitleBar as is often seen in Mac OSX apps. I have two problems: 1 . I have managed the positioning but I had to hard code the parent Frame's TitleBar height. Is there a 'soft' way to get the TitleBar's height? In the Dialog's constructor: Dimension dimensionParentFrame = parent.getSize(); Dimension dimensionDialog = getSize(); int x = parent.getX() + ((dimensionParentFrame.width - dimensionDialog.width)/2); setLocation(x, parent.getY() + 22); // TODO HARD CODE WARNING TITLE HEIGHT 2 . Even though the

Java dialog does not dispose

廉价感情. 提交于 2019-12-02 02:41:57
问题 Java noob here. My Swing class that extends JDialog does not dispose when the user presses the Windows Close button - java.exe stays in memory. I've stripped the code right down to this shell, I still get this behaviour. I took a look at other samples, such as at Basic Java Swing, how to exit and dispose of your application/JFrame When I commented out the two System.exit(0) lines in that sample code, the class in that sample still disposed correctly. What am I missing to make my class dispose

to persist the data of a dialog box in java

牧云@^-^@ 提交于 2019-12-02 00:54:53
问题 if(e.getActionCommand().equals("save to file")) { System.out.println("save is pressed"); StringBuffer fileContent = new StringBuffer(); TableModel tModel = m_table.getModel(); for (int i = 1; i < tModel.getRowCount(); i++) { for(int j=0;j<tModel.getColumnCount();j++) { Object cellValue = tModel.getValueAt(i, j); // ... continue to read each cell in a row fileContent.append(cellValue); // ... continue to append each cell value fileContent.append(" "); } fileContent.append("\n"); } FileWriter

to persist the data of a dialog box in java

為{幸葍}努か 提交于 2019-12-01 21:21:15
if(e.getActionCommand().equals("save to file")) { System.out.println("save is pressed"); StringBuffer fileContent = new StringBuffer(); TableModel tModel = m_table.getModel(); for (int i = 1; i < tModel.getRowCount(); i++) { for(int j=0;j<tModel.getColumnCount();j++) { Object cellValue = tModel.getValueAt(i, j); // ... continue to read each cell in a row fileContent.append(cellValue); // ... continue to append each cell value fileContent.append(" "); } fileContent.append("\n"); } FileWriter fileWriter; try { fileWriter = new FileWriter(new File("data.txt")); fileWriter.write(fileContent

How to hide JDialog from JApplet when user switch browser tab?

ⅰ亾dé卋堺 提交于 2019-12-01 19:49:39
Problem: user starts long operation from applet; JDialog with progress bar is displayed. User open/switch to another browser tab - JDialog is still displayed (and annoys user). JDialog should be hidden when user switch to another tab; and displayed again, when user switch back. Note: I saw question with similar problem, where solution was add windowActivated/deactivated listener. It doesn't work for me, because there are multiple frames in window, and one of them contains applet. When user clicks on another frame, windowDeactivate event is casted, but user still in the same tab. Try specifying

JFrames and JDialogs sometimes open up behind their parent windows but have focus

一世执手 提交于 2019-12-01 18:14:30
问题 We are developing a rather big Java enterprise application with a traditional Swing client. Every now and then, we facing the problem that random JDialogs and JFrames open up and getting the focus, but are hidden behind their parent windows. Unfortunately, this phenomenon is not reproducible and happens on occasion. So far it was recognized on machines having Win7 and WinXP installed. Since all developers running Windows operating systems, that does not necessarily mean that this problem is

Creating a custom blocking Java Swing prompt

假装没事ソ 提交于 2019-12-01 18:05:05
This problem is solved. I'm am developing a Java Swing based projected, and the look & feel of the application is completely customized. We are trying to maintain a consistent appearance throughout the program, and the default Java dialog windows are not the same. The current issue requires a control blocking call to the user prompt. Similar to JOptionPane.showConfirmDialog() In this case, the static call produces a window, and halts the flow of the program until the user selects an option. It also returns the value of the option. Note that the GUI itself is not locked up logically, but the

Font size of JDialog title

别说谁变了你拦得住时间么 提交于 2019-12-01 17:41:11
How do I set the font size of the title of a JDialog. I'm displaying JDialogs on extremely high resolution monitors (5 mega pixels), and the dialog titles are not legible. I need to do this on a per dialog basis because the application is multi-monitor, and some dialogs appear on lower resolution monitors, and some on higher resolution monitors. Bala R You can play with setDefaultLookAndFeelDecorated() , but the title bar is not going to look native or like other normal dialogs, but you can try this. JDialog.setDefaultLookAndFeelDecorated(true); JDialog dialog = new JDialog(frame, "Test");

Showing JDialog in taskbar not working

坚强是说给别人听的谎言 提交于 2019-12-01 16:11:55
问题 I'm using the below code to showing JDialog on taskbar and is perfectly working in JDK 1.6. public class test8 { public static void main(String[] args) { Runnable r = new Runnable() { public void run() { JDialog d = new JDialog((Frame)null,Dialog.ModalityType.TOOLKIT_MODAL); d.setTitle("title"); d.setSize(300,200); d.setVisible(true); System.exit(0); } }; EventQueue.invokeLater(r); } } But When I'm setting the modality type using the method it's not working public class test8 { public static

How to set the JFrame as a parent to the JDialog

谁说我不能喝 提交于 2019-12-01 15:20:03
I am having trouble to set the frame as a owner to the dialog. Normally when I extend JDialog class for creating a dialog then I use super(frame) to specify the owner of the dialog such that both of them are not disjoint when you press alt+tab . But when I create a dialog using new like JDialog dialog = new JDialog() then I am unable to specify the frame as owner to the dialog. Following example demonstrates above two approaches. Top Click button opens a dialog which is without extending JDialog . Bottom Click button opens a dialog with extending JDialog . import java.awt.BorderLayout; import