Salve,
ho provato a cambiare il colore di fondo sia nel JForm che nel JComponent ma non ne vuole sapere mi da sempre il solito grigio?
codice:import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class Graf_01{ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame f = new JFrame("Disegno un ellisse"); f.setBounds(800, 500, 300, 245); f.setBackground(Color.yellow); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new MyComp()); f.setVisible(true); } }); } } class MyComp extends JComponent{ public MyComp(){ setBackground(Color.yellow); } final BasicStroke spessore = new BasicStroke(5.0f); public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d =(Graphics2D)g; g2d.setBackground(Color.yellow); g2d.setStroke(spessore); Ellipse2D.Double fc = new Ellipse2D.Double(95,30,100,150); g2d.draw(fc); } }
In pratica glie l'ho impostato da per tutto ma niente da fare.
f.setBackground(Color.yellow);
setBackground(Color.yellow);
g2d.setBackground(Color.yellow);
Grazie per la pazienza.

Rispondi quotando
