I made this GUI, used a Panel that contains a Table.
Functionality is fine , but My table's sides are cut , about 5 pixels is hidden from each side of the table.
I tried to increase the size of the panel , but the table just stretches and the sides are still hidden , It's irritating cause Half scrollbar isn't visible , and of the left side the first digit of the numbers isn't visible
can someone run this programe and see what I mean
can someone provide me with a solution ?
Functionality is fine , but My table's sides are cut , about 5 pixels is hidden from each side of the table.
I tried to increase the size of the panel , but the table just stretches and the sides are still hidden , It's irritating cause Half scrollbar isn't visible , and of the left side the first digit of the numbers isn't visible
can someone run this programe and see what I mean
can someone provide me with a solution ?
Code
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ViewRecords extends JFrame
{
private static final long serialVersionUID = 1L;
JTable maintainanceRepariTable;
JTable breakdownRepariTable;
JPanel maintainence;
JPanel breakdown;
private JLabel maintainLabel;
private JLabel breakdownLabel;
public ViewRecords()
{
setLayout(null);
Font font1 = new Font("ARIEL BLACK", Font.PLAIN, 20);
maintainLabel = new JLabel("Maintenance Repair Records");
maintainLabel.setFont(font1);
maintainLabel.setForeground(Color.RED);
maintainLabel.setBounds(10, 10, 500, 20);
breakdownLabel = new JLabel("Breakdown Repair Records");
breakdownLabel.setFont(font1);
breakdownLabel.setForeground(Color.RED);
breakdownLabel.setBounds(10, 360, 500, 20);
String breakdownColumnNames[]={"Job Number", "Date of job", "Car Registration number","Repair Type", "Total charges"};
String maintainanceColumnNames[]={"Job Number", "Date of job", "Car Registration number","Extra Charges", "Total charges"};
Object maintainanceRecords[][]={
{"00","01","02","03","04"},
{"10","11","12","13","14"},
{"20","21","22","23","24"},
{"30","31","32","33","34"},//DUMMY TABLE VALUES
{"40","41","42","43","44"},
{"50","51","52","53","54"},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
};
Object breakdownRecords[][]={
{"00","01","02","03","04"},
{"10","11","12","13","14"},
{"20","21","22","23","24"},
{"30","31","32","33","34"},//DUMMY TABLE VALUES
{"40","41","42","43","44"},
{"50","51","52","53","54"},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
};
maintainanceRepariTable=new JTable(maintainanceRecords,breakdownColumnNames);
maintainanceRepariTable.setPreferredScrollableViewportSize(new Dimension(700,200));
maintainanceRepariTable.setFillsViewportHeight(true);
breakdownRepariTable=new JTable(breakdownRecords,maintainanceColumnNames);
breakdownRepariTable.setPreferredScrollableViewportSize(new Dimension(700,200));
breakdownRepariTable.setFillsViewportHeight(true);
JButton editMaintainanceRecords = new JButton("Edit Maintenance Records");
editMaintainanceRecords.setBounds(730,60,100, 40);
editMaintainanceRecords.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
setVisible(false);
}
});
JButton editBreakdownRecords = new JButton("Edit Breakdown Records");
editBreakdownRecords.setBounds(730,90,100, 40);
editBreakdownRecords.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
setVisible(false);
}
});
JScrollPane scrollPane=new JScrollPane(maintainanceRepariTable);
JScrollPane scrollPaneBreak=new JScrollPane(breakdownRepariTable);
maintainence=new JPanel();
maintainence.setBounds(20,40,700,300);
maintainence.add(scrollPane);
maintainence.add(editMaintainanceRecords);
add(maintainence);
breakdown=new JPanel();
breakdown.setBounds(20,400,700,300);
breakdown.add(scrollPaneBreak);
breakdown.add(editBreakdownRecords);
add(breakdown);
add(maintainLabel);
add(breakdownLabel);
}
public static void main(String args[])
{
ViewRecords viewRecords=new ViewRecords();
viewRecords.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
viewRecords.setSize(750,750);
viewRecords.setVisible(true);
viewRecords.setResizable(true);
viewRecords.setTitle("Maintainance Repair Records.");
viewRecords.setLocationRelativeTo(null);
}
}
