Posts

Showing posts with the label java swing

Quantum Internet Benefits

Image
  The quantum internet is a network of quantum computers that are connected together using quantum communication. It has the potential to revolutionize many industries, including: Secure communications: The quantum internet would be inherently secure, as it would be impossible to eavesdrop on quantum communications without being detected. This could be used for applications such as secure financial transactions, government communications, and military applications. Quantum computing: The quantum internet would allow quantum computers to be connected together, which would allow them to solve problems that are currently impossible for classical computers. This could be used for applications such as drug discovery, financial modeling, artificial intelligence, and materials science. Quantum sensors: The quantum internet could be used to connect quantum sensors together, which would allow them to create a global network of sensors that could be used to monitor the environment, detect earthq

Java Swing MySql JDBC: insert data into database

Image
Program import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; public class insertswing implements ActionListener {   JFrame fr;JPanel po;   JLabel l1,l2,main;   JTextField tf1,tf2;   GridBagConstraints gbc;   GridBagLayout go;   JButton ok,exit; public insertswing(){ fr=new JFrame("New User Data "); Font f=new Font("Verdana",Font.BOLD,24); po=new JPanel(); fr.getContentPane().add(po); fr.setVisible(true); fr.setSize(1024,768); fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); po.setBackground(Color.WHITE); go=new GridBagLayout(); gbc=new GridBagConstraints(); po.setLayout(go); main=new JLabel("Enter User Details "); main.setFont(f); l1=new JLabel("Name  :");tf1=new JTextField(20); l2=new JLabel("User Name  :");tf2=new JTextField(20); ok=new JButton("Accept"); exit=new JButton("Exit"); gbc.anchor=GridBagConstraints.NORTH;gbc.gridx=5;gbc.gridy=0; go.s

Java Program: File I/O Fileoutputstream to create file

Image
Program import java.io.*; public class createfile {     public static void main(String[] args)     {         try         {         createfile();         }         catch(Exception ex)         {             System.out.println("File Exceptio occured");         }         }     public static void createfile() throws java.io.IOException     {         DataInputStream d=new DataInputStream(System.in);         FileOutputStream f=new FileOutputStream("jack.txt",true);         BufferedOutputStream b=new BufferedOutputStream(f,1024);         System.out.println("Enter $ at the end to finish text");         char c;         while((c=(char)d.read())!='$')         {             b.write(c);                   }         b.close();     } } Output

Java Program: Thread in swing implements Runnable interface and SwingUtilities

Image
Program import javax.swing.*; public class SwingThread extends JFrame {     public static void main(String[] args) {     SwingUtilities.invokeLater(new Runnable() {       @Override       public void run() {         final JFrame f = new JFrame("Swing using Thread Frame 1");         f.setSize(600, 400);         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         f.setVisible(true);               final JFrame fr = new JFrame("Swing using Thread Frame 2");         fr.setSize(600, 600);         fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         fr.setVisible(true);       }     });     }   } Output:

Java Swing Full Screen window Application without Maximize, Minimize, Exit Buttons

Image
Code For FullScreen Java Swing Desktop Application package fullscreen; import java.awt.Toolkit; import javax.swing.JFrame; public class FullScreen extends JFrame { /** * full screen code using Java Swing component JFrame */ static JFrame f= new FullScreen(); public FullScreen() { setUndecorated(true); //removing Max, min, Exit buttons setSize(Toolkit.getDefaultToolkit().getScreenSize()); //set window size as full screen setVisible(true); } public static void main(String[] args) { // no code here } } Output Screen