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


Java Panel.setBackground方法代碼示例

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


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

示例1: 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

示例2: PointListDialog

import java.awt.Panel; //導入方法依賴的package包/類
/**
 * Constructs an empty PointListDialog
 * 
 * @param owner
 */
public PointListDialog(final Frame owner) {
	super(owner, "Point list");
	panel = new Panel();
	gridbag = new GridBagLayout();
	panel.setLayout(gridbag);

	panel.setBackground(Color.WHITE);
	c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.anchor = GridBagConstraints.NORTHWEST;
	c.weighty = 0.1f;
	c.fill = GridBagConstraints.NONE;
	final ScrollPane scroll = new ScrollPane();
	scroll.add(panel);
	add(scroll);
}
 
開發者ID:fiji,項目名稱:3D_Viewer,代碼行數:23,代碼來源:PointListDialog.java

示例3: displayColors

import java.awt.Panel; //導入方法依賴的package包/類
private void displayColors(World world) {
	this.setSize(600, 800);
	
	for (byte i = 1; i <= num; i++) {
		Panel pnl = new Panel();
		pnl.setPreferredSize(new Dimension(pnlSize + 8, pnlSize + 32));
		Panel col = new Panel();
		col.setPreferredSize(new Dimension(pnlSize, pnlSize));
		col.setBackground(world.getType(i).getColor());
		pnl.add(col);
		Label lb = new Label();
		lb.setText(world.getType(i).getName() + " " + Integer.toString(i));
		pnl.add(lb);
		add(pnl);
	}
}
 
開發者ID:matortheeternal,項目名稱:JVoxelEngine,代碼行數:17,代碼來源:WorldTester.java

示例4: createBorderPanel

import java.awt.Panel; //導入方法依賴的package包/類
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:tiweGH,項目名稱:OpenDiabetes,代碼行數:16,代碼來源:ConnectionDialog.java

示例5: createBorderPanel

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

    Panel p = new Panel();

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

    return p;
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:21,代碼來源:Transfer.java

示例6: createBorderPanel

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

    Panel p = new Panel();

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

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

示例7: initGUI

import java.awt.Panel; //導入方法依賴的package包/類
/**
 * Create the graphical user interface. This is AWT code.
 */
private void initGUI() {

    // all panels
    Panel pQuery       = new Panel();
    Panel pCommand     = new Panel();
    Panel pButton      = new Panel();
    Panel pRecent      = new Panel();
    Panel pResult      = new Panel();
    Panel pBorderWest  = new Panel();
    Panel pBorderEast  = new Panel();
    Panel pBorderSouth = new Panel();

    pQuery.setLayout(new BorderLayout());
    pCommand.setLayout(new BorderLayout());
    pButton.setLayout(new BorderLayout());
    pRecent.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());
    pBorderWest.setBackground(SystemColor.control);
    pBorderSouth.setBackground(SystemColor.control);
    pBorderEast.setBackground(SystemColor.control);

    // labels
    Label lblCommand = new Label(" Command", Label.LEFT);
    Label lblRecent  = new Label(" Recent", Label.LEFT);
    Label lblResult  = new Label(" Result", Label.LEFT);

    lblCommand.setBackground(SystemColor.control);
    lblRecent.setBackground(SystemColor.control);
    lblResult.setBackground(SystemColor.control);

    // buttons
    butExecute = new Button("Execute");
    butScript  = new Button("Script");
    butImport  = new Button("Import");

    pButton.add("South", butScript);
    pButton.add("Center", butExecute);
    pButton.add("North", butImport);

    // command - textarea
    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new TextArea(5, 40);

    txtCommand.setFont(fFont);

    // recent - choice
    choRecent = new Choice();

    // result - grid
    gResult = new Grid();

    // combine it
    setLayout(new BorderLayout());
    pRecent.add("Center", choRecent);
    pRecent.add("North", lblRecent);
    pCommand.add("North", lblCommand);
    pCommand.add("East", pButton);
    pCommand.add("Center", txtCommand);
    pCommand.add("South", pRecent);
    pResult.add("North", lblResult);
    pResult.add("Center", gResult);
    pQuery.add("North", pCommand);
    pQuery.add("Center", pResult);
    add("Center", pQuery);
    add("West", pBorderWest);
    add("East", pBorderEast);
    add("South", pBorderSouth);

    // [email protected] 20011210 - patch 450412 by [email protected]
    doLayout();
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:76,代碼來源:QueryTool.java

示例8: ComponentIsNotDrawnAfterRemoveAddTest

import java.awt.Panel; //導入方法依賴的package包/類
public ComponentIsNotDrawnAfterRemoveAddTest() {
    frame = new Frame("ComponentIsNotDrawnAfterRemoveAddTest");
    frame.setSize(500, 500);
    frame.setLocation(200, 200);
    frame.setLayout(null);
    frame.setBackground(Color.RED);

    panel = new Panel();
    panel.setLayout(null);
    panel.setBounds(25, 100, 455, 295);
    panel.setBackground(Color.GREEN);

    for (int i = 0; i < 10; i++) {
        TestCanvas canv1 = new TestCanvas();
        canv1.setBounds(i * 45 + 5, 15, 30 + i, 30 + i);
        panel.add(canv1);
        compList.add(canv1);

        TestButton btn1 = new TestButton();
        btn1.setBounds(i * 45 + 5, 60, 30 + i, 30 + i);
        panel.add(btn1);
        compList.add(btn1);

        TestCanvas canv2 = new TestCanvas();
        canv2.setBounds(i * 45 + 5, 105, 30 + i, 30 + i);
        panel.add(canv2);
        compList.add(canv2);

        TestButton btn2 = new TestButton();
        btn2.setBounds(i * 45 + 5, 150, 30 + i, 30 + i);
        panel.add(btn2);
        compList.add(btn2);

        TestCanvas canv3 = new TestCanvas();
        canv3.setBounds(i * 45 + 5, 195, 30 + i, 30 + i);
        panel.add(canv3);
        compList.add(canv3);

        TestButton btn3 = new TestButton();
        btn3.setBounds(i * 45 + 5, 240, 30 + i, 30 + i);
        panel.add(btn3);
        compList.add(btn3);
    }

    frame.add(panel);
    frame.setVisible(true);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:48,代碼來源:ComponentIsNotDrawnAfterRemoveAddTest.java

示例9: displayDecisionVariables

import java.awt.Panel; //導入方法依賴的package包/類
private void displayDecisionVariables() {

		Panel dvPanel = new Panel();

    ScrollPane scrollPane = new ScrollPane();

		GroupLayout dvlayout = new GroupLayout(dvPanel);
		dvlayout.setAutoCreateGaps(true);
		dvlayout.setAutoCreateContainerGaps(true);

		ParallelGroup groupForElementsInLine = dvlayout.createParallelGroup(Alignment.LEADING);
		SequentialGroup groupForElementsInColumns = dvlayout.createSequentialGroup();

		for (Displayable displayable : decisionVariables) {

			List<InfoGUI> infos = displayable.getInfo();

			for (InfoGUI infoGUI : infos) {
				DecisionVariableGUI dvGui1 = new DecisionVariableGUI(infoGUI);
				groupForElementsInLine.addGroup((dvlayout.createSequentialGroup().addComponent(dvGui1.getLabel())
						.addComponent(dvGui1.getComponent())));
				groupForElementsInColumns.addGroup((dvlayout.createParallelGroup(Alignment.CENTER)
						.addComponent(dvGui1.getLabel()).addComponent(dvGui1.getComponent())));
				mapWithControls.add(dvGui1);
			}

		}

		dvlayout.setHorizontalGroup(groupForElementsInLine);
		dvlayout.setVerticalGroup(groupForElementsInColumns);
		dvPanel.setLayout(dvlayout);
		dvPanel.setBackground(Color.lightGray);

		Collections.sort(mapWithControls);

		Dimension scrollPaneDimension = new Dimension(dvPanel.getPreferredSize().width + 30,
				dvPanel.getPreferredSize().height + 35);

		scrollPane.setPreferredSize(new Dimension(250, 700));

		if (scrollPaneDimension.height < scrollPane.getPreferredSize().height) {
			scrollPane.setPreferredSize(scrollPaneDimension);
		}

		scrollPane.add(dvPanel);
		controlPanel.add(scrollPane);
	}
 
開發者ID:siemens,項目名稱:JMiniZinc,代碼行數:48,代碼來源:VariableDialog.java

示例10: MakeMyDialog

import java.awt.Panel; //導入方法依賴的package包/類
public MakeMyDialog (int X, int Y, int width, int height, Color fg, Color bg, String title,
    String text, boolean oneLine) {

    // Create a frame from which we will launch a dialog warning window

    final Frame mw = new Frame(title);
    mw.setLayout(new BorderLayout());
    mw.setSize(width,height);
    mw.setLocation(X,Y);
    Label hT = new Label(text,Label.CENTER);
    hT.setForeground(fg);
    hT.setBackground(bg);
    hT.setFont(warnFont);
    mw.add("Center", hT);
    mw.setTitle(title);

    // Add show warning button

    Panel botPanel = new Panel();
    botPanel.setBackground(Color.lightGray);
    Label label1 = new Label();
    Label label2 = new Label();

    Button showButton = new Button("Show Modal Warning Window");
    botPanel.add(label1);
    botPanel.add(showButton);
    botPanel.add(label2);

    // Add inner class event handler for show warning button.  This must be
    // added to the showButton before botPanel is added to mw.

    showButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae){ 
            MakeMyDialog.this.makeTheWarning(200,200,200,100,Color.black,
                Color.lightGray,"Warning","Warning message",
                true, MakeMyDialog.this);
        }
    });

    mw.add("South", botPanel);

    // Add window closing button (inner class)

    mw.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            mw.hide();
            mw.dispose();
            System.exit(0);
        }
    });

    mw.show();
}
 
開發者ID:jayjaybillings,項目名稱:fern,代碼行數:54,代碼來源:MakeMyDialog.java

示例11: GenericHelpFrame

import java.awt.Panel; //導入方法依賴的package包/類
public GenericHelpFrame(String s, String t, int h, int w, int X,int Y, int lines, int columns) {

      Font textFont = new java.awt.Font("SanSerif", Font.PLAIN, 12);
      FontMetrics textFontMetrics = getFontMetrics(textFont);
      Font buttonFont = new java.awt.Font("SanSerif", Font.BOLD, 11);
      FontMetrics buttonFontMetrics = getFontMetrics(buttonFont);
      Color bgColor = MyColors.helpColor; //new Color(245,245,245);

      this.pack();
      this.setSize(w,h);
      this.setLocation(X,Y);
      this.setTitle(t);
      this.setResizable(false);

      setLayout(new BorderLayout());

      TextArea hT = new TextArea("",lines,columns, TextArea.SCROLLBARS_NONE);
      hT.setEditable(false);

      // Set color and font for TextArea.

      hT.setForeground(Color.black);
      hT.setFont(textFont);
      hT.setBackground(bgColor);
      // hT.disable();

      ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
      sp.add(hT);
      this.add("Center", sp);

      Panel leftPanel = new Panel();
      leftPanel.setBackground(MyColors.gray204);

      this.add("West",leftPanel);

      // Add Dismiss button and bottom panel

      Panel botPanel = new Panel();
      botPanel.setFont(buttonFont);
      botPanel.setBackground(MyColors.gray204);
      Button dismissButton = new Button("Cancel");
      botPanel.add(dismissButton);
      this.add("South", botPanel);

      // Insert the text string in the TextArea

      hT.appendText("\n" + s);

      // Add inner class event handler for Dismiss button

      dismissButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae){
              hide();
              dispose();
              ParamSetup.helpWindowOpen = false;
          }
      });

      // Add window closing button (inner class)

      this.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
            hide();
            dispose();
            ParamSetup.helpWindowOpen = false;
         }
      });
   }
 
開發者ID:jayjaybillings,項目名稱:fern,代碼行數:69,代碼來源:GenericHelpFrame.java


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