Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
class jt extends JFrame
{
public jt()
{
super("jt");
JPanel p = new JPanel(new BorderLayout());
JTextArea chatText = new JTextArea("one\ntwo\nthree",10, 30);
chatText.setLineWrap(true);
chatText.setEditable(true);
//chatText.setForeground(Color.white);
//chatText.setBackground(new Color(80,0,0));
JScrollPane chatTextPane = new JScrollPane();
chatTextPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER );
chatTextPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JViewport vp = chatTextPane.getViewport();
vp.add(chatText);
p.add(chatTextPane, BorderLayout.CENTER);
getContentPane().add(p,BorderLayout.CENTER);
try {
System.out.println(chatText.getLineStartOffset(2));
System.out.println(chatText.getLineEndOffset(2));
System.out.println( (chatText.getText()).substring(chatText.getLineStartOffset(2),chatText.getLineEndOffset(2)) );
}
catch (BadLocationException be)
{System.out.println("invalid line no");}
}
public boolean isManagingFocus() // all your JComponents should have this method overidden like this if you want to manage focus yourself
{
return true;
}
public static void main(String args[])
{
jt jtObj = new jt();
jtObj.setSize(400,400);
jtObj.setVisible(true);
}
}