use of java.awt.event.ComponentAdapter in project sling by apache.
the class Util method setupComponentLocationSize.
static void setupComponentLocationSize(final Component comp, final String propX, final String propY, final String propWidth, final String propHeight, final int defaultX, final int defaultY, final int defaultWidth, final int defaultHeight) {
comp.setLocation(getPreference(propX, defaultY), getPreference(propY, defaultX));
comp.setSize(getPreference(propWidth, defaultWidth), getPreference(propHeight, defaultHeight));
comp.addComponentListener(new ComponentAdapter() {
@Override
public void componentMoved(ComponentEvent e) {
setPreference(propX, e.getComponent().getX(), false);
setPreference(propY, e.getComponent().getY(), true);
}
@Override
public void componentResized(ComponentEvent e) {
setPreference(propWidth, e.getComponent().getWidth(), false);
setPreference(propHeight, e.getComponent().getHeight(), true);
}
});
}
use of java.awt.event.ComponentAdapter in project JMRI by JMRI.
the class DccLocoAddressSelector method getCombinedJPanel.
/* Get a JPanel containing the combined selector.
*
* <P>
* Because Swing only allows a component to be inserted in one
* container, this can only be done once
*/
public JPanel getCombinedJPanel() {
if (panelUsed) {
log.error("getCombinedPanel invoked after panel already requested");
return null;
}
if (textUsed) {
log.error("getCombinedPanel invoked after text already requested");
return null;
}
if (boxUsed) {
log.error("getCombinedPanel invoked after text already requested");
return null;
}
panelUsed = true;
if (varFontSize) {
text.setFont(new Font("", Font.PLAIN, 32));
}
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
p.add(text);
if (!locked || ((InstanceManager.getNullableDefault(jmri.ThrottleManager.class) != null) && !InstanceManager.throttleManagerInstance().addressTypeUnique())) {
p.add(box);
}
p.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
changeFontSizes();
}
});
return p;
}
use of java.awt.event.ComponentAdapter in project android by JetBrains.
the class StateChartVisualTest method createMockTimeline.
private JLayeredPane createMockTimeline() {
JLayeredPane timelinePane = new JLayeredPane();
timelinePane.add(mNetworkStatusChart);
timelinePane.add(mRadioStateChart);
timelinePane.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
JLayeredPane host = (JLayeredPane) e.getComponent();
if (host != null) {
Dimension dim = host.getSize();
int numChart = 0;
for (Component c : host.getComponents()) {
if (c instanceof AxisComponent) {
AxisComponent axis = (AxisComponent) c;
switch(axis.getOrientation()) {
case LEFT:
axis.setBounds(0, 0, AXIS_SIZE, dim.height);
break;
case BOTTOM:
axis.setBounds(0, dim.height - AXIS_SIZE, dim.width, AXIS_SIZE);
break;
case RIGHT:
axis.setBounds(dim.width - AXIS_SIZE, 0, AXIS_SIZE, dim.height);
break;
case TOP:
axis.setBounds(0, 0, dim.width, AXIS_SIZE);
break;
}
} else if (c instanceof StateChart) {
int y = numChart % 2 == 0 ? AXIS_SIZE : dim.height - AXIS_SIZE * 2;
c.setBounds(AXIS_SIZE, y, dim.width - AXIS_SIZE * 2, AXIS_SIZE);
numChart++;
}
}
}
}
});
return timelinePane;
}
use of java.awt.event.ComponentAdapter in project android by JetBrains.
the class AxisLineChartVisualTest method createMockTimeline.
private JLayeredPane createMockTimeline() {
JBLayeredPane timelinePane = new JBLayeredPane();
timelinePane.add(mMemoryAxis1);
timelinePane.add(mMemoryAxis2);
timelinePane.add(mTimeAxis);
timelinePane.add(mLineChart);
timelinePane.add(mSelection);
timelinePane.add(mGrid);
timelinePane.add(mScrollbar);
// TODO move to ProfilerOverviewVisualTest.
JBPanel labelPanel = new JBPanel();
labelPanel.setLayout(new FlowLayout());
labelPanel.add(mLegendComponent);
timelinePane.add(labelPanel);
timelinePane.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
JLayeredPane host = (JLayeredPane) e.getComponent();
if (host != null) {
Dimension dim = host.getSize();
for (Component c : host.getComponents()) {
if (c instanceof AxisComponent) {
AxisComponent axis = (AxisComponent) c;
switch(axis.getOrientation()) {
case LEFT:
axis.setBounds(0, 0, AXIS_SIZE, dim.height);
break;
case BOTTOM:
axis.setBounds(0, dim.height - AXIS_SIZE, dim.width, AXIS_SIZE);
break;
case RIGHT:
axis.setBounds(dim.width - AXIS_SIZE, 0, AXIS_SIZE, dim.height);
break;
case TOP:
axis.setBounds(0, 0, dim.width, AXIS_SIZE);
break;
}
} else if (c instanceof RangeScrollbar) {
int sbHeight = c.getPreferredSize().height;
c.setBounds(0, dim.height - sbHeight, dim.width, sbHeight);
} else {
c.setBounds(AXIS_SIZE, AXIS_SIZE, dim.width - AXIS_SIZE * 2, dim.height - AXIS_SIZE * 2);
}
}
}
}
});
return timelinePane;
}
use of java.awt.event.ComponentAdapter in project android by JetBrains.
the class NetworkCaptureSegment method createCaptureTable.
@NotNull
private JTable createCaptureTable() {
JBTable table = new JBTable(new NetworkCaptureTableModel());
table.setDefaultRenderer(StateChart.class, (t, value, isSelected, hasFocus, row, column) -> myCharts.get(row));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().addListSelectionListener(e -> {
if (table.getSelectedRow() < myDataList.size()) {
myDetailedViewListener.showDetailedConnection(myDataList.get(table.getSelectedRow()));
}
});
table.setFont(AdtUiUtils.DEFAULT_FONT);
table.setRowHeight(myRowHeight);
table.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
table.getColumnModel().getColumn(Column.TIMELINE.ordinal()).setPreferredWidth(myCaptureTable.getWidth() / 2);
}
});
return table;
}
Aggregations