Привет!!! есть маленькая проблемка с JTextArea в GridBagLayout-e , с.м. код ниже... | Код | import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*;
public class MyGridBagLayout {
private static JButton button = null; private static JScrollPane scrollPane, scrollPane2 = null; private static JSplitPane splitPane = null; private static JComboBox comboBox = null; private static JLabel label = null; private static JTextField textFeld = null; private static JPanel panel = null; private static JList myList = null; private static ListModel myListModel = null; private static JTextArea myTextArea = null;
public MyGridBagLayout() { }
public static void addComponents(Container pane) { pane.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; comboBox = new JComboBox(); c.insets = new Insets(2, 0, 0, 0); c.anchor = GridBagConstraints.FIRST_LINE_START; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; pane.add(comboBox, c);
button = new JButton("Добавить"); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 0; pane.add(button, c);
button = new JButton("Удалить"); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 2; c.gridy = 0; pane.add(button, c);
panel = new JPanel(); label = new JLabel(); label.setOpaque(true); label.setText("Текст в Label"); panel.add(label); scrollPane = new JScrollPane(); myListModel = new DefaultListModel(); myList = new JList(myListModel); scrollPane.add(myList); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, panel); splitPane.setDividerLocation(150); splitPane.setOneTouchExpandable(true); c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = 3; c.ipady = 100; c.gridx = 0; c.gridy = 1; pane.add(splitPane, c); myTextArea = new JTextArea(); scrollPane2 = new JScrollPane(myTextArea); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 2; pane.add(scrollPane2, c); button = new JButton("Завершить"); c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 1.0; c.ipady = 0; c.gridx = 2; c.gridy = 3; pane.add(button, c); }
public static void main(String[] args) { JFrame frame = new JFrame("Тренировка"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addComponents(frame.getContentPane()); frame.pack(); frame.setVisible(true); } }
|
проблемка вот в чём, я хочу что бы при разтяжке формы, увеличивался бы и размер JTextArea... то есть, что бы она разтягивалась и стягивалась... а чего то не получается...
|