use of com.servoy.j2db.util.gui.SpecialMatteBorder in project servoy-client by Servoy.
the class AbstractScriptLabel method setFocusPainted.
public void setFocusPainted(boolean showFocus) {
if (showFocus) {
final SpecialMatteBorder border = new SpecialMatteBorder(1, 1, 1, 1, Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK);
border.setDashPattern(new float[] { 1 });
addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
if (getBorder() == null)
setBorder(border);
}
public void focusLost(FocusEvent e) {
if (getBorder() == border)
setBorder(null);
}
});
}
}
use of com.servoy.j2db.util.gui.SpecialMatteBorder in project servoy-client by Servoy.
the class CellAdapter method applyRowBorder.
private void applyRowBorder(JComponent component, JTable jtable, boolean isSelected, int row, boolean hasFocus) {
Border styleBorder = getBorder(jtable, isSelected, row);
boolean hasStyleBorder = false;
if (styleBorder != null) {
hasStyleBorder = true;
if (component instanceof AbstractButton && !((AbstractButton) component).isBorderPainted()) {
((AbstractButton) component).setBorderPainted(true);
}
} else {
styleBorder = noFocusBorder;
}
Border marginBorder = null;
if (noFocusBorder instanceof EmptyBorder) {
marginBorder = noFocusBorder;
} else if (noFocusBorder instanceof CompoundBorder && ((CompoundBorder) noFocusBorder).getInsideBorder() instanceof EmptyBorder) {
marginBorder = ((CompoundBorder) noFocusBorder).getInsideBorder();
}
Border adjustedBorder = null;
if (!hasFocus) {
if (hasStyleBorder && marginBorder != null) {
styleBorder = new CompoundBorder(styleBorder, marginBorder);
}
adjustedBorder = styleBorder;
} else {
// $NON-NLS-1$
adjustedBorder = UIManager.getBorder("Table.focusCellHighlightBorder");
if (styleBorder != null) {
if (hasStyleBorder) {
if (marginBorder != null) {
adjustedBorder = new CompoundBorder(styleBorder, new CompoundBorder(adjustedBorder, marginBorder));
} else {
adjustedBorder = new CompoundBorder(styleBorder, adjustedBorder);
}
} else if (styleBorder instanceof CompoundBorder) {
Border insideBorder = ((CompoundBorder) styleBorder).getInsideBorder();
Border outsideBorder = ((CompoundBorder) styleBorder).getOutsideBorder();
if (outsideBorder instanceof SpecialMatteBorder)
adjustedBorder = new CompoundBorder(adjustedBorder, styleBorder);
else
adjustedBorder = new CompoundBorder(adjustedBorder, insideBorder);
} else if (styleBorder instanceof SpecialMatteBorder) {
adjustedBorder = new CompoundBorder(adjustedBorder, styleBorder);
} else {
// keep the renderer content at the same position,
// create a focus border with the same border insets
Insets noFocusBorderInsets = styleBorder.getBorderInsets(component);
Insets adjustedBorderInsets = adjustedBorder.getBorderInsets(component);
EmptyBorder emptyInsideBorder = new EmptyBorder(Math.max(0, noFocusBorderInsets.top - adjustedBorderInsets.top), Math.max(0, noFocusBorderInsets.left - adjustedBorderInsets.left), Math.max(0, noFocusBorderInsets.bottom - adjustedBorderInsets.bottom), Math.max(0, noFocusBorderInsets.right - adjustedBorderInsets.right));
adjustedBorder = new CompoundBorder(adjustedBorder, emptyInsideBorder);
}
}
}
component.setBorder(adjustedBorder);
}
use of com.servoy.j2db.util.gui.SpecialMatteBorder in project servoy-client by Servoy.
the class JSSolutionModel method createSpecialMatteBorder.
/**
* Create a special matte border string.
*
* @sample
* var form = solutionModel.getForm("someForm");
* // create a rectangle border (no rounded corners) and continous line
* form.borderType = solutionModel.createSpecialMatteBorder(1,1,1,1,"#00ff00","#00ff00","#00ff00","#00ff00",0,null);
* // create a border with rounded corners and dashed line (25 pixels drawn, then 25 pixels skipped)
* // form.borderType = solutionModel.createSpecialMatteBorder(1,1,1,1,"#00ff00","#00ff00","#00ff00","#00ff00",10,new Array(25,25));
*
* @param top_width top width of matte border in pixels
* @param right_width right width of matte border in pixels
* @param bottom_width bottom width of matte border in pixels
* @param left_width left width of matte border in pixels
* @param top_color top border color
* @param right_color right border color
* @param bottom_color bottom border color
* @param left_color left border color
* @param rounding_radius width of the arc to round the corners
* @param dash_pattern the dash pattern of border stroke
*/
@JSFunction
public String createSpecialMatteBorder(int top_width, int right_width, int bottom_width, int left_width, String top_color, String right_color, String bottom_color, String left_color, float rounding_radius, float[] dash_pattern) {
SpecialMatteBorder border = new SpecialMatteBorder(top_width, left_width, bottom_width, right_width, PersistHelper.createColor(top_color), PersistHelper.createColor(right_color), PersistHelper.createColor(bottom_color), PersistHelper.createColor(left_color));
border.setRoundingRadius(rounding_radius);
if (dash_pattern != null)
border.setDashPattern(dash_pattern);
return ComponentFactoryHelper.createBorderString(border);
}
Aggregations