1. Swing component that replaces java.awt.Choice? coderanch.com |
2. removing one component and replacing it with another coderanch.com |
3. GridBag Problem (Replacing Component) coderanch.comimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class GridBagTest implements ActionListener { JTextField textField; JPanel panel; int count = 0; public void actionPerformed(ActionEvent e) { Component c = panel.getComponent(2); GridBagLayout layout = (GridBagLayout)panel.getLayout(); GridBagConstraints gbc = layout.getConstraints(c); panel.remove(c); if(c == textField) { JButton button = new JButton("button " + ++count); layout.setConstraints(button, gbc); panel.add(button, 2); } else { layout.setConstraints(textField, gbc); panel.add(textField, 2); ... |