Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,128 questions

40,777 answers

573 users

How to draw a bold line with drawLine() function in Java

1 Answer

0 votes
package javaapplication1;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.BasicStroke;

public class Example extends JPanel {
   @Override
   public void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.setColor(Color.green);
      
      Graphics2D g2d = (Graphics2D) g;
      g2d.setStroke(new BasicStroke(3));
      g2d.drawLine(50, 50, 200, 50);
   }

   public static void main(String[] args) {
      JFrame f = new JFrame("Draw With Java");
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.add(new Example());
      f.setSize(300, 350);
      f.setVisible(true);
   }
}
 
/*
run:
 
// see the green bold line on the run screen
 
*/

 





answered Jan 10, 2016 by avibootz

Related questions

...