net.alantea.swing.graph.GraphConnectedContainer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swingplus Show documentation
Show all versions of swingplus Show documentation
Addons over swing package.
The newest version!
package net.alantea.swing.graph;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
@SuppressWarnings("serial")
public class GraphConnectedContainer extends GraphElement
{
private GraphMarker leftMarker;
private GraphMarker rightMarker;
private GraphElement content;
public GraphConnectedContainer()
{
setLayout(null);
content = new GraphElement();
leftMarker = new GraphMarker();
rightMarker = new GraphMarker();
super.add(content);
super.add(leftMarker);
super.add(rightMarker);
leftMarker.setBackground(Color.DARK_GRAY);
rightMarker.setBackground(Color.DARK_GRAY);
leftMarker.setForeground(Color.LIGHT_GRAY);
rightMarker.setForeground(Color.LIGHT_GRAY);
}
public void setMarkerBackgroundColor(Color markerBackgroundColor)
{
leftMarker.setBackground(markerBackgroundColor);
rightMarker.setBackground(markerBackgroundColor);
}
public void setMarkerForegroundColor(Color markerForegroundColor)
{
leftMarker.setForeground(markerForegroundColor);
rightMarker.setForeground(markerForegroundColor);
}
public void add(Component component, Object constraints)
{
content.add(component, constraints);
}
public void paintBorder(Graphics g)
{
drawRoundRectangle(g, Color.YELLOW, 0.0, 0.0, 1.0, 1.0, 3, 10);
}
@Override
public void setBounds(int x, int y, int width, int height)
{
super.setBounds(x, y, width, height);
content.setBounds(20, 0, width - 40, height);
leftMarker.setBounds(0, (height - 20) / 2, 20, 20);
rightMarker.setBounds(width - 20, (height - 20) / 2, 20, 20);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy