1. Jdialog & Title coderanch.comHi, We are developing an multilingual application and we need to apply Right to Left orientation depending upon user language preference. I am facing an problem with the Title of the Jdialog. Even after applying Right to left orientation to Jdialog using setComponentOrientation, the title is still appearing on the left top corner. Kindly let me know if there is any ... |
2. JDialog too small for title coderanch.comJDialog d = new JDialog(); d.getContentPane().setLayout(new BorderLayout()); d.getContentPane().add(new JLabel("hi!"), BorderLayout.CENTER); d.setTitle("This is an example of a somewhat longish title"); d.pack(); if(d.getTitle() != null) // moot in this example but needed in real life { FontMetrics fm = d.getFontMetrics(d.getFont()); // +75 to allow for icon and "x-out" button int width = fm.stringWidth(d.getTitle()) + 75; width = Math.max(width, d.getPreferredSize().width); d.setSize(new Dimension(width, d.getPreferredSize().height)); } ... |
3. JDialog Title gets truncated coderanch.comHi All, Sorry for the late response. I managed to get this done. I get the font used to paint the FRAME TITLE from the Look And Feel used. With the font create the Font Metrics. From the Font Metrics, get the width. Below is the piece of code that I have used. int s_defaultConfirmDialogWidth = // SOME DEFAULT MIN WIDTH ... |