Skip to main content

Posts

Points with example 1

                 Points in java with example Points The most simple graphics primitive is point. It is a single dot on the window. There is no method to draw a point in Swing. To draw a point, we use the drawLine() method. We use one point twice. package PRACTICEPROGRAM; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.util.Random; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; class DrawPanel extends JPanel {     public void paintComponent(Graphics g) {         super.paintComponent(g);         Graphics2D g2d = (Graphics2D) g;         g2d.setColor(Color.blue);      ...

MVC Example 1

                        Swing MVC Example in java Java Swing first programs In this chapter, we will program our first programs in Swing toolkit. The examples are going  to be very simple. We will cover some basic functionality. Our first example In our first example, we will show a basic window. import javax.swing.JFrame; public class Simple extends JFrame { public Simple() { setSize(300, 200); setTitle("Simple"); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { Simple simple = new Simple(); simple.setVisible(true); } } While this code is very small, the application window can do quite a lot. It can be resized, maximized, minimized. All the complexity that comes with it has been hidden from the application programmer. import javax.swing.JFrame; Here we import the JFrame widget. It is a toplevel container, which is used for plac...

JAVA Swing MVC in java

              JAVA swing Model-View-Controller                                                                  Swing MVC The design of the Swing component classes is loosely based on the Model-View-Controller architecture, or MVC. The model stores the data. The view creates the visual representation from the data in the model. The controller deals with user interaction and modifies the model and/or the view JComponent The basic building block of the entire visual component library of Swing is the JComponent. It's the super class of every component. Swing ...

Swing API Package JAVA

                       Swing API Package The Swing API has 18 public packages: javax.accessibility javax.swing javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi javax.swing.plaf.synth javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree   javax.swing.undo                                                                                FACEBOOK PAGE  :- Practice program -JAVA