*** Please if you want to answere this question, include your program output scr
ID: 653872 • Letter: #
Question
*** Please if you want to answere this question, include your program output screenshot. And follow the requirements please, thanks.****
Design a Java program: A JPanel of dimension 400 X 200. The background is initially displayed as white and there is a line drawn vertically half way through the screen. When a mouse is clicked on the left hand side of the line, the position of the click is shown with a small circle and the background changes to yellow. When a mouse is clicked on the right hand side of the line, the position is shown with a small circle and the background changes to green. Use a JFrame class to display the JPanel class.
Output should be like the pictures below:
Explanation / Answer
private void initComponents() { jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Login"); setAlwaysOnTop(true); setBackground(new java.awt.Color(0, 0, 0)); setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); setResizable(false); jButton1.setText("Login"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(142, 142, 142) .addComponent(jButton1) .addContainerGap(149, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(167, Short.MAX_VALUE) .addComponent(jButton1) .addGap(41, 41, 41)) ); jButton1.getAccessibleContext().setAccessibleName(null); pack(); }//Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.