use of javax.swing.JComponent in project jdk8u_jdk by JetBrains.
the class TSFrame method createGui.
public static Frame createGui(final boolean useSwing, final boolean useShape, final boolean useTransl, final boolean useNonOpaque, final float factor) {
Frame frame;
done = false;
if (useNonOpaque) {
if (useSwing) {
frame = new NonOpaqueJFrame();
// frame = new NonOpaqueJAppletFrame(gc);
} else {
frame = new NonOpaqueFrame();
}
animateComponent(frame);
} else if (useSwing) {
frame = new JFrame("Swing Frame");
JComponent p = new JButton("Swing!");
p.setPreferredSize(new Dimension(200, 100));
frame.add("North", p);
p = new MyJPanel();
animateComponent(p);
frame.add("Center", p);
} else {
frame = new Frame("AWT Frame") {
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillRect(0, 0, 100, 100);
}
};
frame.setLayout(new BorderLayout());
Canvas c = new MyCanvas();
frame.add("North", c);
animateComponent(c);
c = new MyCanvas();
frame.add("Center", c);
animateComponent(c);
c = new MyCanvas();
frame.add("South", c);
animateComponent(c);
}
final Frame finalFrame = frame;
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
finalFrame.dispose();
done = true;
}
});
frame.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
finalFrame.dispose();
done = true;
}
});
frame.setPreferredSize(new Dimension(800, 600));
if (useShape) {
frame.setUndecorated(true);
}
frame.setLocation(450, 10);
frame.pack();
GraphicsDevice gd = frame.getGraphicsConfiguration().getDevice();
if (useShape) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
System.out.println("applying PERPIXEL_TRANSPARENT");
frame.setShape(new Ellipse2D.Double(0, 0, frame.getWidth(), frame.getHeight() / 3));
frame.setTitle("PERPIXEL_TRANSPARENT");
} else {
System.out.println("Passed: PERPIXEL_TRANSPARENT unsupported");
}
}
if (useTransl) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
System.out.println("applying TRANSLUCENT");
frame.setOpacity(factor);
frame.setTitle("TRANSLUCENT");
} else {
System.out.println("Passed: TRANSLUCENT unsupported");
}
}
if (useNonOpaque) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
System.out.println("applying PERPIXEL_TRANSLUCENT");
frame.setBackground(new Color(0, 0, 0, 0));
frame.setTitle("PERPIXEL_TRANSLUCENT");
} else {
System.out.println("Passed: PERPIXEL_TRANSLUCENT unsupported");
}
}
frame.setVisible(true);
return frame;
}
use of javax.swing.JComponent in project processdash by dtuma.
the class DataTableCellNumericRenderer method getTableCellRendererComponent.
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
NumericDataValue number = (NumericDataValue) value;
String display = "";
String errorMsg = null;
boolean readOnly = false;
Color errorColor = null;
if (number != null) {
// extract information from the NumericDataValue object.
display = number.isInvisible ? "" : formatNumber(number);
errorMsg = number.errorMessage;
errorColor = number.errorColor;
readOnly = (number.isEditable == false);
}
// ask our superclass for an appropriate renderer component.
Component result = super.getTableCellRendererComponent(table, display, isSelected, hasFocus, row, column);
// change the foreground color for read-only or erroneous values.
result.setForeground(getForegroundColor(errorMsg, errorColor, readOnly));
// use a bold font for erroneous values.
Font f = getFont(errorMsg != null, result);
if (f != null)
result.setFont(f);
if (result instanceof JComponent)
// set or remove a descriptive tooltip
((JComponent) result).setToolTipText(errorMsg);
return result;
}
use of javax.swing.JComponent in project processdash by dtuma.
the class BoundForm method addFormElement.
protected void addFormElement(Object element, Element xml) {
super.addFormElement(element, xml);
if (element instanceof JComponent) {
JComponent component = (JComponent) element;
addFormComponent(component, xml);
}
}
use of javax.swing.JComponent in project cayenne by apache.
the class ObjEntityRelationshipPanel method rebuildTable.
protected void rebuildTable(ObjEntity entity) {
final ObjRelationshipTableModel model = new ObjRelationshipTableModel(entity, mediator, this);
model.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
if (table.getSelectedRow() >= 0) {
ObjRelationship rel = model.getRelationship(table.getSelectedRow());
enabledResolve = rel.getSourceEntity().getDbEntity() != null;
resolveMenu.setEnabled(enabledResolve);
}
}
});
table.setModel(model);
table.setRowHeight(25);
table.setRowMargin(3);
TableColumn col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_TARGET_PATH);
col.setCellEditor(new DbRelationshipPathComboBoxEditor());
col.setCellRenderer(new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
setToolTipText("To choose relationship press enter two times.To choose next relationship press dot.");
return this;
}
});
col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_DELETE_RULE);
JComboBox deleteRulesCombo = Application.getWidgetFactory().createComboBox(DELETE_RULES, false);
deleteRulesCombo.setFocusable(false);
deleteRulesCombo.setEditable(true);
((JComponent) deleteRulesCombo.getEditor().getEditorComponent()).setBorder(null);
deleteRulesCombo.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
// Default to the first value
deleteRulesCombo.setSelectedIndex(0);
col.setCellEditor(Application.getWidgetFactory().createCellEditor(deleteRulesCombo));
tablePreferences.bind(table, null, null, null, ObjRelationshipTableModel.REL_NAME, true);
}
use of javax.swing.JComponent in project cayenne by apache.
the class ComboSelectionBinding method initComponentDefaults.
protected void initComponentDefaults() {
this.errorColor = ValidatorDialog.WARNING_COLOR;
if (comboBox.getEditor() != null) {
Component editor = comboBox.getEditor().getEditorComponent();
if (editor instanceof JComponent) {
JComponent jEditor = (JComponent) editor;
this.defaultBGColor = jEditor.getBackground();
this.defaultToolTip = jEditor.getToolTipText();
}
}
}
Aggregations