Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rewrite the following program to create the same user interface. Instead of usin

ID: 3642942 • Letter: R

Question

Rewrite the following program to create the same user interface. Instead of using FlowLayout for the panels, use a GridLayout of two rows and three columns.


import javax.swing.*;
import java.awt.*;

public class LayoutDemo extends JFrame {
JPanel panelOne;
JPanel panelTwo;
JButton btnOne;
JButton btnTwo;
JButton btnThree;
JButton btnFour;
JButton btnFive;
JButton btnSix;

public LayoutDemo() {
setLayout(new FlowLayout());
panelOne = new JPanel();
panelTwo = new JPanel();
btnOne = new JButton("One");
btnTwo = new JButton("Two");
btnThree = new JButton("Three");
btnFour = new JButton("Four");
btnFive = new JButton("Five");
btnSix = new JButton("Six");
panelOne.setLayout(new FlowLayout());
panelTwo.setLayout(new FlowLayout());
panelOne.add(btnOne);
panelOne.add(btnTwo);
panelOne.add(btnThree);
panelTwo.add(btnFour);
panelTwo.add(btnFive);
panelTwo.add(btnSix);
add(panelOne);
add(panelTwo);
setTitle("FlowLayout Demonstration");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(new Dimension(230, 130));
show();
}

public static void main(String[] args) {
new LayoutDemo();
}
}

Explanation / Answer

try following " import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.table.*; import java.util.*; import javax.swing.event.*; class netTable implements ActionListener, TableModelListener { JFrame frame; JTable table; Vector rows,columns; DefaultTableModel tabModel; JScrollPane scrollPane; JLabel lblMessage; JButton cmdLookup, cmdUpdatePlan; JPanel topPanel,mainPanel,buttonPanel; public static void main(String[] args) { netTable t=new netTable(); } netTable() { rows=new Vector(); columns= new Vector(); String[] columnNames = { "ID", "Client", "Plan", "Amount" }; addColumns(columnNames); tabModel=new DefaultTableModel(); tabModel.setDataVector(rows,columns); table = new JTable(tabModel); scrollPane= new JScrollPane(table);//ScrollPane table.setRowSelectionAllowed(false); table.getModel().addTableModelListener(this); topPanel = new JPanel(); lblMessage=new JLabel("Invoices to Update"); topPanel.add(lblMessage); buttonPanel=new JPanel(); cmdLookup=new JButton("Lookup"); cmdUpdatePlan = new JButton("Update Plan"); buttonPanel.add(cmdLookup); buttonPanel.add(cmdUpdatePlan); cmdLookup.addActionListener(this); cmdUpdatePlan.addActionListener(this); mainPanel=new JPanel(); frame=new JFrame("Update Table"); frame.setSize(500,500); frame.setExtendedState(JFrame.ICONIFIED); mainPanel.setLayout(new BorderLayout()); mainPanel.add(topPanel,BorderLayout.NORTH); mainPanel.add(buttonPanel,BorderLayout.CENTER); mainPanel.add(scrollPane,BorderLayout.SOUTH);; topPanel.setBackground(Color.gray); mainPanel.setBackground(Color.white); buttonPanel.setBackground(Color.white); table.getParent().setBackground(Color.black); frame.getContentPane().add(mainPanel); frame.addWindowListener(new WindowCloser()); frame.setVisible(true); } } "

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote