creating text areas - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

creating text areas

saran185saran185 Posts: 23Member
hi..

I want to create 2 text areas in the jframe.
First textarea should have a scrollpane and the other text area may not have tat scroll pane.
i want the textareas to be displayed horizontally one below the other..
I have my code attached. but only one text area is displayed on the frame..
pls help me ...
[code]
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.*;
public class hl {


public static void main(String[] args)
{
hl highlight = new hl();
}

public hl()
{ JFrame frm;
JPanel jp;
JTextArea textArea1;
JTextArea textArea2;
JScrollPane jsp;
JScrollPane jsp2;



frm = new JFrame();
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel panel = new JPanel();

textArea1 = new JTextArea("st",10,20);

jsp= new JScrollPane(textArea1);
panel.add(jsp);
JPanel panel2 = new JPanel();

textArea2 = new JTextArea("hbvfubvde",50,70);

jsp2= new JScrollPane(textArea2);
panel2.add(jsp2);


JMenuBar menubar = new JMenuBar();

JMenu filemenu = new JMenu("File");
filemenu.add(new JSeparator());
JMenu editmenu = new JMenu("Play");
editmenu.add(new JSeparator());
JMenuItem fileItem1 = new JMenuItem("New");
JMenuItem fileItem2 = new JMenuItem("Open");
JMenuItem fileItem3 = new JMenuItem("Close");
fileItem3.add(new JSeparator());
JMenuItem fileItem4 = new JMenuItem("Save");
filemenu.add(fileItem1);
filemenu.add(fileItem2);
filemenu.add(fileItem3);
filemenu.add(fileItem4);
menubar.add(filemenu);
menubar.add(editmenu);


frm.add(panel2);
frm.add(panel);

frm.setJMenuBar(menubar);
frm.setSize(1000,700);
frm.setVisible(true);




}
}
[/code]

Comments

  • krishbalodakrishbaloda Posts: 45Member
    public class Main {

    public static void main(String[] args)
    {
    Main highlight = new Main(); }

    public Main()
    { JFrame frm;
    JPanel jp;
    JTextArea textArea1;
    JTextArea textArea2;
    JScrollPane jsp;
    JScrollPane jsp2;
    frm = new JFrame();
    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setBounds(20,20,60,60);
    textArea1 = new JTextArea("st",15,5);
    textArea1.setBounds(50,50,50,50);
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();
    panel2.setBounds(20,350,100,100);
    panel2.setBounds(20,230,100,100);
    textArea2 = new JTextArea("hbvfubvde",5,5);
    textArea2.setBounds(0,0,60,60);
    panel.add(textArea1);
    panel2.add(textArea2);
    frm.add(panel);
    frm.add(panel2);
    frm.add(panel3);
    JMenuBar menubar = new JMenuBar();
    JMenu filemenu = new JMenu("File");
    filemenu.add(new JSeparator());
    JMenu editmenu = new JMenu("Play");
    editmenu.add(new JSeparator());
    JMenuItem fileItem1 = new JMenuItem("New");
    JMenuItem fileItem2 = new JMenuItem("Open");
    JMenuItem fileItem3 = new JMenuItem("Close");
    fileItem3.add(new JSeparator());
    JMenuItem fileItem4 = new JMenuItem("Save");
    filemenu.add(fileItem1);
    filemenu.add(fileItem2);
    filemenu.add(fileItem3);
    filemenu.add(fileItem4);
    menubar.add(filemenu);
    menubar.add(editmenu);
    frm.setJMenuBar(menubar);
    frm.setSize(1000,700);
    frm.setVisible(true);
    }
    }
    i thik this is what u want.




Sign In or Register to comment.