javax.swing.JWindow#getContentPane ( )源码实例Demo

下面列出了javax.swing.JWindow#getContentPane ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Rails   文件: SplashWindow.java
public SplashWindow(boolean isLoad, String initDetailsText) {
    //quit directly when no visualization required
    //all visualization related attributes remain null then
    if ("no".equals(Config.get("splash.window.open"))) return;

    //calculate estimated duration for the respective steps
    cumulativeDuration = new long[STEP_DURATION.length];
    boolean isDockingLayout = "yes".equals(Config.get("or.window.dockablePanels"));
    for ( int i = 0; i < STEP_DURATION.length ; i++) {
        //only consider step if relevant for this setup
        if ( (isLoad || !STEP_GROUP_LOAD.contains(STEP_DURATION[i].labelConfigKey))
                &&
             (isDockingLayout || !STEP_GROUP_DOCKING_LAYOUT.contains(STEP_DURATION[i].labelConfigKey)) ) {
            totalDuration += STEP_DURATION[i].expectedDurationInMillis;
        }
        cumulativeDuration[i] = totalDuration;
    }

    //set up dynamic elements

    myWin = new JWindow();

    leftIcon = new JLabel();
    setIcon(leftIcon, ICONS[currentIconIndex][0]);
    leftIcon.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5),new EtchedBorder()));
    rightIcon = new JLabel();
    setIcon(rightIcon, ICONS[currentIconIndex][1]);
    rightIcon.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5),new EtchedBorder()));

    progressBar = new JProgressBar(0,(int)totalDuration);
    progressBar.setStringPainted(true);
    progressBar.setMinimum(0);

    stepLabel = new JLabel(" "); // needed in order to allocate vertical space
    stepLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
    stepLabel.setBorder(new EmptyBorder(5,5,5,5));

    //set up static elements

    JLabel railsLabel = new JLabel("Rails " +Config.getVersion());
    railsLabel.setFont(railsLabel.getFont().deriveFont(
            (float)2.0 * railsLabel.getFont().getSize()));
    railsLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

    String commandTextKey = isLoad ? "Splash.command.loadGame" : "Splash.command.newGame";
    JLabel commandLabel = new JLabel(
            LocalText.getText(commandTextKey,initDetailsText));
    commandLabel.setFont(commandLabel.getFont().deriveFont(Font.BOLD));
    commandLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

    //plug elements together and set up layout

    JPanel railsCommandPanel = new JPanel();
    railsCommandPanel.setLayout(new BoxLayout(railsCommandPanel, BoxLayout.Y_AXIS));
    railsCommandPanel.add(railsLabel);
    railsCommandPanel.add(commandLabel);
    railsCommandPanel.setBorder(new EmptyBorder(3,3,3,3));

    JPanel idPanel = new JPanel();
    idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS));
    idPanel.add(leftIcon);
    idPanel.add(railsCommandPanel);
    idPanel.add(rightIcon);
    idPanel.setBorder(new EmptyBorder(3,3,3,3));

    JComponent contentPane = (JComponent)myWin.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    contentPane.add(idPanel);
    contentPane.add(progressBar);
    contentPane.add(stepLabel);
    contentPane.setBorder(new CompoundBorder(new EtchedBorder(),new EmptyBorder(5,5,5,5)));

    //perform layout within the EDT
    //blocking call as further initialization requires the layout to be frozen
    try {
        SwingUtilities.invokeAndWait(new Thread() {
            @Override
            public void run() {
                myWin.pack();
                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                myWin.setLocation(
                      (dim.width - myWin.getSize().width) / 2,
                      (dim.height - myWin.getSize().height) / 2
                );
                myWin.setVisible(true);
            }
        });
    } catch (Exception e) {}

    progressVisualizer = new ProgressVisualizer();
    notifyOfStep(DUMMY_STEP_START);
    progressVisualizer.start();
}
 
源代码2 项目: Astrosoft   文件: PrintDialog.java
private Window createPanchangInputWindow(){
	
	JWindow window = new JWindow(this);
	
	Container windowPane = window.getContentPane(  );
	
	windowPane.setLayout(new BorderLayout());
	
	spinner = new CalendarSpinner(CalendarSpinner.FMT_MONTH_YEAR);
	
	spinner.addDateListener( new DateListener () {

		public void dateChanged(Date date) {
			
			outputFileChooser.setFilePath(getPanchangOutputFile(date));
		}
		
	});
	
	JPanel panChooser = spinner.getChooser();
	JPanel p = new JPanel();
	
	p.add(panChooser);
	p.add(fullYear);
	
	p.setBackground(UIConsts.CAL_COMBO_BACKGROUND);
	p.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
	
	windowPane.add(p, BorderLayout.CENTER);
	
	window.pack();
	
	fullYear.addActionListener(new ActionListener(){

		public void actionPerformed(ActionEvent e) {
			outputFileChooser.setFilePath(getPanchangOutputFile(spinner.getSelectedDate()));
		}
	});
	return window;
}