The below code places my 8 shapes in 8 distinct positions.
Shape aShape = new RoundRectangle2D.Double(60,112,310,60,10,10);
Shape bShape = new RoundRectangle2D.Double(60,194,310,60,10,10);
Shape cShape = new RoundRectangle2D.Double(60,276,310,60,10,10);
Shape dShape = new RoundRectangle2D.Double(60,358,310,60,10,10);
Shape eShape = new RoundRectangle2D.Double(60,440,310,60,10,10);
Shape fShape = new RoundRectangle2D.Double(60,522,310,60,10,10);
Shape gShape = new RoundRectangle2D.Double(60,604,310,60,10,10);
Shape hShape = new RoundRectangle2D.Double(60,686,310,60,10,10);
I have hardcoded the position of Font also in the shape.
graphics2D.setStroke(new BasicStroke(borderThickness));
graphics2D.setColor(Color.WHITE);
graphics2D.draw(aShape);
graphics2D.setStroke(oldStroke);
graphics2D.setColor(color);
graphics2D.fill(aShape);
Font aFont = new Font("Serif", Font.PLAIN,25);
graphics2D.setFont(aFont);
graphics2D.setColor(Color.WHITE);
graphics2D.drawString(ProjectConstants.A_KEY, 80,148);
But now I want to show only 4 at a time and introduce scrolling. Since the X and Y positions are hardcoded I am clueless as to how will I scroll my shapes ?
Can someone share some insights on how to dynamically load my graphical shapes and place it in a proper position when Scrolled ?
What I have tried:
I tried to put 4 shapes in one panel and another 4 shapes in another panel, and tried to introduce Scrolling, but that would replace 4 shapes in one scroll.