import java.awt.*; import java.awt.geom.*; import javax.swing.*; class JogDial extends JComponent { public static final int WIDTH = 400; public static final int HEIGHT = 200; public static final int OFFSET = 10; public static final int BAR_THICKNESS = 15; public static final int LINE_DIFFERENCE = 5; public static final int BEAD_WIDTH = 10; public static final int BEAD_HEIGHT = 25; protected int[] values = {-2,-1,0,1,2}; protected int bead_x = WIDTH/2; protected int bead_y = OFFSET + (BAR_THICKNESS/2); public JogDial() { super(); } public Dimension getMinimumSize() { return(new Dimension(WIDTH,HEIGHT)); } public Dimension getPreferredSize() { return(this.getMinimumSize()); } public void drawBead(Graphics2D g2) { Rectangle bead = new Rectangle(bead_x - (this.BEAD_WIDTH/2), bead_y -(this.BEAD_HEIGHT/2), BEAD_WIDTH, BEAD_HEIGHT); g2.setColor(Color.gray); g2.fill(bead); g2.setColor(Color.black); g2.draw(bead); } public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); // Polygon p = new Polygon(); // p.addPoint(x,y); Font font = new Font("Helvetica", Font.BOLD, 14); FontMetrics metrics = g2.getFontMetrics(font); Rectangle bar = new Rectangle(OFFSET,OFFSET,size.width-2*OFFSET,BAR_THICKNESS); g2.setColor(Color.black); g2.setFont(font); int segment_size = bar.width / (values.length - 1); for (int i=0; i