|
||
|
|||
|
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: ![]() Java Code
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);
}
}
|
|
||||
|
You can set up a JPanel within a JPanel, for example, the following code will set up two JPanels with dimensions 200x200 adjacent to each other using the BoxLayout which I alluded to above (see How to Use BoxLayout (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container) )
Java Code
Dimension dim = new Dimension(200,200); JPanel panel1 = new JPanel(); panel1.setPreferredSize(dim); JPanel panel2 = new JPanel(); panel2.setPreferredSize(dim); JPanel holder = new JPanel(); holder.setLayout( new BoxLayout( holder, BoxLayout.LINE_AXIS ) ); holder.add(panel1); holder.add(panel2); |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| JScrollPane | MysticDeath | AWT / Java Swing | 1 | 18-02-2010 02:21 AM |
| JTable in JScrollPane | alwayslearner | AWT / Java Swing | 1 | 01-02-2010 02:24 AM |
| JTable in JScrollPane | alwayslearner | File I/O & Other I/O Streams | 0 | 29-01-2010 03:42 PM |
| About Title border in jscrollpane | subhvi | AWT / Java Swing | 2 | 15-12-2009 04:45 AM |
| Data is getting corrupt in Jscrollpane | ruchika | AWT / Java Swing | 0 | 01-09-2009 03:41 PM |
|
100 most searched terms
Search Cloud
|
| 2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? |