Sir i have a problem with JScrollPane, it suppose to appear JScrollPane when they reach the limit size, but as you can see nothings happen, can someone help me with this one, that will be appreciated... thx
Output:
import javax.swing.*; import java.awt.*; public class test { static int colsPass = 10, rowsPass = 10; static int fHeight, fWidth; static int[] colsAlign = new int[3]; static int[] rowsAlign = new int[3]; static int set = 0; static int tCell = 0; static int loop1, loop2; public static void main(String[] args){ scrollPane(); } private static void scrollPane() { fWidth = ((colsPass*3)*20)+230; fHeight = (colsPass*20)+200; tCell = rowsPass * colsPass; JFrame frame = new JFrame("test scroll"); frame.setSize(fWidth + 35, fHeight + 120); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(null); panel.setLocation(fWidth, fHeight); frame.add(panel); JPanel panel2 = new JPanel(); panel2.setLayout(null); panel2.setLocation(fWidth, fHeight); JScrollPane scroll = new JScrollPane(panel2); scroll.setBounds(10, 10, fWidth, fHeight); panel.add(scroll); JTextField[] txtArray1 = new JTextField[tCell]; JTextField[] txtArray2 = new JTextField[tCell]; JTextField[] txtArray3 = new JTextField[tCell]; try { rowsAlign[0] = 60; rowsAlign[1] = 60; rowsAlign[2] = 60; for (loop1 = 0; loop1 <= rowsPass-1; loop1++){ colsAlign[0] = 60; colsAlign[1] = (colsPass*25)+100; colsAlign[2] = ((colsPass*2)*25)+140; for (loop2 = 0; loop2 <= colsPass-1; loop2++){ txtArray1[set] = new JTextField(""); txtArray1[set].setBounds(colsAlign[0], rowsAlign[0], 20, 20); panel2.add(txtArray1[set]); colsAlign[0] += 25; txtArray2[set] = new JTextField(""); txtArray2[set].setBounds(colsAlign[1], rowsAlign[1], 20, 20); panel2.add(txtArray2[set]); colsAlign[1] += 25; txtArray3[set] = new JTextField(""); txtArray3[set].setBounds(colsAlign[2], rowsAlign[2], 20, 20); panel2.add(txtArray3[set]); colsAlign[2] += 25; set++; } loop2 = 0; rowsAlign[0] += 25; rowsAlign[1] += 25; rowsAlign[2] += 25; } } catch (Exception e) {} frame.setVisible(true); } }