use of java.awt.event.ComponentEvent in project javatari by ppeccin.
the class PanelScreen method setup.
private void setup() {
setTransferHandler(new ROMDropTransferHandler());
monitorPanel.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
if (e.getComponent() == monitorPanel)
validate();
}
});
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
setOpaque(false);
add(monitorPanel);
if (consolePanel != null)
add(consolePanel);
validate();
}
use of java.awt.event.ComponentEvent in project lwjgl by LWJGL.
the class MacOSXCanvasPeerInfo method addComponentListener.
private void addComponentListener(final Canvas component) {
ComponentListener[] components = component.getComponentListeners();
// avoid adding duplicate listners by checking if one has already been added
for (int i = 0; i < components.length; i++) {
ComponentListener c = components[i];
if (c.toString() == "CanvasPeerInfoListener") {
// already contains the listner below return without adding
return;
}
}
ComponentListener comp = new ComponentListener() {
public void componentHidden(ComponentEvent e) {
}
public void componentMoved(ComponentEvent e) {
// nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
reSetLayerBounds(component, getHandle());
}
public void componentResized(ComponentEvent e) {
// nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
reSetLayerBounds(component, getHandle());
}
public void componentShown(ComponentEvent e) {
}
public String toString() {
return "CanvasPeerInfoListener";
}
};
component.addComponentListener(comp);
}
use of java.awt.event.ComponentEvent in project cayenne by apache.
the class CayenneModelerFrame method initToolbar.
/**
* Initializes main toolbar.
*/
protected void initToolbar() {
final JToolBar toolBar = new MainToolBar();
Dimension smallBtnDim = new Dimension(30, 30);
JButton backButton = getAction(NavigateBackwardAction.class).buildButton(1);
backButton.setMinimumSize(smallBtnDim);
backButton.setPreferredSize(smallBtnDim);
toolBar.add(backButton);
JButton forwardButton = getAction(NavigateForwardAction.class).buildButton(3);
forwardButton.setMinimumSize(smallBtnDim);
forwardButton.setPreferredSize(smallBtnDim);
toolBar.add(forwardButton);
toolBar.addSeparator(new Dimension(30, 0));
toolBar.add(getAction(NewProjectAction.class).buildButton(1));
toolBar.add(getAction(OpenProjectAction.class).buildButton(2));
toolBar.add(getAction(SaveAction.class).buildButton(3));
toolBar.addSeparator();
JButton removeButton = getAction(RemoveAction.class).buildButton();
toolBar.add(removeButton);
toolBar.addSeparator();
toolBar.add(getAction(CutAction.class).buildButton(1));
toolBar.add(getAction(CopyAction.class).buildButton(2));
toolBar.add(getAction(PasteAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(getAction(UndoAction.class).buildButton(1));
toolBar.add(getAction(RedoAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(getAction(CreateNodeAction.class).buildButton(1));
toolBar.add(getAction(CreateDataMapAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(getAction(CreateDbEntityAction.class).buildButton(1));
toolBar.add(getAction(CreateProcedureAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(getAction(CreateObjEntityAction.class).buildButton(1));
toolBar.add(getAction(CreateEmbeddableAction.class).buildButton(2));
toolBar.add(getAction(CreateQueryAction.class).buildButton(3));
// is used to place search feature components the most right on a toolbar
toolBar.add(new SearchPanel());
getContentPane().add(toolBar, BorderLayout.NORTH);
// Hide some buttons when frame is too small
final int defaultBtnWidth = removeButton.getUI().getPreferredSize(backButton).width;
addComponentListener(new ComponentAdapter() {
private final int[] empty = {};
private final int[] all = { 6, 7, 8, 9, 10, 11, 12, 13, 14 };
private final int[] remove = { 6, 7 };
private final int[] removeAndCopy = { 6, 7, 8, 9, 10, 11 };
private final int[] undo = { 12, 13, 14 };
private final int[] undoAndCopy = { 8, 9, 10, 11, 12, 13, 14 };
@Override
public void componentResized(ComponentEvent e) {
int[] hidden, shown;
if (getSize().width < (13 * defaultBtnWidth + 300)) {
hidden = all;
shown = empty;
} else if (getSize().width < (16 * defaultBtnWidth + 300)) {
hidden = removeAndCopy;
shown = undo;
} else if (getSize().width < (18 * defaultBtnWidth + 300)) {
hidden = remove;
shown = undoAndCopy;
} else {
hidden = empty;
shown = all;
}
for (int i : hidden) {
toolBar.getComponentAtIndex(i).setVisible(false);
}
for (int i : shown) {
toolBar.getComponentAtIndex(i).setVisible(true);
}
}
});
}
use of java.awt.event.ComponentEvent in project cayenne by apache.
the class ObjEntityCallbackMethodsTab method initController.
/**
* listeners initialization
*/
protected void initController() {
super.initController();
addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
rebuildTables();
}
});
mediator.addObjEntityDisplayListener(e -> {
if (ObjEntityCallbackMethodsTab.this.isVisible()) {
rebuildTables();
}
});
}
use of java.awt.event.ComponentEvent in project cayenne by apache.
the class AdapterEditor method initController.
protected void initController() {
// init bindings
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
adapterNameBinding = builder.bindToTextField(view.getCustomAdapter(), "adapterName");
((ProjectController) getParent()).addDataNodeDisplayListener(new DataNodeDisplayListener() {
public void currentDataNodeChanged(DataNodeDisplayEvent e) {
refreshView(e.getDataNode());
}
});
getView().addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
refreshView(node != null ? node : ((ProjectController) getParent()).getCurrentDataNode());
}
});
}
Aggregations