[´äº¯]¾ÖÇø´¿¡¼­ ÇÁ¸°Æ®ÇÏ´Â ¹ý°ú CardLayout ¿¹Á¦


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :Á¶½ÅÁ¦ 1998³â 7¿ù 25ÀÏ 20:10:52

In Reply to: [Áú¹®] Á¶½ÅÁ¦´Ô²² (¾ÖÇø´ ÇÁ¸°Æ®Çϴ¹ý) posted by ÃÖÁ¾Ã¶ on 1998³â 7¿ù 25ÀÏ 18:15:10:

Á¦°¡ ÀÚ¹Ù¸¦ °øºÎÇϸ鼭 ¿©±â¼­ ¸¹Àº Á¤º¸¸¦ ¾ò¾î
°¬°Åµç¿ä..
¸¹ÀÌ ¾ò¾î °¡±â¸¸ ÇÏ°í ³»°¡ ÁÖ´Â °ÍÀ» ³Ê¹« ¾ø´Â °Í
°°¾Æ¼­ ¿äÁò¿¡´Â ¿©±â µé¾î¿ÔÀ» ¶§ Á¦°¡ ¾Æ´Â°Ô ÀÖÀ¸¸é
¸îÀÚ Àû¾î ³õ°í ³ª°¬´Âµ¥...
Á» ¸¹¾Ò³ª º¸ÁÒ? ^^;


ÃÖÁ¾Ã¶´Ô²²¼­ Áú¹®ÇϽг»¿ëÀÌ Á¶±Ý ¾Ö¸ÅÇϳ׿ä..
¾ÖÇø´À» ¶ç¿üÀ» ¶§ ±×¸ð¾çÀ» ÇÁ¸°Æ®ÇÏ°í ½ÍÀº°ÇÁö,
¾Æ´Ï¸é ¾ÖÇø´¿¡¼­ ÇÁ¸°Æ® ÀÛ¾÷À» Çϰí½ÍÀº°ÇÁö Àß ¸ð¸£
°ÚÁö¸¸ ÀÏ´Ü µÎ°¡Áö¸¦ ´Ù Á¦°¡ ¾Æ´Â´ë·Î ¸»¾¸µå·Á º¸°Ú½À´Ï´Ù.


¾ÖÇø´À» ¶ç¿î ¸ð¾çÀ» ÇÁ¸°Æ® ÇÏ°í ½ÍÀ¸¸é À©µµ¿ì ȯ°æ¿¡¼­´Â
ALT + PrintScreen ¹öưÀ» ´©¸£¸é ½Ã½ºÅÛ Å¬¸³º¸µå¿¡
ÀúÀåÀÌ µÇ´Ï±î PhotoShopµîÀÇ ±×¸²Åø¿¡¼­ copy¸¸ ÇÏ¸é µÇ±¸¿ä.


ÀÌ°Ô ¾Æ´Ï¶ó ÇÁ·Î±×·¥À» ÀÌ¿ëÇÏ¿© ÇÁ¸°Æ® ÀÛ¾÷À» Çϰí
½Í´Ù¸é ½ºÆ®¸²(ObjectStream)À» ÅëÇØ ¼­¹öÃøÀ¸·Î µ¥ÀÌŸ¸¦
º¸³½ ÈÄ ¼­¹ö°¡ ÇÁ¸°Æ® ÀÛ¾÷À» ÇØ¾ß ÇÏ´Â °É·Î ¾Ë¾Æ¿ä.
¼­¹ö°¡ ÇÁ¸°Æ®ÀÛ¾÷À» ÇÏ´Â °ÍÀ» ¾îÇø®ÄÉÀ̼ǿ¡¼­ ÇÁ¸°Æ®
ÇÏ´Â °Í°ú °°À¸´Ï±î
¾Æ·¡ÀÇ ÇÁ·Î±×·¥À» Âü°íÇÏ¸é µË´Ï´Ù.


------< PrintExample.java >----------


import java.awt.*;
import java.awt.event.*;
import java.util.*;


public class PrintScribble extends Frame {
private short last_x = 0, last_y = 0; // last click posistion
private Vector lines = new Vector(256,256); // store the scribble
private Properties printprefs = new Properties(); // store user preferences


public PrintScribble() {
super("PrintScribble");


// Add a print button.
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
Button b = new Button("Print");
this.add(b);


// Call the print() method when the button is clicked.
// Note anonymous class.
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { print(); }
});


// Exit when the user closes the window.
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { System.exit(0); }
});


// Register other event types we're interested in -- for scribbling
enableEvents(AWTEvent.MOUSE_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK);


// Set our initial size and pop the window up.
this.setSize(400, 400);
this.show();
}


/** Redraw (or print) the scribble based on stored lines */
public void paint(Graphics g)
{
for(int i = 0; i < lines.size(); i++) {
Line l = (Line)lines.elementAt(i);
g.drawLine(l.x1, l.y1, l.x2, l.y2);
}
}


/** Print out the scribble */
void print() {
// Obtain a PrintJob and a Graphics object to use with it
Toolkit toolkit = this.getToolkit();
PrintJob job = toolkit.getPrintJob(this, "PrintScribble", printprefs);
if (job == null) return; // If the user clicked Cancel in the print dialog
Graphics g = job.getGraphics();


// Give the output a larger top and left margin. Otherwise it will
// be scrunched up in the upper-left corner of the page.
g.translate(100, 100);


// Draw a border around the output area.
Dimension size = this.getSize();
g.drawRect(-1, -1, size.width+1, size.height+1);


// Set a clipping region so our scribbles don't go outside the border
// On-screen this happens automatically, but not on paper.
g.setClip(0, 0, size.width, size.height);


// Print this component and all components it contains
this.printAll(g); // Use print() if you don't want the button to show


// Finish up.
g.dispose(); // End the page
job.end(); // End the job
}


/** Called when the user clicks */
public void processMouseEvent(MouseEvent e)
{
if (e.getID() == MouseEvent.MOUSE_PRESSED) {
last_x = (short)e.getX(); // remember click position
last_y = (short)e.getY();
}
else super.processMouseEvent(e);
}


/** Called when the the user drags the mouse: does the scribbling */
public void processMouseMotionEvent(MouseEvent e)
{
if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
Graphics g = getGraphics();
g.drawLine(last_x, last_y, e.getX(), e.getY()); // draw the line
lines.addElement(new Line(last_x, last_y, // and save the line
(short) e.getX(), (short)e.getY()));
last_x = (short) e.getX(); last_y = (short) e.getY();
}
else super.processMouseMotionEvent(e);
}


/** The main method. Create a PrintScribble() object and away we go! */
public static void main(String[] args)
{
PrintScribble s = new PrintScribble();
}


/** This nested toplevel helper class stores the coordinates
* of one line of the scribble. */
class Line {
public short x1, y1, x2, y2;
public Line(short x1, short y1, short x2, short y2) {
this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
}
}
}


±×¸®°í CardLayout¿¹Á¦´Â ¾Æ·¡¸¦ Âü°íÇϼ¼¿ä.


------< CardLayoutExample.java >----------


/*

*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;


public class CardLayoutExample extends Applet {
public void init() {
// Create a layout manager, and save a reference to it for future use.
// This CardLayout leaves 10 pixels margins around the component.
final CardLayout cardlayout = new CardLayout(10, 10);
// Specify the layout manager for the applet
this.setLayout(cardlayout);
for(int i = 1; i <= 9; i++) {
Button b = new Button("Button #" + i);
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) { // When button is clicked
cardlayout.next(CardLayoutExample.this); // display the next one.
}
};
b.addActionListener(listener);
this.add("Button" + i, b); // Specify a name for each component
}
}
}



¸¹Àº µµ¿òÀÌ µÇ¾úÀ¸¸é ÁÁ°Ú³×¿ä....
^^;


´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]