當前位置: 首頁>>代碼示例>>Java>>正文


Java Panel類代碼示例

本文整理匯總了Java中java.awt.Panel的典型用法代碼示例。如果您正苦於以下問題:Java Panel類的具體用法?Java Panel怎麽用?Java Panel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Panel類屬於java.awt包,在下文中一共展示了Panel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import java.awt.Panel; //導入依賴的package包/類
@Override
public void init() {
    tf = new TextField(20);
    tf.setText("0123456789");
    tf.select(0, 6);

    final TextArea ta = new TextArea("INSTRUCTIONS:\n"
                                     + "The text 012345 should be selected in the TextField.\n"
                                     + "If this is what you observe, then the test passes.\n"
                                     + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    ta.setEditable(false);
    ta.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(tf);
    setLayout(new BorderLayout());
    add(ta, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:SelectionVisible.java

示例2: createObjects

import java.awt.Panel; //導入依賴的package包/類
void createObjects() {
    textArea = new TextArea( bigString() );
    robot = Util.createRobot();

    Panel panel = new Panel();
    panel.setLayout( new GridLayout(3,3) );

    for( int y=0; y<3; ++y ) {
        for( int x=0; x<3; ++x ) {
            if( x==1 && y==1 ) {
                panel.add( textArea );
            } else {
                panel.add( new Panel() );
            }
        }
    }

    Frame frame = new Frame( "TextArea cursor icon test" );
    frame.setSize( 300, 300 );
    frame.add( panel );
    frame.setVisible( true );
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:23,代碼來源:SelectionAutoscrollTest.java

示例3: testCanHandleComplexData

import java.awt.Panel; //導入依賴的package包/類
public void testCanHandleComplexData() throws Exception {
    Panel p = new Panel();
    p.setForeground(Color.BLUE);
    
    FileObject template = FileUtil.createData(root, "some.txt");
    OutputStream os = template.getOutputStream();
    String txt = "<html><h1>${panel.foreground.red} ${panel.foreground.green} ${panel.foreground.blue}</h1></html>";
    os.write(txt.getBytes());
    os.close();
    template.setAttribute("panel", p);
    
    StringWriter w = new StringWriter();
    
    apply(template, w);
    
    String exp = "<html><h1>0 0 255</h1></html>";
    assertEquals(exp, w.toString());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ProcessorTest.java

示例4: init

import java.awt.Panel; //導入依賴的package包/類
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:WPrinterJob.java

示例5: createBorderPanel

import java.awt.Panel; //導入依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param center
 *
 * @return
 */
protected static Panel createBorderPanel(Component center) {

    Panel p = new Panel();

    p.setBackground(SystemColor.control);
    p.setLayout(new BorderLayout());
    p.add("Center", center);
    p.add("North", createLabel(""));
    p.add("South", createLabel(""));
    p.add("East", createLabel(""));
    p.add("West", createLabel(""));
    p.setBackground(SystemColor.control);

    return p;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:ConnectionDialog.java

示例6: DisplayPolytopeCanvasG3DSys

import java.awt.Panel; //導入依賴的package包/類
public DisplayPolytopeCanvasG3DSys(DisplayPolytope _box) {
    super(null);
	displayPolytope = _box;

	// init G3DSys
	// adding JPanel flickers, Panel does not. Nobody knows why.
	/*
	 * Set visible false here to be toggled later; seems to fix the
	 * 'sometimes gray' bug
	 */
	// this.setVisible(false); // to be set visible later by
	// SimulationGraphic
	panel = new Panel();
	this.setLayout(new java.awt.GridLayout());
	panel.setLayout(new java.awt.GridLayout());
	panel.setSize(1600, 1600);
	this.add(panel);
	gsys = new G3DSys(panel);
	setBackgroundColor(Color.BLACK);
	setBoundaryFrameColor(Color.WHITE);
}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:22,代碼來源:DisplayPolytopeCanvasG3DSys.java

示例7: init

import java.awt.Panel; //導入依賴的package包/類
@Override
public void init() {
    ta = new TextArea(4, 20);
    ta.setText("01234\n56789");
    ta.select(3, 9);

    final TextArea instruction = new TextArea("INSTRUCTIONS:\n"
                                             + "The text 34567 should be selected in the TextArea.\n"
                                             + "If this is what you observe, then the test passes.\n"
                                             + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    instruction.setEditable(false);
    instruction.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(ta);
    setLayout(new BorderLayout());
    add(instruction, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:SelectionVisible.java

示例8: getScaleFactor

import java.awt.Panel; //導入依賴的package包/類
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        final float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:MultiResolutionSplashTest.java

示例9: init

import java.awt.Panel; //導入依賴的package包/類
private void init()
{
	f = new Frame("Demo");
	bt1 = new Button("SIN");
	bt2 = new Button("COS");
	bt3 = new Button("EXIT");
	mc = new MyCanvas();
	p = new Panel();
	
	
	f.setBounds(100, 100, 500, 500);
	f.setLayout(new BorderLayout());

	p.add(bt1);
	p.add(bt2);
	p.add(bt3);
	f.add(p, BorderLayout.NORTH);
	f.add(mc, BorderLayout.CENTER);
	
	addEvent();
	f.setVisible(true);
}
 
開發者ID:pwn-orz,項目名稱:anti-fanmei,代碼行數:23,代碼來源:FunPlot.java

示例10: shouldFocusOnClick

import java.awt.Panel; //導入依賴的package包/類
public static boolean shouldFocusOnClick(Component component) {
    boolean acceptFocusOnClick = false;

    // A component is generally allowed to accept focus on click
    // if its peer is focusable. There're some exceptions though.


    // CANVAS & SCROLLBAR accept focus on click
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    if (component instanceof Canvas ||
        component instanceof Scrollbar)
    {
        acceptFocusOnClick = true;

    // PANEL, empty only, accepts focus on click
    } else if (component instanceof Panel) {
        acceptFocusOnClick = (((Panel)component).getComponentCount() == 0);


    // Other components
    } else {
        ComponentPeer peer = (component != null ? acc.getPeer(component) : null);
        acceptFocusOnClick = (peer != null ? peer.isFocusable() : false);
    }
    return acceptFocusOnClick && acc.canBeFocusOwner(component);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:KeyboardFocusManagerPeerImpl.java

示例11: initTestWindow

import java.awt.Panel; //導入依賴的package包/類
public static void initTestWindow() {
    mainFrame = new Frame();
    p1 = new Panel();
    mainFrame.setTitle("TestWindow");
    mainFrame.setBounds(700, 10, 400, 100);

    tf = new TextField(20);
    tf.select(0, 10);
    bt = new Button("Disable textfield");
    p1.add(tf);
    p1.add(bt);
    mainFrame.add(p1);
    bt.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            tf.setEditable(false);
        }
    });
    mainFrame.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:DisabledUndoTest.java

示例12: TestDialog

import java.awt.Panel; //導入依賴的package包/類
public TestDialog(Frame frame, String name) {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    buttonP = new Panel();
    passB = new Button("pass");
    passB.setActionCommand("pass");
    passB.addActionListener(this);
    buttonP.add("East", passB);

    failB = new Button("Fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("West", failB);

    add("South", buttonP);
    pack();
    setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:ScrollSelectionTest.java

示例13: createUI

import java.awt.Panel; //導入依賴的package包/類
private static void createUI() throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            background = new Frame();
            background.setUndecorated(true);
            background.setBackground(Color.blue);
            background.setSize(300, 300);
            background.setLocation(100, 100);
            background.setVisible(true);
            window = new Window(background);
            window.setBackground(Color.red);
            window.add(new Panel(), BorderLayout.CENTER);
            window.setLocation(200, 200);
            window.setSize(100, 100);
            Area a = new Area();
            a.add(new Area(new Rectangle2D.Double(0, 0, 100, 100)));
            window.setShape(a);
            window.setVisible(true);
            window.toFront();
        }
    });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:SetShapeTest.java

示例14: testPanelBackground

import java.awt.Panel; //導入依賴的package包/類
public void testPanelBackground() {
    Window window = new Frame();
    window.setBackground(Color.GREEN);
    Panel panel = new Panel();
    window.add(panel);
    window.pack();
    window.setVisible(true);
    if (panel.getBackground() != Color.GREEN) {
        window.dispose();
        throw new RuntimeException("Panel Background Color Not Valid");
    }
    window.dispose();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:ChildWindowProperties.java

示例15: TestFrame

import java.awt.Panel; //導入依賴的package包/類
public TestFrame(int width, int height) throws HeadlessException {
    super("Test Frame");
    setSize(width, height);
    mrImage = new TestMultiResolutionImage(width, height);

    Panel panel = new Panel(new FlowLayout()) {
        @Override
        public void paint(Graphics g) {
            super.paint(g);
            AffineTransform tx = ((Graphics2D) g).getTransform();
            mrImage.scaleX = tx.getScaleX();
            mrImage.scaleY = tx.getScaleY();
            Insets insets = getInsets();
            g.drawImage(mrImage, insets.left, insets.bottom, null);
        }
    };
    add(panel);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:WindowResizingOnMovingToAnotherDisplay.java


注:本文中的java.awt.Panel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。