Set Upper Left Corner with JPanel
Set Upper Left Corner with JButton
Size of Upper Left Corner
Set Upper Right Corner with JPanel
Set Upper Right Corner with JTable Corner Component
Set Upper Right Corner with JButton
Size of Upper Right Corner
Set Lower Left Corner with JPanel
Set Lower Left Corner with JButton
Size of Lower Left Corner
Set Lower Right Corner with JPanel
Set Lower Right Corner with JButton
Size of Lower Left Corner
Set Upper Left Corner with JButton
Size of Upper Left Corner
Set Upper Right Corner with JPanel
Set Upper Right Corner with JTable Corner Component
Set Upper Right Corner with JButton
Size of Upper Right Corner
Set Lower Left Corner with JPanel
Set Lower Left Corner with JButton
Size of Lower Left Corner
Set Lower Right Corner with JPanel
Set Lower Right Corner with JButton
Size of Lower Left Corner
Set Upper Left Corner with JPanel
JPanel panel = new JPanel();
panel.setBackground(Color.PINK);
jScrollPane1.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, panel);
Set Upper Left Corner with JButton
JButton button = new JButton();
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
addTextToTextArea("Upper Left Corner is a Button\n\n");
}
});
button.setBackground(Color.PINK);
jScrollPane1.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, button);
Size of Upper Left Corner
Component corner = jScrollPane.getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER);
jLabel10.setText("Upper Left Corner: "+corner.getSize().width+"w "+corner.getSize().height+"h");
Set Upper Right Corner with JPanel
JPanel panel = new JPanel();
panel.setBackground(Color.ORANGE);
jScrollPane1.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, panel);
Set Upper Right Corner with JTable Corner Component
if (jScrollPane1.getViewport() != null && jScrollPane1.getViewport().getView() != null) {
if (jScrollPane1.getViewport().getView() instanceof JTable) {
Component corner = (Component) UIManager.get("Table.scrollPaneCornerComponent");
jScrollPane1.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, corner);
}
}
Set Upper Right Corner with JButton
JButton button = new JButton();
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
addTextToTextArea("Upper Right Corner Button\n\n");
}
});
button.setBackground(Color.ORANGE);
jScrollPane1.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, button);
Size of Upper Right Corner
Component corner = jScrollPane.getCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER);
jLabel22.setText("Upper Right Corner: "+corner.getSize().width+"w "+corner.getSize().height+"h");
Set Lower Left Corner with JPanel
JPanel panel = new JPanel();
panel.setBackground(Color.CYAN);
jScrollPane1.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, panel);
Set Lower Left Corner with JButton
JButton button = new JButton();
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
addTextToTextArea("Lower Left Corner Button\n\n");
}
});
button.setBackground(Color.CYAN);
jScrollPane1.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, button);
Size of Lower Left Corner
Component corner = jScrollPane1.getCorner(ScrollPaneConstants.LOWER_LEFT_CORNER);
jLabel28.setText("Lower Left Corner: "+corner.getSize().width+"w "+corner.getSize().height+"h");
Set Lower Right Corner with JPanel
JPanel panel = new JPanel();
panel.setBackground(Color.MAGENTA);
jScrollPane1.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, panel);
Set Lower Right Corner with JButton
JButton button = new JButton();
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
addTextToTextArea("Lower Right Corner Button\n\n");
}
});
button.setBackground(Color.MAGENTA);
jScrollPane1.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, button);
Size of Lower Left Corner
Component corner = jScrollPane1.getCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER);
jLabel25.setText("Lower Left Corner: "+corner.getSize().width+"w "+corner.getSize().height+"h");