Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to make JTextArea size thesame with its splitpane

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post How to make JTextArea size thesame with its splitpane

    i have a textarea on a scrolpane attached to a panel, how can i make the size automatically adjust when the split pane is adjusted?
    regards


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to make JTextArea size thesame with its splitpane

    Can you give us an example program in SSCCE form that shows us exactly what you're talking about?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to make JTextArea size thesame with its splitpane

    JPanel querypanel = new JPanel();
    JPanel resultpanel = new JPanel();
    JTextArea textArea = new JTextArea(10,60);
    JScrollPane scrollPane = new JScrollPane(textArea);
    querypanel.add(scrollPane);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, querypanel, resultpanel);
    getCOntentPane().add(splitPane);

    find attached a copy of the image of the output. i want the textarea attached to the panel to adjust automatically as you drag the splitpane up or down

  4. #4
    Junior Member
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to make JTextArea size thesame with its splitpane

    [Consider the program below]

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package scheduling;

    /**
    *
    * @author ThankGod
    */
    import javax.swing.*;
    import java.awt.event.*;
    public class DualQuery extends JFrame implements ActionListener
    {
    JMenuBar jmb = new JMenuBar();
    JMenu file = new JMenu("File");
    JMenuItem exe = new JMenuItem("Execute Query",new ImageIcon("execute.jpg"));
    JPanel querypanel = new JPanel();
    JPanel resultpanel = new JPanel();
    JTextArea textArea = new JTextArea(10,60);
    JLabel resultlabel = new JLabel(" Query Result");

    public DualQuery()
    {

    textArea.setText("Query");
    resultpanel.add(resultlabel);
    exe.addActionListener(this);
    file.add(exe);
    jmb.add(file);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane. VERTICAL_SCROLLBAR_ALWAYS);
    querypanel.add(scrollPane);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, querypanel, resultpanel);
    splitPane.setOneTouchExpandable(true);
    getContentPane().add(splitPane);
    setSize(700, 650);// here's the part where i center the jframe on screen
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    }//end of constructor
    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource()==exe){
    //Executing Engine here
    MySQLController mysql = new MySQLController(resultpanel,textArea.getText());

    }
    }//end main
    }

    public class MySQLController(JPanel panel,String query){
    JLabel fname = new JLabel("First Name:");
    JTextField nametf = new JTextField();

    public MySQLControler(){
    panel.add(fname);
    panel.add(namef);
    jpanel.add(fname);
    }

    }
    1. I want the content of the firstname label and text field from the MySQLController class to automatically updated in the DualQuery class when a user click on execute menuitem But its not given me the desired result

    2. Is it possible to make the JTextArea's size adjust automatically when the user adjust the splitpane up and down?

Similar Threads

  1. [SOLVED] I Forgot how to set a size to a JTextArea
    By Java Programmer in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 19th, 2012, 10:08 PM
  2. How to Change JTextArea font, font size and color
    By Flash in forum Java Swing Tutorials
    Replies: 7
    Last Post: January 14th, 2012, 10:47 PM
  3. [SOLVED] Make JTextArea Support HTML
    By bgroenks96 in forum AWT / Java Swing
    Replies: 12
    Last Post: August 28th, 2011, 01:01 PM
  4. Make JTextArea accept input from JButton
    By crazed8s in forum AWT / Java Swing
    Replies: 9
    Last Post: December 5th, 2010, 09:38 PM
  5. How to Change JTextArea font, font size and color
    By Flash in forum Java Code Snippets and Tutorials
    Replies: 4
    Last Post: July 8th, 2008, 01:45 PM