jncomponent.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 859 行 · 第 1/2 页
JAVA
859 行
}
}
/**
* Process a paint event.
*
* @param e
*/
private void processPaintEvent(JNPaintEvent e) {
final Graphics g = this.getGraphics();
final Rectangle updateRect = e.getUpdateRect();
if (updateRect != null) {
g.clipRect(updateRect.x, updateRect.y, updateRect.width, updateRect.height);
}
if (e.getID() == JNPaintEvent.UPDATE) {
validate();
Graphics gfx = getGraphics().create();
gfx.translate(getAbsLocation().x, getAbsLocation().y);
update(gfx);
// update(g);
} else if (e.getID() == JNPaintEvent.PAINT) {
Graphics gfx = getGraphics().create();
gfx.translate(getAbsLocation().x, getAbsLocation().y);
// update(gfx);
paint(gfx);
}
}
/**
* ???????
*
* @see org.jnode.wt.components.AbstractValidatable#recalculate()
*/
public void recalculate() {
}
/**
* Add a mouse listener to this component.
*
* @param listener
*/
public void removeMouseListener(JNMouseListener listener) {
if (mouseListeners != null) {
mouseListeners.remove(listener);
}
}
/**
* Repaint the complete component.
*
* @see org.jnode.wt.components.Drawable#repaint()
*/
public void repaint() {
this.repaint(null);
}
/**
* Repaint a selected area within the component.
*
* @param x
* @param y
* @param width
* @param height
*/
public void repaint(int x, int y, int width, int height) {
this.repaint(new Rectangle(x, y, width, height));
}
/**
* Post repaint events.
*/
private void repaint(Rectangle updateRect) {
if (isShowing()) {
desktopMgr.postEvent(new JNComponentEvent(this, JNComponentEvent.COMPONENT_RESIZED));
desktopMgr.postEvent(new JNPaintEvent(this, JNPaintEvent.UPDATE, updateRect));
}
}
public abstract void resize();
public void setBackground(Color c) {
this.background = c;
}
public void setBounds(int x, int y, int w, int h) {
bounds.setBounds(x, y, w, h);
setLocation(x, y);
setSize(w, h);
invalidate();
}
public void setBounds(Rectangle r) {
this.setBounds(r.x, r.y, r.width, r.height);
}
/**
* @param cursor
* The cursor to set.
*/
public void setCursor(JNCursor cursor) {
this.cursor = cursor;
}
public void setEnableBorderLine(boolean b) {
drawBorderLine = b;
}
/**
* Set the enabled state of this component.
*
* @param enabled
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public void setFont(Font f) {
this.font = f;
}
public void setForeground(Color c) {
this.foreground = c;
}
public void setInsets(Insets ins) {
comp_insets = ins;
}
/**
* Sets the location of this component relative to its parent.
*
* @param x
* @param y
*/
public void setLocation(int x, int y) {
bounds.setLocation(x, y);
invalidate();
}
/**
* Insert the method's description here.
* Creation date: (1/24/04 2:14:21 AM)
* @param newName java.lang.String
*/
public void setName(java.lang.String newName) {
name = newName;
}
/**
* Set this component to opaque or transparent.
*
* @param on
*/
public void setOpaque(boolean on) {
this.opaque = on;
}
/**
* @param parent
* The parent to set.
*/
public final void setParent(JNContainer parent) {
this.parent = parent;
}
public void setPreferredSize(int w, int h) {
/* Perfomance Note:: its always fast to use already created vari, than creating new */
this.setPreferredSize(new Dimension(w, h));
}
public void setPreferredSize(Dimension d) {
this.preferredSize = d;
}
/**
* Set the size of this component
*
* @param width
* The new width
* @param height
* The new height
*/
public void setSize(int width, int height) {
// bounds.setSize(width, height);
// invalidate();
this.setSize(new Dimension(width, height));
}
/*
public void setSize(int width, int height) {
if (width < 0)
width = 0;
if (height < 0)
height = 0;
this.size = new Dimension(width, height);
invalidate();
} */
/**
* @param size
* The size to set.
*/
public void setSize(Dimension size) {
bounds.setSize(size);
invalidate();
}
/**
* Set the visibility of this component.
*
* @param visible
*/
public void setVisible(boolean visible) {
if (this.visible == visible)
return;
this.visible = visible;
if (visible) {
invalidate();
this.visible = visible;
/*This is wrong, an event should not post based directly,it should also depend on whether the comp is added to a container. */
if (isShowing()) {
getDesktopManager().postEvent(new JNComponentEvent(this, JNComponentEvent.COMPONENT_SHOWN));
this.repaint();
}
}
}
/**
* Update this component.
*/
public void update(Graphics g) {
if (isValid() && isVisible()) {
Graphics translatedG = g;//.create();
// Point absLoc = this.getAbsLocation();
// translatedG.translate(absLoc.x, absLoc.y);
internallyPaint(translatedG);
paint(translatedG);
}
}
/**
* Paint this component.
*
* @param g
*/
public void paint(Graphics g) {
}
// protected abstract Dimension calculatePreferredSize();
//*********************** The ComponentPeer interface ***********************
public int checkImage(Image img, int width, int height,
ImageObserver ob) {
//TODO: implement it
return 0;
}
public Image createImage(ImageProducer prod) {
//TODO: implement it
return null;
}
public Image createImage(int width, int height) {
//TODO: implement it
return null;
}
public VolatileImage createVolatileImage(int width, int height){
//TODO: implement it
return null;
}
public void disable() {
//TODO: implement it
}
public void dispose() {
//TODO: implement it
}
public void enable() {
//TODO: implement it
}
public ColorModel getColorModel() {
//TODO: implement it
return null;
}
public FontMetrics getFontMetrics(Font f) {
//TODO: implement it
return null;
}
public GraphicsConfiguration getGraphicsConfiguration() {
//TODO: implement it
return null;
}
public Point getLocationOnScreen() {
//TODO: implement it
return null;
}
public Toolkit getToolkit() {
//TODO: implement it
return null;
}
// The JCL says that handleEvent returns boolean. However, we've
// experimentally determined that it in fact actually returns void.
public void handleEvent(AWTEvent e) {
//TODO: implement it
}
public void hide() {
//TODO: implement it
}
public boolean isFocusTraversable() {
//TODO: implement it
return false;
}
public Dimension minimumSize() {
//TODO: implement it
return null;
}
public Dimension preferredSize() {
//TODO: implement it
return null;
}
public boolean prepareImage(Image img, int width, int height,
ImageObserver ob) {
//TODO: implement it
return false;
}
public void print(Graphics graphics) {
//TODO: implement it
}
public void repaint(long tm, int x, int y, int width, int height) {
//TODO: implement it
}
public void requestFocus() {
//TODO: implement it
}
public void reshape(int x, int y, int width, int height) {
//TODO: implement it
}
public void setCursor(Cursor cursor) {
//TODO: implement it
}
public void setEventMask(long mask) {
//TODO: implement it
}
public void show() {
//TODO: implement it
}
//********** PART OF JDK 1.4 BUT NOT IN CLASSPATH *****************
public void coalescePaintEvent(PaintEvent event){
//TODO: implement it
}
public Image getBackBuffer(){
//TODO: implement it
return null;
}
public boolean requestFocus(Component comp, boolean b1, boolean b2, long l){
//TODO: implement it
return false;
}
public void flip(BufferCapabilities.FlipContents cont){
//TODO: implement it
}
public void createBuffers(int i, BufferCapabilities cap){
//TODO: implement it
}
public boolean isObscured(){
//TODO: implement it
return false;
}
public boolean isFocusable(){
//TODO: implement it
return false;
}
public boolean handlesWheelScrolling(){
//TODO: implement it
return false;
}
public boolean canDetermineObscurity(){
//TODO: implement it
return false;
}
public void updateCursorImmediately(){
//TODO: implement it
}
public void destroyBuffers(){
//TODO: implement it
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?