use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class NetworkMainPanel method getRootNetworkScroll.
JScrollPane getRootNetworkScroll() {
if (rootNetworkScroll == null) {
rootNetworkScroll = new JScrollPane(getRootNetworkListPanel());
rootNetworkScroll.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
getRootNetworkListPanel().updateScrollableTracksViewportHeight();
}
});
rootNetworkScroll.setMinimumSize(new Dimension(280, 160));
rootNetworkScroll.setPreferredSize(new Dimension(380, 420));
}
return rootNetworkScroll;
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class RootNetworkPanel method getSubNetListPanel.
private JPanel getSubNetListPanel() {
if (subNetListPanel == null) {
subNetListPanel = new JPanel();
subNetListPanel.setBackground(UIManager.getColor("Table.background"));
subNetListPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIManager.getColor("TableHeader.background")));
subNetListPanel.setVisible(false);
subNetListPanel.setLayout(new BoxLayout(subNetListPanel, BoxLayout.Y_AXIS));
subNetListPanel.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(final ComponentEvent ce) {
if (!getExpandCollapseBtn().isSelected())
getExpandCollapseBtn().setSelected(true);
}
@Override
public void componentHidden(final ComponentEvent ce) {
if (getExpandCollapseBtn().isSelected())
getExpandCollapseBtn().setSelected(false);
}
});
}
return subNetListPanel;
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class NetworkViewGrid method init.
@SuppressWarnings("unchecked")
private void init() {
setName(NAME);
setFocusable(true);
setRequestFocusEnabled(true);
setLayout(new BorderLayout());
add(getGridScrollPane(), BorderLayout.CENTER);
add(getToolBar(), BorderLayout.SOUTH);
addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
update(thumbnailSize);
updateToolBar();
}
@Override
public void componentResized(ComponentEvent e) {
update(thumbnailSize);
}
});
setSelectionKeyBindings(this);
setSelectionKeyBindings(getGridScrollPane().getViewport());
update(thumbnailSize);
addPropertyChangeListener("selectedItems", (PropertyChangeEvent e) -> {
if (!ignoreSelectedItemsEvent)
setSelectedNetworkViews(getNetworkViews((Collection<ThumbnailPanel>) e.getNewValue()));
});
}
use of java.awt.event.ComponentEvent in project CCDD by nasa.
the class CcddInputFieldPanelHandler method createDescAndDataFieldPanel.
/**
********************************************************************************************
* Create the table input field panel
*
* @param fieldPnlHndlrOwner
* reference to the owner of this description and data field handler
*
* @param tableScrollPane
* scroll pane containing the table; null if this field panel handler does not
* contain a table
*
* @param ownerName
* name of the owner of this field panel handler; null if no owner name is
* associated with it
*
* @param description
* description field text; null if the description is initially blank and disabled
*
* @param fieldHandler
* field handler reference
********************************************************************************************
*/
protected void createDescAndDataFieldPanel(final Component fieldPnlHndlrOwner, final JScrollPane tableScrollPane, String ownerName, String description, CcddFieldHandler fieldHandler) {
this.fieldPnlHndlrOwner = fieldPnlHndlrOwner;
this.ownerName = ownerName;
this.dataFieldHandler = fieldHandler;
// Set the flag to indicate if this input field panel handler is a data table
isDataTable = this instanceof CcddTableEditorHandler;
// Create the handler for undoing/redoing data field changes
undoFieldPnl = undoHandler.new UndoableDataFieldPanel();
// Set the initial layout manager characteristics
gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
// Create an outer panel to put the editor panel in (the border doesn't appear without
// this) and add the table description text field
inputPnl = new JPanel(new GridBagLayout());
// Check if this editor contains a table
if (tableScrollPane != null) {
// Define the editor panel to contain the table
JPanel innerPanel = new JPanel();
innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
innerPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
innerPanel.add(tableScrollPane);
inputPnl.add(innerPanel, gbc);
}
// Create borders for the input fields
border = BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.GRAY), BorderFactory.createEmptyBorder(ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing()));
Border emptyBorder = BorderFactory.createEmptyBorder();
// Create a panel to hold the table's system name, description and, if applicable, message
// ID information
JPanel descriptionPnl = new JPanel(new GridBagLayout());
// Create the description label
JLabel descriptionLbl = new JLabel("Description");
descriptionLbl.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
descriptionLbl.setForeground(ModifiableColorInfo.SPECIAL_LABEL_TEXT.getColor());
// Check if this editor doesn't contain a table
if (tableScrollPane == null) {
gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2;
gbc.insets.bottom = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2;
}
// Add the table description label
gbc.insets.left = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() / 2;
gbc.insets.right = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() / 2;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
gbc.gridy++;
descriptionPnl.add(descriptionLbl, gbc);
// Create the description input field
descriptionFld = undoHandler.new UndoableTextArea(3, 1);
descriptionFld.setFont(ModifiableFontInfo.INPUT_TEXT.getFont());
descriptionFld.setBorder(emptyBorder);
descriptionFld.setEditable(true);
descriptionFld.setLineWrap(true);
descriptionFld.setWrapStyleWord(true);
descriptionFld.setForeground(ModifiableColorInfo.INPUT_TEXT.getColor());
descriptionFld.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
descriptionFld.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
descScrollPane = new JScrollPane(descriptionFld);
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
// Check if the description field is initially disabled
if (description == null) {
// Set the description field and description field scroll pane background color to
// indicate these are disabled
descriptionFld.setBackground(ModifiableColorInfo.INPUT_DISABLE_BACK.getColor());
descScrollPane.setBackground(ModifiableColorInfo.INPUT_DISABLE_BACK.getColor());
} else {
// Set the description field and description field scroll pane background color to
// indicate these are enabled, and set the description field text
descriptionFld.setBackground(ModifiableColorInfo.INPUT_BACK.getColor());
descScrollPane.setBackground(ModifiableColorInfo.INPUT_BACK.getColor());
descriptionFld.setText(description);
}
// Check if this editor doesn't contain a table
if (tableScrollPane == null) {
// Place the description field within a scroll pane and add the field to the editor
inputPnl.setBorder(BorderFactory.createEtchedBorder());
descScrollPane.setBorder(border);
descScrollPane.setMinimumSize(descScrollPane.getPreferredSize());
gbc.gridy++;
descriptionPnl.add(descScrollPane, gbc);
} else // The editor contains a table
{
// Place the description field within a scroll pane and add the field to the editor
inputPnl.setBorder(emptyBorder);
descriptionFld.setToolTipText(CcddUtilities.wrapText("Table description", ModifiableSizeInfo.MAX_TOOL_TIP_LENGTH.getSize()));
descScrollPane.setBorder(emptyBorder);
descScrollPane.setViewportBorder(border);
descScrollPane.setMinimumSize(descScrollPane.getPreferredSize());
gbc.gridx++;
descriptionPnl.add(descScrollPane, gbc);
gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing();
gbc.insets.bottom = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing();
}
// Add the description panel to the editor
gbc.gridx = 0;
gbc.gridy++;
inputPnl.add(descriptionPnl, gbc);
// Add the data field panel to the editor
gbc.gridy++;
gbc.insets.top = 0;
gbc.insets.bottom = 0;
createDataFieldPanel(false);
// Check if this editor doesn't contain a table
if (tableScrollPane == null) {
// Add an invisible component in order to force the description panel and data fields
// to the top of the panel
JLabel invisibleLbl = new JLabel("");
gbc.weighty = 1.0;
gbc.gridy++;
inputPnl.add(invisibleLbl, gbc);
gbc.weighty = 0.0;
gbc.gridy--;
}
// Add a listener for changes in the editor panel's size
inputPnl.addComponentListener(new ComponentAdapter() {
/**
************************************************************************************
* Handle resizing of the editor panel
************************************************************************************
*/
@Override
public void componentResized(ComponentEvent ce) {
// Create a runnable object to be executed
SwingUtilities.invokeLater(new Runnable() {
/**
****************************************************************************
* Since the size returned by get___Size() can lag the actual size, use
* invokeLater to let the sizes "catch up"
****************************************************************************
*/
@Override
public void run() {
// Revalidate to force the editor panel to redraw to the new sizes, which
// causes the data fields to be correctly sized so that all of the fields
// are visible
inputPnl.revalidate();
}
});
}
});
}
use of java.awt.event.ComponentEvent in project Universal-G-Code-Sender by winder.
the class MainWindow method visualizeButtonActionPerformed.
// GEN-LAST:event_browseButtonActionPerformed
private void visualizeButtonActionPerformed(java.awt.event.ActionEvent evt) {
// Create new object if it is null.
if (this.vw == null) {
this.vw = new VisualizerWindow(settings.getVisualizerWindowSettings());
final MainWindow mw = this;
vw.addComponentListener(new ComponentListener() {
@Override
public void componentResized(ComponentEvent ce) {
mw.settings.getVisualizerWindowSettings().height = ce.getComponent().getSize().height;
mw.settings.getVisualizerWindowSettings().width = ce.getComponent().getSize().width;
}
@Override
public void componentMoved(ComponentEvent ce) {
mw.settings.getVisualizerWindowSettings().xLocation = ce.getComponent().getLocation().x;
mw.settings.getVisualizerWindowSettings().yLocation = ce.getComponent().getLocation().y;
}
@Override
public void componentShown(ComponentEvent ce) {
}
@Override
public void componentHidden(ComponentEvent ce) {
}
});
setVisualizerFile();
// Add listener
this.backend.addControllerListener(vw);
}
// Display the form
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
vw.setVisible(true);
}
});
}
Aggregations