本文整理汇总了Java中javax.swing.JTable.setAutoResizeMode方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setAutoResizeMode方法的具体用法?Java JTable.setAutoResizeMode怎么用?Java JTable.setAutoResizeMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setAutoResizeMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javax.swing.JTable; //导入方法依赖的package包/类
private void init() {
this.setLayout(new BorderLayout());
tableListTable = new JTable(this.tableModel);
tableListTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
tableListTable.setFillsViewportHeight(false);
tableListTable.setDragEnabled(false);
tableListTable.setColumnSelectionAllowed(false);
tableListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
// //
// // Set the column widths
// //
// tableListTable.getColumnModel().getColumn(0).setPreferredWidth(40);
// tableListTable.getColumnModel().getColumn(1).setPreferredWidth(20);
// tableListTable.getColumnModel().getColumn(3).setPreferredWidth(40);
JScrollPane scrollPane = new JScrollPane(tableListTable);
//scrollPane.setPreferredSize(new Dimension(DesignerVisualization.WINDOW_WIDTH, 175));
//scrollPane.setMaximumSize(this.columnSetTable.getPreferredScrollableViewportSize());
this.add(scrollPane, BorderLayout.CENTER);
}
示例2: CourseListPanel
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Create the panel.
*/
public CourseListPanel(String user,ProfessorFrame pf) throws Exception{
setLayout(new BorderLayout(0, 0));
TableCellRenderer buttonRenderer = new ButtonRenderer();
dao = new ProfessorDAO();
model=new tableModelTeach(dao.getAllCourses(user),user,pf);
table = new JTable();
table.setRowHeight(30);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setDefaultRenderer(JButton.class,buttonRenderer);
table.addMouseListener(new JTableButtonMouseListener(table));
table.setModel(model);
JScrollPane scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//resizeColumnWidth(table);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnModel tcm = table.getColumnModel();
tcm.getColumn(0).setPreferredWidth(800);
tcm.getColumn(1).setPreferredWidth(200);
scrollPane.setBounds(10, 57, 1320, 450);
add(scrollPane, BorderLayout.CENTER);
}
示例3: KuCunPanDian
import javax.swing.JTable; //导入方法依赖的package包/类
public KuCunPanDian() {
super();
setMaximizable(true);
setIconifiable(true);
setClosable(true);
getContentPane().setLayout(new GridBagLayout());
setTitle("����̵�");
setBounds(50, 50, 750, 400);
setupComponet(new JLabel("�� �� Ա��"), 0, 0, 1, 0, false);
pdy.setFocusable(false);
pdy.setPreferredSize(new Dimension(120, 21));
setupComponet(pdy, 1, 0, 1, 0, true);
setupComponet(new JLabel("�̵�ʱ�䣺"), 2, 0, 1, 0, false);
pdsj.setFocusable(false);
pdsj.setText(pdDate.toLocaleString());
pdsj.setPreferredSize(new Dimension(180, 21));
setupComponet(pdsj, 3, 0, 1, 1, true);
setupComponet(new JLabel("Ʒ �� ����"), 4, 0, 1, 0, false);
pzs.setFocusable(false);
pzs.setPreferredSize(new Dimension(80, 21));
setupComponet(pzs, 5, 0, 1, 20, true);
table = new JTable();
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
initTable();
JScrollPane scrollPanel = new JScrollPane(table);
scrollPanel.setPreferredSize(new Dimension(700, 300));
setupComponet(scrollPanel, 0, 2, 6, 1, true);
}
示例4: createStatsTable
import javax.swing.JTable; //导入方法依赖的package包/类
private JPanel createStatsTable(String title, Map<String, String> data) {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(new JLabel(title), BorderLayout.PAGE_START);
StatisticsModel model = new StatisticsModel();
model.setData(data);
JTable table = new JTable(model);
table.setAutoCreateColumnsFromModel(true);
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
table.setAutoCreateRowSorter(true);
JScrollPane scrollPane = new JScrollPane(table);
table.addNotify();
scrollPane.getViewport().setOpaque(false);
scrollPane.getColumnHeader().setOpaque(false);
panel.add(scrollPane, BorderLayout.CENTER);
panel.setPreferredSize(new Dimension(300, (data.size()+2)*17));
return panel;
}
示例5: GraphValidationPanel
import javax.swing.JTable; //导入方法依赖的package包/类
public GraphValidationPanel() {
setSize(new Dimension(900, 300));
setPreferredSize(new Dimension(900, 300));
setMinimumSize(new Dimension(450, 300));
setLayout(null);
JLabel lblValidationResults = new JLabel("Validation Results");
lblValidationResults.setBounds(12, 12, 137, 15);
add(lblValidationResults);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(12, 39, 876, 212);
add(scrollPane);
table = new JTable();
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
scrollPane.setViewportView(table);
// btnRevalidate = new JButton("Revalidate");
// btnRevalidate.setBounds(12, 263, 117, 25);
// add(btnRevalidate);
}
示例6: createTable
import javax.swing.JTable; //导入方法依赖的package包/类
public JScrollPane createTable() {
sorter = new TableSorter();
//connect();
//fetch();
// Create the table
JTable table = new JTable(sorter);
// Use a scrollbar, in case there are many columns.
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// Install a mouse listener in the TableHeader as the sorter UI.
sorter.addMouseListenerToHeaderInTable(table);
JScrollPane scrollpane = new JScrollPane(table);
return scrollpane;
}
示例7: jbInit
import javax.swing.JTable; //导入方法依赖的package包/类
void jbInit() throws Exception {
setBorder(BorderList.etchedBorder5);
ActionListener actionEventHandler = new ActionEventHandler();
MouseListener mouseEventHandler = new MouseEventHandler();
addButton = new JButton("Add");
addButton.setActionCommand("Add");
addButton.addActionListener(actionEventHandler);
removeButton = new JButton("Remove");
removeButton.setActionCommand("Remove");
removeButton.addActionListener(actionEventHandler);
//by lila
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.CENTER));
p1.add(addButton);
p1.add(removeButton);
model = new MyFieldTableModel();
fieldTable = new JTable(model);
fieldTable.setRowSelectionAllowed(true);
fieldTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
fieldTable.addMouseListener(mouseEventHandler);
fieldTable.setBorder(BorderList.bebelBorder);
scrollpane = new JScrollPane(fieldTable);
scrollpane.setPreferredSize(new Dimension(550,220));
//by lila
JPanel p2 = new JPanel();
p2.setLayout(new BorderLayout(0,5));
TitledBorder border = new TitledBorder(new EtchedBorder(),"Field Table");
border.setTitleFont(FontList.regularFont);
border.setTitleColor(Color.black);
p2.setBorder(border);
p2.add(p1,BorderLayout.SOUTH);
p2.add(scrollpane,BorderLayout.CENTER);
p2.add(new JPanel(),BorderLayout.EAST);
p2.add(new JPanel(),BorderLayout.WEST);
setLayout(new FlowLayout(FlowLayout.CENTER));
add(p2);
}
示例8: createAddressBalanceTable
import javax.swing.JTable; //导入方法依赖的package包/类
private JTable createAddressBalanceTable(String rowData[][])
throws WalletCallException, IOException, InterruptedException
{
String columnNames[] = { "Balance", "Confirmed?", "Address" };
JTable table = new AddressTable(rowData, columnNames, this.clientCaller);
table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
table.getColumnModel().getColumn(0).setPreferredWidth(160);
table.getColumnModel().getColumn(1).setPreferredWidth(140);
table.getColumnModel().getColumn(2).setPreferredWidth(1000);
return table;
}
示例9: addPropertiesTab
import javax.swing.JTable; //导入方法依赖的package包/类
private void addPropertiesTab() {
if (compNode instanceof ComponentNode) {
Hashtable<String, Object> props = ((ContainerNode) compNode).getProperties();
if (props.size() > 0) {
JTable propTable = new JTable(new MyModel(props));
propTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
tbd.add(PROPERTIES_TAB, new JScrollPane(propTable));
/*
propTable.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
new ComponentBrowser(getOwnr(),
getSelectedNode()).
show();
}
public void mouseExited(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
});
*/
}
}
}
示例10: PanneauCalendrier
import javax.swing.JTable; //导入方法依赖的package包/类
public PanneauCalendrier(Projet projet){
//Affichage de la fenêtre
this.setSize(1500, 800);
this.setLayout(new BorderLayout());
this.setVisible(true);
//Cadre
label = new JLabel();
label.setHorizontalAlignment(SwingConstants.CENTER);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
//Taille du tableau (lignes, colonnes)
//TODO Modifier le nombre de colonnes en fonction de la durée du projet
model = new DefaultTableModel(projet.getLotList().size(),0);
model.addColumn("Lots");
//Ajout des dates dans le tableau
for(String item :projet.getCalendar().getDatesBetween()){
model.addColumn(item);
}
//Ajouter les lignes des lots ordonnés
for (int k = 0; k < projet.getLotList().size(); k++){
//model.addRow(row);
//model.setValueAt(projet.getLotList().get(k).getName(), k, 0);
}
//Colorier les cases du tableau pendant la durée d'un lot
ArrayList<String> projectDuration = projet.getCalendar().getDatesBetween();
ArrayList<String> lotDuration;
String value = "1";
for (int h = 0; h < projet.getLotList().size(); h++){
lotDuration = projet.getLotList().get(h).getDatesBetween();
for (int i = 0; i < projectDuration.size(); i++){
for (int j = 0; j < lotDuration.size(); j++){
if (projectDuration.get(i) == lotDuration.get(j)){
model.setValueAt(value, h, i+1);
}
}
}
}
//Création du tableau
JTable table = new JTable(model);
//Disable réduction des colonnes
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//Barre de défilements
JScrollPane pane = new JScrollPane(table);
this.add(panel, BorderLayout.NORTH);
this.add(pane, BorderLayout.CENTER);
}
示例11: PanelCourses
import javax.swing.JTable; //导入方法依赖的package包/类
public PanelCourses(Student student,CourseOutline courseoutline) throws Exception{
this.co=courseoutline;
setLayout(new BorderLayout(0, 0));
cmdao=new CourseMappingDAO();
/*JScrollPane scrollPane = new JScrollPane();
add(scrollPane, BorderLayout.CENTER);*/
JLabel lblCoursesTaken = new JLabel("Courses Taken");
//scrollPane.setColumnHeaderView(lblCoursesTaken);
StudentCourseOutlineDAO sctodao = new StudentCourseOutlineDAO(student);
ArrayList<String> course = sctodao.Coursedata(student);
/* DefaultListModel<String> model = new DefaultListModel<>();
int size = course.size();
for(int i=0; i<size; i++){
model.addElement(course.get(i));
}
JList list = new JList(model);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent arg0) {
String course_name=(String)list.getSelectedValue();
//System.out.println("Course id is::"+course_name);
//System.out.println("Batch is ::"+student.getBatch());
String path=cmdao.getDirectoryPath(course_name, student.getBatch());
//System.out.println("Path is::"+path);
//System.out.println(path);
co.c_panel.curr_subject=course_name;
try {
co.c_panel.resetPanes(student, path);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
jb=(JLabel)co.panel.getComponent(7);
jb_c=(JLabel)co.panel.getComponent(6);
jb.setVisible(true);
jb_c.setVisible(true);
jb.setText(course_name);
CardLayout card=(CardLayout)co.panel_1.getLayout();
co.panel_2.getComponent(0).setEnabled(true);
card.show(co.panel_1, "CoursePanel");
}
});
scrollPane.setViewportView(list);*/
TableCellRenderer buttonRenderer = new ButtonRenderer();
model=new CourseTableModel(course,this,student);
table = new JTable();
table.setRowHeight(30);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setDefaultRenderer(JButton.class,buttonRenderer);
table.addMouseListener(new JTableButtonMouseListener(table));
table.setModel(model);
JScrollPane scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//resizeColumnWidth(table);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnModel tcm = table.getColumnModel();
tcm.getColumn(0).setPreferredWidth(800);
tcm.getColumn(1).setPreferredWidth(200);
scrollPane.setBounds(10, 57, 1320, 450);
scrollPane.setColumnHeaderView(lblCoursesTaken);
add(scrollPane, BorderLayout.CENTER);
}
示例12: packColumns
import javax.swing.JTable; //导入方法依赖的package包/类
public static void packColumns(JTable table, int margin) {
for (int c = 0; c < table.getColumnCount(); c++) {
packColumn(table, c, 2);
}
table.setAutoResizeMode(table.AUTO_RESIZE_OFF);
}
示例13: KeHuChaXun
import javax.swing.JTable; //导入方法依赖的package包/类
public KeHuChaXun() {
super();
setIconifiable(true);
setClosable(true);
setTitle("�ͻ���Ϣ��ѯ");
getContentPane().setLayout(new GridBagLayout());
setBounds(100, 100, 640, 375);
table = new JTable();
table.setEnabled(false);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
String[] tableHeads = new String[]{"�ͻ�ID", "�ͻ�ȫ��", "�ͻ���ַ", "�ͻ����",
"��������", "�硡����", "��������", "�� ϵ ��", "��ϵ�绰", "E-Mail", "��������",
"�����˺�"};
final DefaultTableModel dftm = (DefaultTableModel) table.getModel();
dftm.setColumnIdentifiers(tableHeads);
final JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setAutoscrolls(true);
final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();
gridBagConstraints_6.weighty = 1.0;
gridBagConstraints_6.insets = new Insets(0, 10, 5, 10);
gridBagConstraints_6.fill = GridBagConstraints.BOTH;
gridBagConstraints_6.gridwidth = 6;
gridBagConstraints_6.gridy = 1;
gridBagConstraints_6.gridx = 0;
getContentPane().add(scrollPane, gridBagConstraints_6);
setupComponet(new JLabel(" ѡ���ѯ������"), 0, 0, 1, 1, false);
conditionBox1 = new JComboBox();
conditionBox1.setModel(new DefaultComboBoxModel(new String[]{"�ͻ�ȫ��",
"�ͻ����"}));
setupComponet(conditionBox1, 1, 0, 1, 30, true);
conditionBox2 = new JComboBox();
conditionBox2.setModel(new DefaultComboBoxModel(
new String[]{"����", "����"}));
setupComponet(conditionBox2, 2, 0, 1, 30, true);
conditionContent = new JTextField();
setupComponet(conditionContent, 3, 0, 1, 140, true);
final JButton queryButton = new JButton();
queryButton.addActionListener(new queryAction(dftm));
queryButton.setText("��ѯ");
setupComponet(queryButton, 4, 0, 1, 1, false);
showAllButton = new JButton();
showAllButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
conditionContent.setText("");
List list = Dao.getKhInfos();
updateTable(list, dftm);
}
});
setupComponet(showAllButton, 5, 0, 1, 1, false);
showAllButton.setText("��ʾȫ������");
}
示例14: ShangPinChaXun
import javax.swing.JTable; //导入方法依赖的package包/类
public ShangPinChaXun() {
super();
setIconifiable(true);
setClosable(true);
setTitle("��Ʒ��Ϣ��ѯ");
getContentPane().setLayout(new GridBagLayout());
setBounds(100, 100, 609, 375);
table = new JTable();
table.setEnabled(false);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
final DefaultTableModel dftm = (DefaultTableModel) table.getModel();
String[] tableHeads = new String[]{"�ͻ�ID", "��Ʒ����", "���", "����", "��λ",
"���", "��װ", "����", "���ĺ�", "��Ӧ��ȫ��", "��ע",};
dftm.setColumnIdentifiers(tableHeads);
final JScrollPane scrollPane = new JScrollPane(table);
final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();
gridBagConstraints_6.weighty = 1.0;
gridBagConstraints_6.anchor = GridBagConstraints.NORTH;
gridBagConstraints_6.insets = new Insets(0, 10, 0, 10);
gridBagConstraints_6.fill = GridBagConstraints.BOTH;
gridBagConstraints_6.gridwidth = 6;
gridBagConstraints_6.gridy = 1;
gridBagConstraints_6.gridx = 0;
getContentPane().add(scrollPane, gridBagConstraints_6);
setupComponet(new JLabel(" ѡ���ѯ������"), 0, 0, 1, 1, false);
conditionName = new JComboBox();
conditionName.setModel(new DefaultComboBoxModel(new String[]{"��Ʒ����",
"��Ӧ��ȫ��", "����", "���"}));
setupComponet(conditionName, 1, 0, 1, 30, true);
conditionOperation = new JComboBox();
conditionOperation.setModel(new DefaultComboBoxModel(new String[]{"����",
"����"}));
setupComponet(conditionOperation, 2, 0, 1, 30, true);
conditionContent = new JTextField();
setupComponet(conditionContent, 3, 0, 1, 140, true);
final JButton queryButton = new JButton();
queryButton.addActionListener(new QueryAction(dftm));
setupComponet(queryButton, 4, 0, 1, 1, false);
queryButton.setText("��ѯ");
final JButton showAllButton = new JButton();
showAllButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
conditionContent.setText("");
List list = Dao.getSpInfos();
updateTable(list, dftm);
}
});
setupComponet(showAllButton, 5, 0, 1, 1, false);
showAllButton.setText("��ʾȫ������");
}
示例15: XiaoShouPaiHang
import javax.swing.JTable; //导入方法依赖的package包/类
public XiaoShouPaiHang() {
setIconifiable(true);
setClosable(true);
setTitle("��������");
getContentPane().setLayout(new GridBagLayout());
setBounds(100, 100, 650, 375);
final JLabel label_1 = new JLabel();
label_1.setText("��");
final GridBagConstraints gridBagConstraints_8 = new GridBagConstraints();
gridBagConstraints_8.anchor = GridBagConstraints.EAST;
gridBagConstraints_8.gridy = 0;
gridBagConstraints_8.gridx = 0;
getContentPane().add(label_1, gridBagConstraints_8);
year = new JComboBox();
for (int i = 1981, j = 0; i <= date.get(Calendar.YEAR) + 1; i++, j++) {
year.addItem(i);
if (i == date.get(Calendar.YEAR))
year.setSelectedIndex(j);
}
year.setPreferredSize(new Dimension(100, 21));
setupComponet(year, 1, 0, 1, 90, true);
setupComponet(new JLabel("��"), 2, 0, 1, 1, false);
month = new JComboBox();
for (int i = 1; i <= 12; i++) {
month.addItem(String.format("%02d", i));
if (date.get(Calendar.MONTH) == i)
month.setSelectedIndex(i - 1);
}
month.setPreferredSize(new Dimension(100, 21));
setupComponet(month, 3, 0, 1, 30, true);
setupComponet(new JLabel(" �·ݵ�������Ϣ����"), 4, 0, 1, 1, false);
condition = new JComboBox();
condition.setModel(new DefaultComboBoxModel(new String[]{"���", "����"}));
setupComponet(condition, 5, 0, 1, 30, true);
setupComponet(new JLabel(" ����"), 6, 0, 1, 1, false);
operation = new JComboBox();
operation.setModel(new DefaultComboBoxModel(
new String[]{"��������", "��������"}));
setupComponet(operation, 7, 0, 1, 30, true);
okButton = new JButton();
okButton.addActionListener(new OkAction());
setupComponet(okButton, 8, 0, 1, 1, false);
okButton.setText("ȷ��");
final JScrollPane scrollPane = new JScrollPane();
final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();
gridBagConstraints_6.weighty = 1.0;
gridBagConstraints_6.anchor = GridBagConstraints.NORTH;
gridBagConstraints_6.insets = new Insets(0, 10, 5, 10);
gridBagConstraints_6.fill = GridBagConstraints.BOTH;
gridBagConstraints_6.gridwidth = 9;
gridBagConstraints_6.gridy = 1;
gridBagConstraints_6.gridx = 0;
getContentPane().add(scrollPane, gridBagConstraints_6);
table = new JTable();
table.setEnabled(false);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
dftm = (DefaultTableModel) table.getModel();
String[] tableHeads = new String[]{"��Ʒ���", "��Ʒ����", "���۽��", "��������",
"���", "����", "��λ", "���", "��װ", "����", "���ĺ�","���","��Ӧ��"};
dftm.setColumnIdentifiers(tableHeads);
scrollPane.setViewportView(table);
}