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
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.
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
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!
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
[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?