📄 abstractinputtabledialogue.java
字号:
//Vedio rental System Developed by Banu
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class abstractInputTableDialogue extends JDialog implements ListSelectionListener, ActionListener
{
private JList lstTables;
private JScrollPane scrollPane;
protected JTextField txtTable;
protected JButton cmdClick, cmdCancel;
protected JLabel lblStatus;
private JPanel panRoot, panSouthArea, panSelect;
protected String strChosenTable = "";
private String[] strList;
protected String getChosenTable ()
{
return strChosenTable;
}
public abstractInputTableDialogue (JFrame mainApp, String[] strList)
{
super(mainApp, true);
this.strList = strList;
this.setSize(new Dimension(350, 500));
this.setResizable(false);
this.setLayout(new BorderLayout());
lstTables = new JList();
if (!strList[0].equalsIgnoreCase("---"))
{
lstTables.setListData(strList);
lstTables.addListSelectionListener(this);
}
scrollPane = new JScrollPane(lstTables, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setPreferredSize(new Dimension(350, 400));
txtTable = new JTextField("", 15);
lblStatus = new JLabel("Choose a table");
cmdClick = new JButton("");
cmdCancel = new JButton("Cancel");
cmdClick.addActionListener(this);
cmdCancel.addActionListener(this);
panRoot = new JPanel(new BorderLayout());
panSouthArea = new JPanel(new BorderLayout());
panSelect = new JPanel();
this.add(panRoot, BorderLayout.CENTER);
panRoot.add(scrollPane, BorderLayout.NORTH);
panRoot.add(panSouthArea, BorderLayout.SOUTH);
panSouthArea.add(panSelect, BorderLayout.NORTH);
panSelect.add(txtTable);
panSelect.add(cmdClick);
panSelect.add(cmdCancel);
panSouthArea.add(lblStatus, BorderLayout.SOUTH);
panRoot.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
txtTable.requestFocusInWindow();
}
public void valueChanged (ListSelectionEvent e)
{
txtTable.setText((String)lstTables.getSelectedValue());
}
public void actionPerformed (ActionEvent e)
{
}
protected boolean exists (String strTableName)
{
for (int i = 0; i < strList.length; i++)
{
if (strTableName.equalsIgnoreCase(strList[i]))
{
return true;
}
}
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -