com.pekinsoft.desktop.notifications.support.NotificationsTableColumnModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of application-framework-api Show documentation
Show all versions of application-framework-api Show documentation
A simple platform on which Java/Swing desktop applications may be built.
This updated version has packaged the entire library into a single JAR
file. We have also made the following changes:
ToolBarGenerator should now create ButtonGroups properly for state actions.
ApplicationContext has accessors for the WindowManager, DockingManager,
StatusDisplayer, and ProgressHandler implementations. It defaults to
testing the Application's MainView and the MainView's StatusBar, then
uses the Lookup, if the MainView and its StatusBar do not implement the
desired interfaces.
StatusMessage now uses the com.pekinsoft.desktop.error.ErrorLevel instead
of the java.util.logging.Level, so that the levels will no longer need to
be cast in order to be used.
The newest version!
/*
* Copyright (C) 2024 PekinSOFT Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* *****************************************************************************
* Project : application-management-api
* Class : NotificationsTableColumnModel.java
* Author : Sean Carrick
* Created : Jun 25, 2024
* Modified : Jun 25, 2024
*
* Purpose: See class JavaDoc for explanation
*
* Revision History:
*
* WHEN BY REASON
* ------------ ------------------- -----------------------------------------
* Jun 25, 2024 Sean Carrick Initial creation.
* *****************************************************************************
*/
package com.pekinsoft.desktop.notifications.support;
import com.pekinsoft.framework.Application;
import com.pekinsoft.framework.ResourceMap;
import java.awt.FontMetrics;
import java.util.Objects;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.TableColumn;
/**
*
* @author Sean Carrick <sean at pekinsoft dot com>
*
* @version 1.0
* @since 1.0
*/
public class NotificationsTableColumnModel extends DefaultTableColumnModel {
public NotificationsTableColumnModel (FontMetrics fm) {
Objects.requireNonNull(fm, "The FontMetrics cannot be null.");
resourceMap = Application.getInstance().getContext().getResourceMap(getClass());
int digit = fm.stringWidth("0");
int alpha = fm.stringWidth("W");
addColumn(createColumn(0, 10 * alpha, fm, true,
resourceMap.getString("col0.text")));
addColumn(createColumn(1, 20 * alpha, fm, true,
resourceMap.getString("col1.text")));
addColumn(createColumn(2, 50 * alpha, fm, true,
resourceMap.getString("col2.text")));
addColumn(createColumn(3, 15 * alpha, fm, true,
resourceMap.getString("col3.text")));
}
private TableColumn createColumn(int col, int w, FontMetrics fm,
boolean resizable, String text) {
int textW = fm.stringWidth(text + " ");
if (w < textW) {
w = textW;
}
TableColumn c = new TableColumn(col);
c.setCellRenderer(new NotificationsCellRenderer());
c.setHeaderValue(text);
c.setPreferredWidth(w);
if (!resizable) {
c.setMinWidth(w);
c.setMaxWidth(w);
}
c.setResizable(resizable);
return c;
}
private final ResourceMap resourceMap;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy