Noob Questions From Nickropheliac: First game String drawing issues

In the single digits, the string is centered. How would I do this for double digits. I was thinking about offsetting x, but… I don’t understand offsets to their full extent. I’m not entirely sure if that would work. I’m too big of a noob, but I’m new and you guys are always willing to help! :smiley:

public void paintComponent(Graphics g) {

		super.paintComponent(g);
		Random rand = new Random();
	
		for (int lineY = 0; lineY < getHeight(); lineY += 50) {
			g.setColor(new Color(rand.nextInt(0xFF4AF6)));
			g.fillRoundRect(400, lineY, 20, 800, 0, 0);
		}

		g.setColor(Color.WHITE);
		g.fillRoundRect(ballX, ballY, 25, 25, 5, 25);
	for (int tick = 0; tick > getHeight(); tick--){
	
            g.setColor(new Color (rand.nextInt(0xFF4AF6)));
	}
	g.setColor(new Color(rand.nextInt(0xFF4AF6)));
	g.fillRoundRect(playerOneX, playerOneY, playerOneWidth,
					playerOneHeight, 50, 5);

			g.fillRoundRect(playerTwoX, playerTwoY, playerTwoWidth,
					playerTwoHeight, 50, 5);
	
			g.setColor(Color.WHITE);
			g.fillRoundRect(335, 180, 150, 150 , 50, 50);
			  g.setFont(new Font(Font.DIALOG, Font.BOLD, 150));
		      String rally = " " + rallyScore;
			  g.setColor(new Color (0xFF2172));
		      g.drawString(rally, 328, 310);
			  g.dispose();	
	}