Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1426 > unrolled thread
| Started by | "oddstray" <oddstray@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:33 +0000 |
| Last post | 2011-04-27 15:33 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.java.gui
Limit size of JOptionPane "oddstray" <oddstray@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
Re: Limit size of JOption "visionset" <visionset@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
Re: Limit size of JOption "oddstray" <oddstray@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
Re: Limit size of JOption "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
| From | "oddstray" <oddstray@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:33 +0000 |
| Subject | Limit size of JOptionPane |
| Message-ID | <1176230836.660006.261610@w1g2000hsg.googlegroups.com> |
To: comp.lang.java.gui Hi, I'm using a JTextArea inside a JScrollPane inside a JPanel as the "msg" field in a JOptionPane. Trouble is, my JTextArea has many lines, and the JOptionPane expands to accommodate it. I need to limit the height of my JOptionPane, but for the life of me I can't find the magic combination of layouts and set<something>Size calls that works! Here's my sequence of calls (not showing all my non-working attempts): JTextArea msgTxtArea = new JTextArea(fileBuffer.toString()); JScrollPane msgPane = new JScrollPane(msgTxtArea); msgPane.setMaximumSize(new Dimension(m_mainFrame.getWidth()/ 2,m_mainFrame.getHeight()/2)); JPanel msgPanel = new JPanel(); // needs some sort of layout and size settings msgPanel.add(msgPane); JOptionPane.showMessageDialog( m_mainFrame, msgPanel, "Warning", JOptionPane.WARNING_MESSAGE); Can anyone point me in the right direction to get this to appear properly? TIA for any help ... --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "visionset" <visionset@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:33 +0000 |
| Subject | Re: Limit size of JOption |
| Message-ID | <vvRSh.154$633.40@newsfe4-gui.ntli.net> |
| In reply to | #1426 |
To: comp.lang.java.gui <oddstray@gmail.com> wrote in message news:1176230836.660006.261610@w1g2000hsg.googlegroups.com... > Hi, > > I'm using a JTextArea inside a JScrollPane inside a JPanel as the > "msg" field in a JOptionPane. Trouble is, my JTextArea has many > lines, and the JOptionPane expands to accommodate it. I need to limit > the height of my JOptionPane, but for the life of me I can't find the > magic combination of layouts and set<something>Size calls that works! JScrollPane sp = ... sp.setPrefrerredSize(new Dimension(sp.getPreferredSize().width, myHeight); Just take the default FlowLayout of JPanel this will respect PreferredSize. -- Mike W --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "oddstray" <oddstray@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:33 +0000 |
| Subject | Re: Limit size of JOption |
| Message-ID | <1176235718.667388.142030@h3g2000cwc.googlegroups.com> |
| In reply to | #1429 |
To: comp.lang.java.gui On Apr 10, 12:24 pm, "visionset" <s...@ntlworld.com> wrote: > <oddst...@gmail.com> wrote in message > > > [edited] the height of my JOptionPane, but for the life of me I can't find the > > magic combination of layouts and set<something>Size calls that works! > > JScrollPane sp = ... > sp.setPrefrerredSize(new Dimension(sp.getPreferredSize().width, myHeight); > > Just take the default FlowLayout of JPanel this will respect PreferredSize. Thanks! That worked. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:33 +0000 |
| Subject | Re: Limit size of JOption |
| Message-ID | <VzSSh.1854$Pi4.1369@newsfe14.lga> |
| In reply to | #1430 |
To: comp.lang.java.gui
oddstray@gmail.com wrote:
> On Apr 10, 12:24 pm, "visionset" <s...@ntlworld.com> wrote:
>> <oddst...@gmail.com> wrote in message
>>
>>> [edited] the height of my JOptionPane, but for the life of me I can't find the
>>> magic combination of layouts and set<something>Size calls that works!
>> JScrollPane sp = ...
>> sp.setPrefrerredSize(new Dimension(sp.getPreferredSize().width, myHeight);
>>
>> Just take the default FlowLayout of JPanel this will respect PreferredSize.
>
> Thanks! That worked.
>
>
>
You could probably go a long way by just setting rows and columns in the
JTextArea too.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test {
public static void main(String[] args) throws Exception {
Runnable r = new Runnable() {
public void run() {
JTextArea ta = new JTextArea(
";laksdj l;aksdj weiowe sa;2334 234 2 asojoi3 23423" +
"kdddd 3awe Now is the tiem for all good men to com to the" +
"adi of theirparty. the quick brown fox jumped over the " +
"lazy red dog. ;alskd askldf ;lwkj02930n; 0wqeoji aslk" +
";l asd <F2><F2>;;laskjdoj kkd 3w []pioopi[p sadwerqddsf" +
"23423 34 3 3 234 6343 764564 66 455645 4345 77 774565 745"
,5,25);
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
JScrollPane sp = new JScrollPane(ta);
JOptionPane.showMessageDialog(null,sp);
System.exit(0);
}
};
EventQueue.invokeLater(r);
}
}
--
Knute Johnson
email s/nospam/knute/
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web