Hi, I would need help, pleas. I would like to portray the curve under the specified angles with the repeat and the number of segments. Will you help me please?
now I have this:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
*
* @author martin.juranek
*/
public class Main extends JFrame {
private boolean draw = false;
JPanel paintPanel;
public Main() throws HeadlessException {
JButton jb = new JButton("Cudl");
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
draw = true;
System.out.println("kresli = " + draw);
paintPanel.repaint();
}
});
paintPanel = new JPanel() {
@Override
public void paint(Graphics g) {
super.paint(g);
if (draw) {
g.drawLine(0, 0, 1000, 1000);
} else {
}
}
};
BorderLayout bl = new BorderLayout();
bl.addLayoutComponent(jb, BorderLayout.NORTH);
bl.addLayoutComponent(paintPanel, BorderLayout.CENTER);
getContentPane().add(jb);
getContentPane().add(paintPanel);
setLayout(bl);
paintPanel.setPreferredSize(new Dimension(500, 500));
jb.setPreferredSize(new Dimension(50, 100));
pack();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Main m = new Main();
m.setVisible(true);
}
});
// TODO code application logic here
}
}