Reputation: 1
I'm doing this program with NetBeans
and I need:
a Frame
with a split view, fitting the frame's width, each view has multiple lines, where I add/remove
strings, these strings can have a particular font and colors.
Can you provide me some examples or which classes should I use to resolve the problem ?
Thanks @trashgod, this is gonna really help me. About the layouts, i've build in netbeans a jframe that it expands to the full resolution of the screen in use, and inside of it i'd want ,as you suggested to me, 2 JTextPane half the jframe's width side by side that resize themselves when the jframe expands...until now i tried setSize() and setPreferredSize() on each JTextPane, but so far nothing...any idea why isn't working? here's my code
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = (int)screenSize.getWidth();
int height = (int)screenSize.getHeight();
System.out.println(width +" x "+ height);
this.setSize(width,height);
Dimension dimTextArea1 = new Dimension((width/2),height);
Dimension dimTextArea2 = new Dimension((width/2),height);
jTextPane1.setPreferredSize(dimTextArea1);
jTextPane2.setPreferredSize(dimTextArea2);
Upvotes: 0
Views: 358
Reputation: 205855
You can use a StyledDocument
in a JTextPane
, illustrated here, usng any of a variety of layouts.
Addendum: I'd want…half the frame's width side-by-side that resize themselves when the frame expands…I tried setSize()
and setPreferredSize()
.
Don't use setPreferredSize()
. Do add your two text panes to a GridLayout(1, 0)
, which means "one row & some arbitrary number of columns". After pack()
, use setExtendedState()
as shown here.
Upvotes: 3