Java Code Examples for javax.swing.JFrame.setBackground()

The following are Jave code examples for showing how to use setBackground() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: QN-ACTR-Release   File: QnactrSimulation.java   View Source Code Vote up 6 votes
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);
}
 
Example 2
Project: QN-ACTR-Release   File: QnactrSimulation.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: N-Queen-Puzzle-Knight-sTour   File: Knight.java   View Source Code Vote up 6 votes
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();
}
 
Example 4
Project: COE1186   File: DynamicDisplay.java   View Source Code Vote up 6 votes
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();
			}
		});
	}
 
Example 5
Project: LivroJavaComoProgramar10Edicao   File: Shapes2.java   View Source Code Vote up 5 votes
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);
}
 
Example 6
Project: N-Queen-Puzzle-Knight-sTour   File: Queen.java   View Source Code Vote up 5 votes
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);
 }
 
Example 7
Project: openjdk-jdk10   File: ComponentResizeTest.java   View Source Code Vote up 5 votes
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);
}
 
Example 8
Project: openjdk-jdk10   File: bug8041561.java   View Source Code Vote up 5 votes
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);
}