use of javax.swing.JComponent in project adempiere by adempiere.
the class Env method updateUI.
// sleep
/**
* Update all windows after look and feel changes.
* @since 2006-11-27
*/
public static Set<Window> updateUI() {
Set<Window> updated = new HashSet<Window>();
for (Container c : s_windows) {
Window w = getFrame(c);
if (w == null)
continue;
if (updated.contains(w))
continue;
SwingUtilities.updateComponentTreeUI(w);
w.validate();
RepaintManager mgr = RepaintManager.currentManager(w);
Component[] childs = w.getComponents();
for (Component child : childs) {
if (child instanceof JComponent)
mgr.markCompletelyDirty((JComponent) child);
}
w.repaint();
updated.add(w);
}
for (Window w : s_hiddenWindows) {
if (updated.contains(w))
continue;
SwingUtilities.updateComponentTreeUI(w);
w.validate();
RepaintManager mgr = RepaintManager.currentManager(w);
Component[] childs = w.getComponents();
for (Component child : childs) {
if (child instanceof JComponent)
mgr.markCompletelyDirty((JComponent) child);
}
w.repaint();
updated.add(w);
}
return updated;
}
use of javax.swing.JComponent in project adempiere by adempiere.
the class AEnv method updateUI.
// cacheReset
/**
* Update all windows after look and feel changes.
* @since 2006-11-27
*/
public static void updateUI() {
Set<Window> updated = Env.updateUI();
JFrame top = Env.getWindow(0);
if (top instanceof AMenu) {
CFrame[] frames = ((AMenu) top).getWindowManager().getWindows();
for (CFrame f : frames) {
if (updated.contains(f))
continue;
SwingUtilities.updateComponentTreeUI(f);
f.validate();
RepaintManager mgr = RepaintManager.currentManager(f);
Component[] childs = f.getComponents();
for (Component c : childs) {
if (c instanceof JComponent)
mgr.markCompletelyDirty((JComponent) c);
}
f.repaint();
updated.add(f);
}
}
}
use of javax.swing.JComponent in project adempiere by adempiere.
the class MiniTable method prepareRenderer.
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
JComponent jc = (JComponent) c;
if (c == null)
return c;
// Row is selected
Color selectedColor = AdempierePLAF.getFieldBackground_Selected();
// Even row
Color normalColor = AdempierePLAF.getFieldBackground_Normal();
// Odd row
Color backColor = AdempierePLAF.getInfoBackground();
// Lead row border
Color borderColor = AdempierePLAF.getFieldBackground_Mandatory();
CompoundBorder cb = null;
ListSelectionModel rsm = this.getSelectionModel();
boolean readOnly = !this.isCellEditable(row, column);
if (!(row == rsm.getLeadSelectionIndex())) {
if (// Highlighted but not the lead
rsm.isSelectedIndex(row)) {
c.setBackground(selectedColor);
jc.setBorder(new MatteBorder(1, 1, 1, 1, selectedColor));
} else if (// Not selected but even in number
row % 2 == 0) {
c.setBackground(normalColor);
jc.setBorder(new MatteBorder(1, 1, 1, 1, normalColor));
} else // Not selected and odd in number
{
// If not shaded, match the table's background
c.setBackground(backColor);
jc.setBorder(new MatteBorder(1, 1, 1, 1, backColor));
}
// Buttons and checkboxes need to have the border turned on
if (c.getClass().equals(JCheckBox.class)) {
((JCheckBox) c).setBorderPainted(false);
} else if (c.getClass().equals(JButton.class)) {
((JButton) c).setBorderPainted(false);
}
} else {
if (c.getClass().equals(JCheckBox.class)) {
((JCheckBox) c).setBorderPainted(true);
} else if (c.getClass().equals(JButton.class)) {
((JButton) c).setBorderPainted(true);
}
// Define border - compond border maintains the spacing of 1px around the field
if (column == 0) {
cb = new CompoundBorder(new EmptyBorder(new Insets(0, 0, 0, 1)), new MatteBorder(1, 1, 1, 0, borderColor));
} else if (column == this.getColumnCount() - 1) {
cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 0)), new MatteBorder(1, 0, 1, 1, borderColor));
} else {
cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 1)), new MatteBorder(1, 0, 1, 0, borderColor));
}
// Set border
jc.setBorder(cb);
// Set background color
if (!readOnly && this.isRowChecked(row))
c.setBackground(normalColor);
else
c.setBackground(selectedColor);
}
return c;
}
use of javax.swing.JComponent in project adempiere by adempiere.
the class CompiereTabbedPaneUI method paintContentBorder.
// paintTabBackground
/**************************************************************************
* Paint Content Border (overwriting BasicTabbedPanelUI)
* Uses Color from actual Tab (not from TabbedPane)
* @param g graphics
* @param tabPlacement tab placement
* @param selectedIndex index
*/
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
// System.out.println("TabContentBorder " );
int width = tabPane.getWidth();
int height = tabPane.getHeight();
Insets insets = tabPane.getInsets();
int x = insets.left;
int y = insets.top;
int w = width - insets.right - insets.left;
int h = height - insets.top - insets.bottom;
switch(tabPlacement) {
case LEFT:
x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
w -= (x - insets.left);
break;
case RIGHT:
w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
break;
case BOTTOM:
h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
break;
case TOP:
default:
y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
h -= (y - insets.top);
}
// Fill region behind content area - basically a border
Component comp = null;
if (selectedIndex != -1)
comp = tabPane.getComponentAt(selectedIndex);
if (comp != null && comp instanceof JComponent) {
JComponent jc = (JComponent) comp;
CompiereColor bg = null;
try {
if (jc != null)
bg = (CompiereColor) jc.getClientProperty(CompiereLookAndFeel.BACKGROUND);
} catch (Exception e) {
System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage());
}
if (bg == null) {
bg = new CompiereColor(jc.getBackground());
jc.putClientProperty(CompiereLookAndFeel.BACKGROUND, bg);
}
bg.paintRect(g, jc, x, y, w, h);
} else // Not a JComponent - paint flat
if (comp != null) {
g.setColor(comp.getBackground());
g.fillRect(x, y, w, h);
}
paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h);
paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h);
paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h);
paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h);
}
use of javax.swing.JComponent in project adempiere by adempiere.
the class CompiereToolTipUI method getAcceleratorString.
/**
* Get Accelerator String
* @return string
*/
public String getAcceleratorString() {
String str = super.getAcceleratorString();
if (tip == null || isAcceleratorHidden())
return str;
JComponent comp = tip.getComponent();
if (comp == null || comp instanceof JTabbedPane || comp instanceof JMenuItem)
return str;
KeyStroke[] keys = comp.getRegisteredKeyStrokes();
StringBuffer controlKeyStr = new StringBuffer();
for (int i = 0; i < keys.length; i++) {
int mod = keys[i].getModifiers();
int condition = comp.getConditionForKeyStroke(keys[i]);
if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
String prefix = KeyEvent.getKeyModifiersText(mod);
if (prefix.length() > 1) {
if (controlKeyStr.length() > 0)
controlKeyStr.append(" ");
controlKeyStr.append(prefix).append("-").append(KeyEvent.getKeyText(keys[i].getKeyCode()));
// just first
break;
}
}
}
return controlKeyStr.toString();
}
Aggregations