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


Java JFrame.setBackground方法代碼示例

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


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

示例1: createAndShowTaskVisualization2DViewerGUI

import javax.swing.JFrame; //導入方法依賴的package包/類
public static void createAndShowTaskVisualization2DViewerGUI() {
  frameTaskVisualization2DViewer  = new JFrame("TaskVisualization2DViewer");
  frameTaskVisualization2DViewer.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
  
  taskVisualization2D = new TaskVisualization2D();
  taskVisualization2D.setOpaque(true); //content panes must be opaque
  frameTaskVisualization2DViewer.setContentPane(taskVisualization2D);

  frameTaskVisualization2DViewer.pack();
  frameTaskVisualization2DViewer.setLocationByPlatform(true);
  frameTaskVisualization2DViewer.setVisible(true);
  
  int x = simulatedWindowDefaultSizeX + taskVisualization2DExtendSizeX;
  int y = simulatedWindowDefaultSizeY + taskVisualization2DExtendSizeY;
  
  frameTaskVisualization2DViewer.setSize(x, y);
  frameTaskVisualization2DViewer.setBackground(Color.WHITE);
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:19,代碼來源:QnactrSimulation.java

示例2: createAndShowTaskVisualization3DViewerGUI

import javax.swing.JFrame; //導入方法依賴的package包/類
public static void createAndShowTaskVisualization3DViewerGUI() {
  frameTaskVisualization3DViewer  = new JFrame("TaskVisualization3DViewer");
  frameTaskVisualization3DViewer.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
  
  taskVisualization3D = new TaskVisualization3D();
  taskVisualization3D.setOpaque(true); //content panes must be opaque
  frameTaskVisualization3DViewer.setContentPane(taskVisualization3D);

  frameTaskVisualization3DViewer.pack();
  frameTaskVisualization3DViewer.setLocationByPlatform(true);
  frameTaskVisualization3DViewer.setVisible(true);
  
  int x = taskVisualization3DSizeX;
  int y = taskVisualization3DSizeY;
  
  frameTaskVisualization3DViewer.setSize(x, y);
  frameTaskVisualization3DViewer.setBackground(Color.WHITE);
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:19,代碼來源:QnactrSimulation.java

示例3: main

import javax.swing.JFrame; //導入方法依賴的package包/類
public static void main(String[] args){
    dimension = Integer.parseInt(args[0]);
    size = Integer.parseInt(args[1]);
    //margin = (args[2].equals("1")) ? size : 0;
    bigDim = dimension + 4;
    dim = dimension * size;
    
    frame = new JFrame();
    frame.setSize(dim+2*margin, dim+2*margin+size/2);
    frame.getContentPane().add(new Knight());
    frame.setLocationRelativeTo(null);
    frame.setBackground(Color.LIGHT_GRAY);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    
    JButton btnNext = new JButton();
    btnNext.setVisible(true);
    frame.add(btnNext);
    btnNext.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
            step++;
          }
    });
    start();
}
 
開發者ID:OzodbekKamolov,項目名稱:N-Queen-Puzzle-Knight-sTour,代碼行數:26,代碼來源:Knight.java

示例4: initializeFrame

import javax.swing.JFrame; //導入方法依賴的package包/類
public void initializeFrame(){

		// Main frame
		f = new JFrame("Dynamic Simulation Display");
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setSize(DYNAMIC_FRAME_WIDTH, DYNAMIC_FRAME_HEIGHT);
		f.setUndecorated(true);
		f.setBackground(Color.BLACK);
		f.setLayout(null);
		f.setLocationRelativeTo(null);
		f.setResizable(false);
		f.add(new JLabel("test label"));

		// Add the dynamic track view panel
		f.add(dynamicTrackView);

		dynamicTrackView.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				dynamicTrackView.showArrows = !dynamicTrackView.showArrows;
				dynamicTrackView.refresh();
			}
		});
	}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:25,代碼來源:DynamicDisplay.java

示例5: main

import javax.swing.JFrame; //導入方法依賴的package包/類
public static void main(String[] args)
{
   // create frame for Shapes2JPanel
   JFrame frame = new JFrame("Drawing 2D Shapes");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   Shapes2JPanel shapes2JPanel = new Shapes2JPanel(); 
   frame.add(shapes2JPanel); 
   frame.setBackground(Color.WHITE);
   frame.setSize(315, 330);
   frame.setVisible(true);
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:13,代碼來源:Shapes2.java

示例6: main

import javax.swing.JFrame; //導入方法依賴的package包/類
public static void main(String[] args){

 dimension = Integer.parseInt(args[0]);
 size = Integer.parseInt(args[1]);
 dim = dimension * size;
 JFrame frame = new JFrame();
 frame.setSize(dim+2* + margin, dim+2* + margin + size / 2);
 frame.getContentPane().add(new Queen());
 frame.setLocationRelativeTo(null);
 frame.setBackground(Color.LIGHT_GRAY);
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 frame.setVisible(true);
 t = new char[dimension][dimension];
     enumerate(dimension);
 }
 
開發者ID:OzodbekKamolov,項目名稱:N-Queen-Puzzle-Knight-sTour,代碼行數:16,代碼來源:Queen.java

示例7: createAndShowGUI

import javax.swing.JFrame; //導入方法依賴的package包/類
private static void createAndShowGUI() {
    demoFrame = new JFrame();
    demoFrame.setSize(300, 300);
    demoFrame.setLayout(new FlowLayout());
    demoFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    demoFrame.setUndecorated(true);
    demoFrame.setBackground(new Color(0f, 0, 0, 0.1f));
    JCheckBox b = new JCheckBox("Whatever");
    demoFrame.paintAll(null);
    b.setOpaque(true);
    demoFrame.add(b);
    demoFrame.add(new JButton());
    demoFrame.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:ComponentResizeTest.java

示例8: createAndShowGUI

import javax.swing.JFrame; //導入方法依賴的package包/類
private static void createAndShowGUI() {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBackground(Color.BLUE);
    radioButton = new JRadioButton();
    radioButton.setOpaque(false);
    JPanel panel = new JPanel();
    panel.setBackground(Color.BLUE);
    panel.add(radioButton);
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:bug8041561.java


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