Java 类javax.swing.table.DefaultTableCellRenderer 实例源码
项目:PPRCarTrade
文件:TelaBuscarVeiculo.java
public TelaBuscarVeiculo() {
initComponents();
jtb_Veiculos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ButtonGroup group = new ButtonGroup();
group.add(jrb_Marca);
group.add(jrb_Modelo);
group.add(jrb_Ano);
group.add(jrb_MenorPreco);
group.add(jrb_MaiorPreco);
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment( JLabel.CENTER );
jtb_Veiculos.setDefaultRenderer(Object.class, centerRenderer);
}
项目:PPRCarTrade
文件:TelaUsuarioVendas.java
public void atualizaTela(){
meusVeiculos = new ArrayList<>();
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment( JLabel.CENTER );
jtb_Veiculos.setDefaultRenderer(Object.class, centerRenderer);
jtb_Veiculos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
DefaultTableModel model = (DefaultTableModel)jtb_Veiculos.getModel();
model.setRowCount(0);
ArrayList<VendaVeiculo> aux = NegocioFacade.listaVeiculos();
Usuario logado = NegocioFacade.getUsuarioLogado();
for(VendaVeiculo a : aux){
if(a.getProprietario().getCpf().equals(logado.getCpf())){
model.addRow(new Object[]{ a.getVeiculo().getMarca(), a.getVeiculo().getModelo(),
a.getVeiculo().getCor(), a.getVeiculo().getAno(), a.getPreco()});
meusVeiculos.add(a);
}
}
jtb_Veiculos.setModel(model);
}
项目:incubator-netbeans
文件:CoverageReportTopComponent.java
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (value == null) {
return new DefaultTableCellRenderer().getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
}
// This doesn't work in the presence of table row sorting:
//boolean isTotalRow = row == table.getModel().getRowCount()-1;
FileCoverageSummary summary = (FileCoverageSummary) table.getValueAt(row, -1);
boolean isTotalRow = summary == ((CoverageTableModel)table.getModel()).total;
setEmphasize(isTotalRow);
setSelected(isSelected);
float coverage = (Float) value;
setCoveragePercentage(coverage);
//setStats(summary.getLineCount(), summary.getExecutedLineCount(),
// summary.getInferredCount(), summary.getPartialCount());
return this;
}
项目:rapidminer
文件:DatabaseAdvancedConnectionDialog.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if(value instanceof String[]) {
this.box.setModel(new DefaultComboBoxModel((String[])(value)));
this.box.setSelectedItem(((DatabaseAdvancedConnectionDialog.DriverPropertyInfoTableModel)table.getModel()).getComboValue(table.convertRowIndexToModel(row)));
return this.box;
} else {
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(component instanceof DefaultTableCellRenderer && table.convertColumnIndexToModel(column) == 0) {
String tooltip = ((DatabaseAdvancedConnectionDialog.DriverPropertyInfoTableModel)table.getModel()).getTooltip(table.convertRowIndexToModel(row));
tooltip = "<html><div width = 300px>" + tooltip + "</div></html>";
((DefaultTableCellRenderer)component).setToolTipText(tooltip);
}
return component;
}
}
项目:jmt
文件:StationsPanel.java
/**Returns combobox-styled cellrenderer if a multiple choice cell is to be rendered.
* @return cell renderer*/
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
//if this is type column, I must render it as a combo box instead of a jtextfield
if (column == 1) {
if (isLdEnabled()) {
return LD_enabled_StationTypeCell;
} else {
return LD_disabled_StationTypeCell;
}
} else if (column == getColumnCount() - 1) {
return deleteButtonCellRenderer;
} else {
return new DefaultTableCellRenderer();
}
}
项目:jmt
文件:StationsPanel.java
/**Returns combobox-styled cellrenderer if a multiple choice cell is to be rendered.
* @return cell renderer*/
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
//if this is type column, I must render it as a combo box instead of a jtextfield
if (column == 1) {
if (LD_enabled_system) {
return LD_enabled_StationTypeCell;
} else {
return LD_disabled_StationTypeCell;
}
} else if (column == getColumnCount() - 1) {
return deleteButtonCellRenderer;
} else {
return new DefaultTableCellRenderer();
}
}
项目:jmt
文件:PAResultsWindow.java
/**
* The original getCellRenderer method is overwritten, since the table
* displays in red the values that could not be calculated with the requested
* precision
* @param row the row of the cell
* @param column the column of the cell
* @return a the TableCellRenderer for the requested cell (row,column)
*/
public TableCellRenderer getCellRenderer(int row, int column) {
dtcr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
//Component c = null;
Component c;
if (column < values.size()) {
c = dtcr.getTableCellRendererComponent(this, values.get(column), false, false, row, column);
if (!((PAResultsModel.MeasureValueImpl) values.get(column)).isValid()) {
c.setForeground(Color.RED);
} else {
c.setForeground(Color.BLACK);
}
} else {
c = dtcr.getTableCellRendererComponent(this, "-", false, false, row, column);
c.setForeground(Color.BLACK);
}
return dtcr;
}
项目:marathonv5
文件:TableRenderDemo.java
public void setUpSportColumn(JTable table, TableColumn sportColumn) {
// Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("Snowboarding");
comboBox.addItem("Rowing");
comboBox.addItem("Knitting");
comboBox.addItem("Speed reading");
comboBox.addItem("Pool");
comboBox.addItem("None of the above");
sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
// Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
sportColumn.setCellRenderer(renderer);
}
项目:QN-ACTR-Release
文件:StationsPanel.java
/**Returns combobox-styled cellrenderer if a multiple choice cell is to be rendered.
* @return cell renderer*/
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
//if this is type column, I must render it as a combo box instead of a jtextfield
if (column == 1) {
if (LD_enabled_system) {
return LD_enabled_StationTypeCell;
} else {
return LD_disabled_StationTypeCell;
}
} else if (column == getColumnCount() - 1) {
return deleteButtonCellRenderer;
} else {
return new DefaultTableCellRenderer();
}
}
项目:QN-ACTR-Release
文件:StationsPanel.java
/**Returns combobox-styled cellrenderer if a multiple choice cell is to be rendered.
* @return cell renderer*/
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
//if this is type column, I must render it as a combo box instead of a jtextfield
if (column == 1) {
if (LD_enabled_system) {
return LD_enabled_StationTypeCell;
} else {
return LD_disabled_StationTypeCell;
}
} else if (column == getColumnCount() - 1) {
return deleteButtonCellRenderer;
} else {
return new DefaultTableCellRenderer();
}
}
项目:QN-ACTR-Release
文件:PAResultsWindow.java
/**
* The original getCellRenderer method is overwritten, since the table
* displays in red the values that could not be calculated with the requested
* precision
* @param row the row of the cell
* @param column the column of the cell
* @return a the TableCellRenderer for the requested cell (row,column)
*/
public TableCellRenderer getCellRenderer(int row, int column) {
dtcr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
//Component c = null;
Component c;
if (column < values.size()) {
c = dtcr.getTableCellRendererComponent(this, values.get(column), false, false, row, column);
//if (!((Boolean)(validities.get(column))).booleanValue()) {
if (!((PAResultsModel.MeasureValueImpl) values.get(column)).isValid()) {
c.setForeground(Color.RED);
} else {
c.setForeground(Color.BLACK);
}
} else {
c = dtcr.getTableCellRendererComponent(this, "-", false, false, row, column);
c.setForeground(Color.BLACK);
}
return dtcr;
}
项目:ramus
文件:PriceAttributePlugin.java
@Override
public TableCellRenderer getTableCellRenderer(Engine engine,
AccessRules rules, Attribute attribute) {
return new DefaultTableCellRenderer() {
/**
*
*/
private static final long serialVersionUID = -7922052040779840252L;
{
setHorizontalAlignment(SwingConstants.RIGHT);
}
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
Component component = super.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, column);
if (value != null)
((JLabel) component).setText(format(value));
return component;
}
};
}
项目:ramus
文件:EmptyPlugin.java
@Override
public TableCellRenderer getTableCellRenderer(Engine engine,
AccessRules rules, Attribute attribute) {
return new DefaultTableCellRenderer() {
/**
*
*/
private static final long serialVersionUID = 6973511367750673696L;
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
return super.getTableCellRendererComponent(table,
MessageFormat
.format(GlobalResourcesManager
.getString("EmptyPlugin.Name"), type
.toString()), isSelected, hasFocus,
row, column);
}
};
}
项目:PwnBack
文件:PwnBackTable.java
PwnBackTable(PwnBackMediator mediator) {
this.mediator = mediator;
logTable.getModel().addTableModelListener(e -> {
if (TableUtilities.isInsert(e)) {
int viewRow = logTable.convertRowIndexToView(e.getFirstRow());
logTable.scrollRectToVisible(logTable.getCellRect(viewRow, 0, true));
}
});
logTable.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setForeground(mediator.getLog().get(row).getRowColor());
return c;
}
});
}
项目:openjdk-jdk10
文件:bug6442918a.java
private static void runTest() {
JDialog dialog = Util
.createModalDialogWithPassFailButtons("Empty header showing \"...\"");
String[] columnNames = {"", "", "", "", "Testing"};
String[][] data = {{"1", "2", "3", "4", "5"}};
JTable table = new JTable(data, columnNames);
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
int tableCellWidth = renderer.getFontMetrics(renderer.getFont())
.stringWidth("test");
table.setPreferredScrollableViewportSize(new Dimension(
5 * tableCellWidth, 50));
JPanel p = new JPanel();
p.add(new JScrollPane(table));
dialog.add(p, BorderLayout.NORTH);
JTextArea area = new JTextArea();
String txt = "\nInstructions:\n\n";
txt += "Only the last column header should show \"...\".";
area.setText(txt);
dialog.add(new JScrollPane(area), BorderLayout.CENTER);
dialog.pack();
dialog.setVisible(true);
}
项目:openjdk9
文件:bug6442918a.java
private static void runTest() {
JDialog dialog = Util
.createModalDialogWithPassFailButtons("Empty header showing \"...\"");
String[] columnNames = {"", "", "", "", "Testing"};
String[][] data = {{"1", "2", "3", "4", "5"}};
JTable table = new JTable(data, columnNames);
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
int tableCellWidth = renderer.getFontMetrics(renderer.getFont())
.stringWidth("test");
table.setPreferredScrollableViewportSize(new Dimension(
5 * tableCellWidth, 50));
JPanel p = new JPanel();
p.add(new JScrollPane(table));
dialog.add(p, BorderLayout.NORTH);
JTextArea area = new JTextArea();
String txt = "\nInstructions:\n\n";
txt += "Only the last column header should show \"...\".";
area.setText(txt);
dialog.add(new JScrollPane(area), BorderLayout.CENTER);
dialog.pack();
dialog.setVisible(true);
}
项目:Hanze-TwoPlayerGameServer
文件:MatchTable.java
private TableCellRenderer createTableCellRenderer() {
return new DefaultTableCellRenderer() {
private static final long serialVersionUID = 0L;
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Match match = (Match) value;
String text = "";
if(column == 0) {
text = Integer.toString(match.getMatchNumber());
} else if(column == 1) {
text = match.getGameType();
} else if(column == 2) {
text = match.getPlayerOne().getPlayerName();
} else if(column == 3) {
text = match.getPlayerTwo().getPlayerName();
}
return super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
}
};
}
项目:PanamaHitek_Arduino
文件:PanamaHitek_DataBuffer.java
/**
* Construye la JTable donde se almacenan los datos
*/
private void buildTable() {
if (!tableFlag) {
table = new JTable();
String[] headerTitles = new String[variableList.size()];
Object[][] tableContent = new Object[mainBuffer.get(0).size()][variableList.size()];
for (int i = 0; i < variableList.size(); i++) {
headerTitles[i] = variableList.get(i);
for (int j = 0; j < mainBuffer.get(i).size(); j++) {
tableContent[j][i] = mainBuffer.get(i).get(j);
}
}
table.setModel(new DefaultTableModel(tableContent, headerTitles));
DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer();
renderer.setHorizontalAlignment(0);
table.getTableHeader().setReorderingAllowed(false);
((DefaultTableModel) table.getModel()).addTableModelListener(tableModelListener);
}
}
项目:LGoodDatePicker
文件:DateTableEditor.java
/**
* Constructor, with options.
*
* @param autoAdjustMinimumTableRowHeight Set this to true to have this class automatically
* adjust the the minimum row height of all rows in the table, the first time that a
* DateTableEditor is displayed. Set this to false to turn off any row height adjustments. The
* default value is true.
*
* @param matchTableBackgroundColor This indicates whether this table editor should set the
* picker text area background color to match the background color of the table. The default
* value is true.
*
* @param matchTableSelectionBackgroundColor This indicates whether this table editor should set
* the picker text area background color to match the background color of the table selection
* (when selected). The default value is true.
*/
public DateTableEditor(boolean autoAdjustMinimumTableRowHeight,
boolean matchTableBackgroundColor, boolean matchTableSelectionBackgroundColor) {
// Save the constructor parameters.
this.autoAdjustMinimumTableRowHeight = autoAdjustMinimumTableRowHeight;
this.matchTableBackgroundColor = matchTableBackgroundColor;
this.matchTableSelectionBackgroundColor = matchTableSelectionBackgroundColor;
// Create the borders that should be used for focused and unfocused cells.
JLabel exampleDefaultRenderer = (JLabel) new DefaultTableCellRenderer().
getTableCellRendererComponent(new JTable(), "", true, true, 0, 0);
borderFocusedCell = exampleDefaultRenderer.getBorder();
borderUnfocusedCell = new EmptyBorder(1, 1, 1, 1);
// Create and set up the date picker.
datePicker = new DatePicker();
datePicker.setBorder(borderUnfocusedCell);
datePicker.getComponentDateTextField().setBorder(null);
// Adjust any needed date picker settings.
DatePickerSettings settings = datePicker.getSettings();
settings.setGapBeforeButtonPixels(0);
settings.setSizeTextFieldMinimumWidthDefaultOverride(false);
settings.setSizeTextFieldMinimumWidth(20);
// Calculate and store the minimum row height needed to display the date picker.
minimumRowHeightInPixels = (datePicker.getPreferredSize().height + 1);
}
项目:LGoodDatePicker
文件:TimeTableEditor.java
/**
* Constructor, with options.
*
* @param autoAdjustMinimumTableRowHeight Set this to true to have this class automatically
* adjust the the minimum row height of all rows in the table, the first time that a
* TimeTableEditor is displayed. Set this to false to turn off any row height adjustments. The
* default value is true.
*/
public TimeTableEditor(boolean autoAdjustMinimumTableRowHeight,
boolean matchTableBackgroundColor, boolean matchTableSelectionBackgroundColor) {
// Save the constructor parameters.
this.autoAdjustMinimumTableRowHeight = autoAdjustMinimumTableRowHeight;
this.matchTableBackgroundColor = matchTableBackgroundColor;
this.matchTableSelectionBackgroundColor = matchTableSelectionBackgroundColor;
// Create the borders that should be used for focused and unfocused cells.
JLabel exampleDefaultRenderer = (JLabel) new DefaultTableCellRenderer().
getTableCellRendererComponent(new JTable(), "", true, true, 0, 0);
borderFocusedCell = exampleDefaultRenderer.getBorder();
borderUnfocusedCell = new EmptyBorder(1, 1, 1, 1);
// Create and set up the time picker.
timePicker = new TimePicker();
timePicker.setEnableArrowKeys(false);
timePicker.setBorder(borderUnfocusedCell);
timePicker.getComponentTimeTextField().setBorder(null);
// Adjust any needed time picker settings.
TimePickerSettings settings = timePicker.getSettings();
settings.setGapBeforeButtonPixels(0);
settings.setSizeTextFieldMinimumWidthDefaultOverride(false);
settings.setSizeTextFieldMinimumWidth(20);
// Calculate and store the minimum row height needed to display the time picker.
minimumRowHeightInPixels = (timePicker.getPreferredSize().height + 1);
}
项目:SweetHome3D
文件:FurnitureTable.java
/**
* Returns a renderer that displays the level name of a piece of furniture.
*/
private TableCellRenderer getLevelRenderer()
{
return new DefaultTableCellRenderer()
{
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column)
{
HomePieceOfFurniture piece = (HomePieceOfFurniture) value;
Level level = value != null ? piece.getLevel() : null;
return super.getTableCellRendererComponent(table, level != null ? level.getName() : null,
isSelected, hasFocus, row, column);
}
};
}
项目:SweetHome3D
文件:FurnitureTable.java
/**
* Returns a renderer that displays the angle property of a piece of furniture.
*/
private TableCellRenderer getAngleRenderer()
{
return new DefaultTableCellRenderer()
{
private TableCellRenderer integerRenderer;
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column)
{
if (this.integerRenderer == null)
{
this.integerRenderer = table.getDefaultRenderer(Integer.class);
}
Integer angle = value != null
? (int) (Math.round(Math.toDegrees(((HomePieceOfFurniture) value).getAngle()) + 360) % 360)
: null;
return this.integerRenderer.getTableCellRendererComponent(table, angle, isSelected, hasFocus, row,
column);
}
};
}
项目:SweetHome3D
文件:FurnitureTable.java
/**
* Returns a renderer that displays the value added tax percentage property of a piece of furniture.
*/
private TableCellRenderer getValueAddedTaxPercentageRenderer()
{
return new DefaultTableCellRenderer()
{
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column)
{
BigDecimal valueAddedTaxPercentage = value != null
? ((HomePieceOfFurniture) value).getValueAddedTaxPercentage() : null;
if (valueAddedTaxPercentage != null)
{
NumberFormat percentInstance = DecimalFormat.getPercentInstance();
percentInstance.setMinimumFractionDigits(valueAddedTaxPercentage.scale() - 2);
value = percentInstance.format(valueAddedTaxPercentage);
}
else
{
value = null;
}
setHorizontalAlignment(JLabel.RIGHT);
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
};
}
项目:intellij-ce-playground
文件:PluginManagerColumnInfo.java
public TableCellRenderer getRenderer(IdeaPluginDescriptor o) {
if (columnIdx == COLUMN_RATE) {
return new DefaultTableCellRenderer(){
private RatesPanel myPanel = new RatesPanel();
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final Component orig = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
myPanel.setBackground(orig.getBackground());
if (value != null) {
myPanel.setRate((String)value);
}
return myPanel;
}
};
}
return new PluginTableCellRenderer((PluginNode)o);
}
项目:intellij-ce-playground
文件:ManageCodeStyleSchemesDialog.java
private MySchemesTable() {
myFixedItemsRenderer = new DefaultTableCellRenderer() {
@NotNull
@Override
public Component getTableCellRendererComponent(@NotNull JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
Component defaultComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof CodeStyleScheme) {
CodeStyleScheme scheme = (CodeStyleScheme)value;
if (scheme.isDefault() || myModel.isProjectScheme(scheme)) {
defaultComponent.setFont(defaultComponent.getFont().deriveFont(Font.BOLD));
}
}
return defaultComponent;
}
};
}
项目:intellij-ce-playground
文件:ModulesToImportDialog.java
private void setModuleNameCellRenderer() {
TableColumn column = getColumnModel().getColumn(MODULE_NAME_COLUMN);
column.setCellRenderer(new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int rowIndex,
int columnIndex) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, columnIndex);
if (c instanceof JLabel && value instanceof ModuleRow) {
JLabel label = (JLabel)c;
ModuleRow row = (ModuleRow)value;
label.setIcon(row.icon);
label.setText(getNameOf(row.module));
}
return c;
}
});
}
项目:intellij-ce-playground
文件:ProjectSettingsPanel.java
public TableCellRenderer getRenderer(final ScopeSetting mapping) {
return new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value == null) {
setText("");
}
else {
final String scopeName = ((NamedScope)value).getName();
if (!isSelected) {
final NamedScope scope = NamedScopesHolder.getScope(myProject, scopeName);
if (scope == null) setForeground(JBColor.RED);
}
setText(scopeName);
}
return this;
}
};
}
项目:dummyOptNode
文件:NeFrame.java
/**
* Create a pane that displays Information Model ID list.
*
* @param portList Ports
* @return The pane that displays Information Model ID list
*/
private JScrollPane createInformationModelIdListPane(List<Port> portList) {
Collections.sort(portList, new PortComparator());
Object[] columnNames = INFORMATION_MODEL_ID_COLNAME_LIST.toArray();
DefaultTableModel tableModel = new DefaultTableModel(columnNames, 0);
for (Port port : portList) {
Port[] column = { port, port };
tableModel.addRow(column);
}
JTable informationModeldTable = new JTable(tableModel);
informationModeldTable.getTableHeader().setBackground(Color.WHITE);
DefaultTableCellRenderer renderer = new InformationModelIdRenderer();
renderer.setHorizontalAlignment(SwingConstants.CENTER);
informationModeldTable.setDefaultRenderer(Object.class, renderer);
JScrollPane informationModelIdPane = new JScrollPane();
informationModelIdPane.getViewport().setView(informationModeldTable);
informationModelIdPane.setPreferredSize(new Dimension(
informationModelIdPane.getPreferredSize().width, TABLE_HEIGHT));
return informationModelIdPane;
}
项目:SE2
文件:BasicDataManagePanel.java
private void setTableColor(){
tcr = new DefaultTableCellRenderer(){
private static final long serialVersionUID = 6L;
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
if (row % 2 == 0)
setBackground(Color.cyan);
else
setBackground(Color.white);
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
};
}
项目:SE2
文件:ReceiptPanel_new.java
private void setTableColor(){
tcr = new DefaultTableCellRenderer(){
/**
*
*/
private static final long serialVersionUID = 1L;
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
if (row % 2 == 0)
setBackground(Color.cyan);
else
setBackground(Color.white);
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
};
}
项目:SE2
文件:InitialStockPanel_new.java
public void setTableColor(){
tcr = new DefaultTableCellRenderer(){
private static final long serialVersionUID = 1L;
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
if (row % 2 == 0)
setBackground(Color.cyan);
else
setBackground(Color.white);
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
};
}
项目:Impro-Visor
文件:ThemeWeaver.java
public void setTableColumnWidths()
{
for( int j = 0; j < soloTableModel.getColumnCount(); j++ )
{
soloTable.getColumnModel().getColumn(j).
setPreferredWidth(soloTableModel.getColumnWidths(j));
}
for( int j = 0; j < soloTableModel.getColumnCount(); j++ )
{
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(soloTableModel.getColumnAdjustments(j));
soloTable.getColumnModel().getColumn(j).setCellRenderer(renderer);
}
}
项目:mars-sim
文件:TableRenderDemo.java
public void setUpSportColumn(JTable table,
TableColumn sportColumn) {
//Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("Snowboarding");
comboBox.addItem("Rowing");
comboBox.addItem("Knitting");
comboBox.addItem("Speed reading");
comboBox.addItem("Pool");
comboBox.addItem("None of the above");
sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
sportColumn.setCellRenderer(renderer);
}
项目:Borneo-Bengkel
文件:fSatuan.java
private void lebarkolom(){
TableColumn column;
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
column = jTable1.getColumnModel().getColumn(0);
column.setPreferredWidth(40);
column = jTable1.getColumnModel().getColumn(1);
column.setPreferredWidth(150);
column = jTable1.getColumnModel().getColumn(2);
column.setPreferredWidth(300);
//rata tengah untuk judul kolom
DefaultTableCellHeaderRenderer tengahRenderer = new DefaultTableCellHeaderRenderer();
tengahRenderer.setHorizontalAlignment(DefaultTableCellHeaderRenderer.CENTER);
jTable1.getColumnModel().getColumn(0).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(1).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(2).setHeaderRenderer(tengahRenderer);
//rata tengah untuk kolom 0 (ID Kategori)
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
jTable1.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);
}
项目:eurocarbdb
文件:AccessControlDialog.java
public GranteeTable(GranteeTableModel granteeTableModel) {
super();
sorter = new TableSorter(granteeTableModel);
this.setModel(sorter);
sorter.setTableHeader(this.getTableHeader());
getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
getSelectionModel().addListSelectionListener(this);
DefaultCellEditor groupCellEditor = new DefaultCellEditor(groupGranteeComboBox);
groupCellEditor.setClickCountToStart(2);
setDefaultEditor(GroupGrantee.class, groupCellEditor);
setDefaultRenderer(GroupGrantee.class, new DefaultTableCellRenderer() {
private static final long serialVersionUID = 4938391147702620699L;
public Component getTableCellRendererComponent(JTable arg0, Object value, boolean arg2, boolean arg3, int arg4, int arg5) {
GroupGrantee groupGrantee = (GroupGrantee) value;
return super.getTableCellRendererComponent(arg0, groupGrantee.getIdentifier(), arg2, arg3, arg4, arg5);
}
});
DefaultCellEditor permissionCellEditor = new DefaultCellEditor(permissionComboBox);
permissionCellEditor.setClickCountToStart(2);
setDefaultEditor(Permission.class, permissionCellEditor);
}
项目:swingx
文件:DNDRendererVisualCheck.java
/**
* Issue #370-swingx: drop-on not shown correctly.
*
* Check core default renderer as renderer in Table.
*/
public void interactiveDropOnVisualsTable() {
JXTable xTable = new JXTable(new AncientSwingTeam());
installTransferHandler(xTable);
xTable.getColumn(0).setCellRenderer(new DefaultTableCellRenderer());
JTable table = new JTable(new AncientSwingTeam());
installTransferHandler(table);
// xTable.setDropMode(DropMode.USE_SELECTION);
// table.setDropMode(DropMode.USE_SELECTION);
xTable.setDropMode(DropMode.ON_OR_INSERT);
table.setDropMode(DropMode.ON_OR_INSERT);
JXFrame frame = wrapWithScrollingInFrame(xTable, table,
"JXTable (first column core renderer) <-> core table: drop-on appearance");
JTextField textField = new JTextField("drag me over first column....");
textField.setDragEnabled(true);
addStatusComponent(frame, textField);
show(frame);
}
项目:swingx
文件:JXTableHeaderTest.java
/**
* test doc'ed xheader.getToolTipText(MouseEvent) behaviour.
*
*/
@Test
public void testColumnToolTip() {
JXTable table = new JXTable(10, 2);
TableColumnExt columnExt = table.getColumnExt(0);
JXTableHeader tableHeader = (JXTableHeader) table.getTableHeader();
MouseEvent event = new MouseEvent(tableHeader, 0,
0, 0, 40, 5, 0, false);
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
String rendererToolTip = "rendererToolTip";
renderer.setToolTipText(rendererToolTip);
columnExt.setHeaderRenderer(renderer);
assertEquals(rendererToolTip, tableHeader.getToolTipText(event));
String columnToolTip = "columnToolTip";
columnExt.setToolTipText(columnToolTip);
assertEquals(columnToolTip, tableHeader.getToolTipText(event));
}
项目:xdat
文件:DataSheetTablePanel.java
/**
* Updates the table model.
*/
public void updateRunsTableModel() {
DataSheet dataSheet = this.mainWindow.getCurrentSession().getCurrentDataSheet();
if (dataSheet != null) {
DataSheetTableColumnModel cm = new DataSheetTableColumnModel(this.mainWindow, dataSheet);
DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
cellRenderer.setHorizontalAlignment(SwingConstants.CENTER);
TableColumn idCol = new TableColumn(0, 30, cellRenderer, new DefaultCellEditor(new JTextField()));
idCol.setHeaderValue("#");
idCol.setResizable(true);
cm.addColumn(idCol);
TableColumn[] cols = new TableColumn[dataSheet.getParameterCount() + 1];
for (int colIndex = 1; colIndex <= dataSheet.getParameterCount(); colIndex++) {
cols[colIndex] = new TableColumn(colIndex, 100, cellRenderer, new DefaultCellEditor(new JTextField()));
cols[colIndex].setHeaderValue(dataSheet.getParameterName(colIndex - 1));
cols[colIndex].setResizable(true);
cm.addColumn(cols[colIndex]);
}
this.dataTable.setColumnModel(cm);
}
}
项目:dsworkbench
文件:SortableTableHeaderRenderer.java
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setBackground(Constants.DS_BACK);
DefaultTableCellRenderer r = ((DefaultTableCellRenderer) c);
r.setText("<html><b>" + r.getText() + "</b></html>");
try {
List<? extends SortKey> sortKeys = table.getRowSorter().getSortKeys();
SortKey key = sortKeys.get(0);
if (column == key.getColumn()) {
r.setIcon(key.getSortOrder() == SortOrder.ASCENDING ? ascIcon : descIcon);
} else {
r.setIcon(null);
}
} catch (Exception e) {
r.setIcon(null);
}
return r;
}
项目:OAT
文件:UiUtil.java
public static void setupColumns(JTable table) {
for (int i = 0; i < table.getColumnCount(); i++) {
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
TableColumn column = table.getColumnModel().getColumn(i);
Class columnClass = table.getColumnClass(i);
String columnName = table.getColumnName(i);
renderer.setToolTipText(columnName);
if (columnClass.getSuperclass().equals(Number.class)) {
renderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT);
}
if (table.isEnabled()) {
if (columnName.equals("Currency")) {
//addComboCell(column, Product.CURRENCIES);
} else if (columnName.equals("Holidays")) {
//column.setCellEditor(new FileChooserCellEditor());
}
}
column.setCellRenderer(renderer);
}
}