Java Code Examples for java.awt.Container#setLayout()

The following examples show how to use java.awt.Container#setLayout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SessionFrame.java    From rest-client with Apache License 2.0 6 votes vote down vote up
public SessionFrame(String title){
    super(title);
    me = this;
    
    Container c = this.getContentPane();
    c.setLayout(new BorderLayout());
    
    jt.setPreferredSize(new Dimension(200, 300));
    c.add(new JScrollPane(jt), BorderLayout.CENTER);
    
    this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we){
            int confirmValue = JOptionPane.showConfirmDialog(me, "You will loose any unsaved session data if you\n" +
                    " close the Session Window. Do you want to close?", "Close Session Window?", JOptionPane.YES_NO_OPTION);
            if(confirmValue == JOptionPane.YES_OPTION){
                stm.clear();
                me.setVisible(false);
            }
        }
    });
    
    pack();
}
 
Example 2
Source File: Test8039464.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
Example 3
Source File: TextViewerWindow.java    From LoboBrowser with MIT License 6 votes vote down vote up
public TextViewerWindow() {
  super("LoboBrowser Console");
  final UserAgentContext uaContext = null; // TODO
  this.setIconImage(DefaultWindowFactory.getInstance().getDefaultImageIcon(uaContext).getImage());
  final JMenuBar menuBar = this.createMenuBar();
  this.setJMenuBar(menuBar);
  final Container contentPane = this.getContentPane();
  final JTextArea textArea = createTextArea();
  this.textArea = textArea;
  contentPane.setLayout(WrapperLayout.getInstance());
  contentPane.add(new JScrollPane(textArea));
  this.addWindowListener(new java.awt.event.WindowAdapter() {
    @Override
    public void windowClosed(final WindowEvent e) {
      final DocumentListener cl = cachedListener;
      if (cl != null) {
        final Document prevDocument = textArea.getDocument();
        if (prevDocument != null) {
          prevDocument.removeDocumentListener(cl);
        }
      }
    }
  });
}
 
Example 4
Source File: EquipCustomizerDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void initComponents()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	pane.add(equipCustomPanel, BorderLayout.CENTER);

	ButtonBar buttonBar = new OKCloseButtonBar(
			this::doOK,
			this::doCancel
	);

	Button buyButton = new Button(LanguageBundle.getString("in_buy"));
	buttonBar.getButtons().add(buyButton);

	pane.add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END);
	Utility.installEscapeCloseOperation(this);
}
 
Example 5
Source File: TrackingPong.java    From marvinproject with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void loadGUI(){	
	setTitle("Video Sample - Tracking Pong");
	
	videoPanel.addMouseListener(new MouseHandler());
	
	sliderSensibility = new JSlider(JSlider.HORIZONTAL, 0, 60, 30);
	sliderSensibility.setMinorTickSpacing(2);
	sliderSensibility.setPaintTicks(true);
	sliderSensibility.addChangeListener(new SliderHandler());
	
	labelSlider = new JLabel("Sensibility");
	
	panelSlider = new JPanel();
	panelSlider.add(labelSlider);
	panelSlider.add(sliderSensibility);
	
	Container container = getContentPane();
	container.setLayout(new BorderLayout());
	container.add(videoPanel, BorderLayout.NORTH);
	container.add(panelSlider, BorderLayout.SOUTH);
	
	setSize(videoInterface.getImageWidth()+20,videoInterface.getImageHeight()+100);
	setVisible(true);
}
 
Example 6
Source File: Test8039464.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
Example 7
Source File: SlowPanelIteration.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void showUI() {
    frame = new JFrame();
    frame.setSize(new Dimension(400, 400));
    frame.setLocationRelativeTo(null);

    final Container content = frame.getContentPane();
    content.setLayout(new BorderLayout(0, 0));
    Container lastPanel = content;
    for (int i = 0; i < 500; i++) {
        final JPanel p = new JPanel();
        p.setLayout(new BorderLayout(0, 0));
        lastPanel.add(p);
        lastPanel.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                System.out.println("click");
                go.countDown();
            }
        });
        lastPanel = p;
    }

    lastPanel.setBackground(Color.GREEN);
    frame.setVisible(true);

    Point loc = frame.getLocationOnScreen();
    center.x = loc.x + frame.getWidth() / 2;
    center.y = loc.y + frame.getHeight() / 2;
}
 
Example 8
Source File: Regression_116619_swing.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Contructs the layout with a container for displaying chart and a control
 * panel for selecting interactivity.
 * 
 * @param args
 */
public static void main( String[] args )
{
	final Regression_116619_swing siv = new Regression_116619_swing( );

	JFrame jf = new JFrame( );
	jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
	jf.addComponentListener( siv );

	Container co = jf.getContentPane( );
	co.setLayout( new BorderLayout( ) );
	co.add( siv, BorderLayout.CENTER );

	Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( );
	Dimension dApp = new Dimension( 600, 400 );
	jf.setSize( dApp );
	jf.setLocation(
			( dScreen.width - dApp.width ) / 2,
			( dScreen.height - dApp.height ) / 2 );

	jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$
			+ siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$

	ControlPanel cp = siv.new ControlPanel( siv );
	co.add( cp, BorderLayout.SOUTH );

	siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv );

	jf.addWindowListener( new WindowAdapter( ) {

		public void windowClosing( WindowEvent e )
		{
			siv.idr.dispose( );
		}

	} );

	jf.setVisible( true );
}
 
Example 9
Source File: OkCancelDialog.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public OkCancelDialog(String title, JPanel panel, boolean modal)
{
    setTitle(title);
    setModal(modal);
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    pane.add(panel, "Center");
    pane.add(new OkCancelButtonPanel(this), "South");
    pack();
    CommonUI.centerComponent(this);
}
 
Example 10
Source File: CrashDialog.java    From AMIDST with GNU General Public License v3.0 5 votes vote down vote up
public CrashDialog(String message) {
	super("AMIDST encountered an unexpected error.");
	Container contentPane = getContentPane();
	contentPane.setLayout(new MigLayout());
	
	add(new JLabel("AMIDST has crashed with the following message:"), "growx, pushx, wrap");
	add(new JLabel(message), "growx, pushx, wrap");
	
	JTextArea logText = new JTextArea(LogRecorder.getContents());

	JScrollPane scrollPane = new JScrollPane(logText);
	scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	
	logText.setFont(new Font("arial", Font.PLAIN, 10));
	scrollPane.setBorder(new LineBorder(Color.darkGray, 1));
	
	add(scrollPane,"grow, push");
	
	setSize(500, 400);
	setVisible(true);
	
	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			dispose();
			System.exit(4);
		}
	});
	
}
 
Example 11
Source File: OkCancelDialog.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public OkCancelDialog(String title, JPanel panel, boolean modal)
{
    setTitle(title);
    setModal(modal);
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    pane.add(panel, "Center");
    pane.add(new OkCancelButtonPanel(this), "South");
    pack();
    CommonUI.centerComponent(this);
}
 
Example 12
Source File: JGlassPaneInternalFrameOverlapping.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void prepareControls() {
    JFrame frame = new JFrame("Glass Pane children test");
    frame.setLayout(null);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new BorderLayout());
    super.propagateAWTControls(contentPane);

    Container glassPane = (Container) frame.getRootPane().getGlassPane();
    glassPane.setVisible(true);
    glassPane.setLayout(null);

    internalFrame = new JInternalFrame("Internal Frame", true);
    internalFrame.setBounds(50, 0, 200, 100);
    internalFrame.setVisible(true);
    glassPane.add(internalFrame);

    internalFrame.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            lwClicked = true;
        }
    });

    frame.setSize(300, 180);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
Example 13
Source File: JFileChooser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates and returns a new <code>JDialog</code> wrapping
 * <code>this</code> centered on the <code>parent</code>
 * in the <code>parent</code>'s frame.
 * This method can be overriden to further manipulate the dialog,
 * to disable resizing, set the location, etc. Example:
 * <pre>
 *     class MyFileChooser extends JFileChooser {
 *         protected JDialog createDialog(Component parent) throws HeadlessException {
 *             JDialog dialog = super.createDialog(parent);
 *             dialog.setLocation(300, 200);
 *             dialog.setResizable(false);
 *             return dialog;
 *         }
 *     }
 * </pre>
 *
 * @param   parent  the parent component of the dialog;
 *                  can be <code>null</code>
 * @return a new <code>JDialog</code> containing this instance
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since 1.4
 */
protected JDialog createDialog(Component parent) throws HeadlessException {
    FileChooserUI ui = getUI();
    String title = ui.getDialogTitle(this);
    putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
                      title);

    JDialog dialog;
    Window window = JOptionPane.getWindowForComponent(parent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    dialog.setComponentOrientation(this.getComponentOrientation());

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);

    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations =
        UIManager.getLookAndFeel().getSupportsWindowDecorations();
        if (supportsWindowDecorations) {
            dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
        }
    }
    dialog.pack();
    dialog.setLocationRelativeTo(parent);

    return dialog;
}
 
Example 14
Source File: TestFont.java    From SikuliNG with MIT License 5 votes vote down vote up
public TestFont() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    add(wrappedTable("using setFont, non-derived", false, false, false));
//    add(wrappedTable("using getFont, non-derived", true, false, false));
//    add(wrappedTable("using setFont, derived (int)", false, true, false));
//    add(wrappedTable("using getFont, derived (int)", true, true, false));
//    add(wrappedTable("using setFont, derived (float)", false, true, true));
//    add(wrappedTable("using getFont, derived (float)", true, true, true));
    pack();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
 
Example 15
Source File: DomViewerWindow.java    From LoboBrowser with MIT License 5 votes vote down vote up
public DomViewerWindow() {
  super("Lobo DOM Viewer");
  final UserAgentContext uaContext = null; // TODO
  this.setIconImage(DefaultWindowFactory.getInstance().getDefaultImageIcon(uaContext).getImage());
  final Container contentPane = this.getContentPane();
  this.domTree = new JTree();
  this.domTree.setRootVisible(false);
  this.domTree.setShowsRootHandles(true);
  this.domTree.addTreeSelectionListener(this);
  final JTextArea textArea = createTextArea();
  this.textArea = textArea;
  final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(domTree), new JScrollPane(textArea));
  contentPane.setLayout(WrapperLayout.getInstance());
  contentPane.add(splitPane);
}
 
Example 16
Source File: RankingGraph.java    From moa with GNU General Public License v3.0 4 votes vote down vote up
private void initComponents() {
    Container container = getContentPane();
    width = getSize().width - 10;
    height = 70 * getSize().height / 100;
    graphPanel = new Graph();
    zoomPanel = new SliderPanel();
    controlPanel = new JPanel();
    imgOptionsPanel = new JPanel();
    exportPanel = new JPanel();
    btnSave = new JButton("Save");
    btnLineStroke = new JButton("Line 1 Stroke");
    btnFont = new JButton("Text Font");
    btnLineDifStronke = new JButton("Line 2 Stroke");
    btnDir = new JButton("Save as");
  
    graphPanelDisplay.setLayout(new BorderLayout());
    graphPanelDisplay.add(graphPanel, BorderLayout.CENTER);
    TitledBorder titleborder;
    titleborder = BorderFactory.createTitledBorder(" Zoom");
    zoomPanel.setBorder(titleborder);
    //titleborder = BorderFactory.createTitledBorder("Options");
    //controlPanel.setBorder(titleborder);
    
    titleborder = BorderFactory.createTitledBorder("Properties");
    imgOptionsPanel.setBorder(titleborder);
    
    titleborder = BorderFactory.createTitledBorder("Export");
    exportPanel.setBorder(titleborder);
    
    graphPanelDisplay.setPreferredSize(new Dimension(width, height));
    controlPanel.setPreferredSize(new Dimension(60 * width / 100,
            20 * getSize().height / 100));
    zoomPanel.setPreferredSize(new Dimension(30 * width / 100,
            20 * getSize().height / 100));
    
    EventControl evt = new EventControl();
    btnFont.addActionListener(evt);
    btnLineDifStronke.addActionListener(evt);
    btnLineStroke.addActionListener(evt);
    btnSave.addActionListener(evt);
    btnDir.addActionListener(evt);
    imgOptionsPanel.add(btnFont);
    imgOptionsPanel.add(btnLineStroke);
    imgOptionsPanel.add(btnLineDifStronke);
    
    exportPanel.setLayout(new BorderLayout());
    JPanel panel = new JPanel();
    //panel.add(new JLabel("Export as "));
   // panel.add(imgType);
   // panel.add(btnSave);
    
    JPanel panelName = new JPanel();
    //panelName.add(new JLabel("File name "));
   // panelName.add(JtextFieldimgName);
    panelName.add(btnDir);
    exportPanel.add(panelName, BorderLayout.CENTER);
    exportPanel.add(panel, BorderLayout.SOUTH);
    
    controlPanel.setLayout(new BorderLayout());
    controlPanel.add(imgOptionsPanel, BorderLayout.CENTER);
    controlPanel.add(exportPanel, BorderLayout.EAST);
    controlPanelDisplay.setLayout(new BorderLayout(1, 1));
    controlPanelDisplay.add(controlPanel, BorderLayout.CENTER);
    controlPanelDisplay.add(zoomPanel, BorderLayout.EAST);
    container.setLayout(new BorderLayout(1, 1));
    container.add("Center", graphPanelDisplay);
    container.add("South", controlPanelDisplay);
    xScale = 20;
    yScale = 20;
    x0 = width / 2;
    y0 = height / 5;
    this.availableStrokeSamples = new StrokeSample[4];
    this.availableStrokeSamples[0] = new StrokeSample(new BasicStroke(1.5f,
            BasicStroke.CAP_BUTT,
            BasicStroke.JOIN_MITER,
            10.0f, dash1, 0.0f));
    this.availableStrokeSamples[1] = new StrokeSample(
            new BasicStroke(1.0f));
    this.availableStrokeSamples[2] = new StrokeSample(
            new BasicStroke(2.0f));
    this.availableStrokeSamples[3] = new StrokeSample(
            new BasicStroke(3.0f));
    
    addWindowStateListener((WindowEvent arg0) -> {
        width = getSize().width - 10;
        height = 70 * getSize().height / 100;
        x0 = width / 2;
        y0 = height / 5;
        xScale = 20;
        yScale = 20;
        xSlider.setValue(50);
        ySlider.setValue(20);
    });
    
}
 
Example 17
Source File: LanguageChooserDialog.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initComponents()
{
	setTitle(chooser.getName());
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	addWindowListener(new WindowAdapter()
	{

		@Override
		public void windowClosed(WindowEvent e)
		{
			//detach listeners from the chooser
			treeViewModel.setDelegate(null);
			listModel.setListFacade(null);
			chooser.getRemainingSelections().removeReferenceListener(LanguageChooserDialog.this);
		}

	});
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	JSplitPane split = new JSplitPane();
	JPanel leftPane = new JPanel(new BorderLayout());
	//leftPane.add(new JLabel("Available Languages"), BorderLayout.NORTH);
	availTable.setAutoCreateRowSorter(true);
	availTable.setTreeViewModel(treeViewModel);
	availTable.getRowSorter().toggleSortOrder(0);
	availTable.addActionListener(new DoubleClickActionListener());
	leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER);

	Button addButton = new Button(LanguageBundle.getString("in_sumLangAddLanguage"));
	addButton.setOnAction(this::doAdd);
	addButton.setGraphic(new ImageView(Icons.Forward16.asJavaFX()));
	leftPane.add(GuiUtility.wrapParentAsJFXPanel(addButton), BorderLayout.PAGE_END);

	split.setLeftComponent(leftPane);

	JPanel rightPane = new JPanel(new BorderLayout());
	JPanel labelPane = new JPanel(new GridBagLayout());

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridwidth = GridBagConstraints.REMAINDER;
	labelPane.add(new JLabel(LanguageBundle.getString("in_sumLangRemain")), //$NON-NLS-1$
		new GridBagConstraints());
	remainingLabel.setText(chooser.getRemainingSelections().get().toString());
	labelPane.add(remainingLabel, gbc);
	labelPane.add(new JLabel(LanguageBundle.getString("in_sumSelectedLang")), gbc); //$NON-NLS-1$
	rightPane.add(labelPane, BorderLayout.PAGE_START);

	list.setModel(listModel);
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.addActionListener(new DoubleClickActionListener());
	rightPane.add(new JScrollPane(list), BorderLayout.CENTER);

	Button removeButton = new Button(LanguageBundle.getString("in_sumLangRemoveLanguage"));
	removeButton.setOnAction(this::doRemove);
	removeButton.setGraphic(new ImageView(Icons.Back16.asJavaFX()));
	rightPane.add(GuiUtility.wrapParentAsJFXPanel(removeButton), BorderLayout.PAGE_END);

	split.setRightComponent(rightPane);
	pane.add(split, BorderLayout.CENTER);
	ButtonBar buttonBar = new OKCloseButtonBar(
			this::doOK,
			this::doRollback
	);
	pane.add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END);
}
 
Example 18
Source File: DownloadDialog.java    From LoboBrowser with MIT License 4 votes vote down vote up
public DownloadDialog(final ClientletResponse response, final @NonNull URL url, final int transferSpeed, final UserAgentContext uaContext) {
  this.url = url;
  this.uaContext = uaContext;
  this.setIconImage(DefaultWindowFactory.getInstance().getDefaultImageIcon(uaContext).getImage());

  this.topFormPanel.setMinLabelWidth(100);
  this.bottomFormPanel.setMinLabelWidth(100);

  this.bottomFormPanel.setEnabled(false);

  this.documentField.setCaption("Document:");
  this.timeLeftField.setCaption("Estimated time:");
  this.mimeTypeField.setCaption("MIME type:");
  this.sizeField.setCaption("Size:");
  this.destinationField.setCaption("File:");
  this.transferSizeField.setCaption("Transfer size:");
  this.transferRateField.setCaption("Transfer rate:");
  this.openFolderButton.setVisible(false);
  this.openButton.setVisible(false);

  this.documentField.setValue(url.toExternalForm());
  this.mimeTypeField.setValue(response.getMimeType());
  final int cl = response.getContentLength();
  this.knownContentLength = cl;
  final String sizeText = cl == -1 ? "Not known" : getSizeText(cl);
  this.sizeField.setValue(sizeText);
  final String estTimeText = (transferSpeed <= 0) || (cl == -1) ? "Not known" : Timing.getElapsedText(cl / transferSpeed);
  this.timeLeftField.setValue(estTimeText);

  final Container contentPane = this.getContentPane();
  contentPane.setLayout(new FlowLayout());
  final Box rootPanel = new Box(BoxLayout.Y_AXIS);
  rootPanel.setBorder(new EmptyBorder(4, 8, 4, 8));
  rootPanel.add(this.progressBar);
  rootPanel.add(Box.createVerticalStrut(8));
  rootPanel.add(this.topFormPanel);
  rootPanel.add(Box.createVerticalStrut(8));
  rootPanel.add(this.bottomFormPanel);
  rootPanel.add(Box.createVerticalStrut(8));
  rootPanel.add(this.getButtonsPanel());
  contentPane.add(rootPanel);

  final FormPanel bfp = this.bottomFormPanel;
  bfp.addField(this.destinationField);
  bfp.addField(this.transferRateField);
  bfp.addField(this.transferSizeField);

  final FormPanel tfp = this.topFormPanel;
  tfp.addField(this.documentField);
  tfp.addField(this.mimeTypeField);
  tfp.addField(this.sizeField);
  tfp.addField(this.timeLeftField);

  final Dimension topPanelPs = this.topFormPanel.getPreferredSize();
  this.topFormPanel.setPreferredSize(new Dimension(400, topPanelPs.height));

  final Dimension bottomPanelPs = this.bottomFormPanel.getPreferredSize();
  this.bottomFormPanel.setPreferredSize(new Dimension(400, bottomPanelPs.height));

  this.progressBar.setEnabled(false);

  this.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosed(final WindowEvent e) {
      final RequestHandler rh = requestHandler;
      if (rh != null) {
        rh.cancel();
        // So that there's no error dialog
        requestHandler = null;
      }
    }
  });
}
 
Example 19
Source File: ServiceDialog.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize print dialog.
 */
void initPrintDialog(int x, int y,
                     PrintService[] services,
                     int defaultServiceIndex,
                     DocFlavor flavor,
                     PrintRequestAttributeSet attributes)
{
    this.services = services;
    this.defaultServiceIndex = defaultServiceIndex;
    this.asOriginal = attributes;
    this.asCurrent = new HashPrintRequestAttributeSet(attributes);
    this.psCurrent = services[defaultServiceIndex];
    this.docFlavor = flavor;
    SunPageSelection pages =
        (SunPageSelection)attributes.get(SunPageSelection.class);
    if (pages != null) {
        isAWT = true;
    }

    if (attributes.get(DialogOnTop.class) != null) {
        setAlwaysOnTop(true);
    }
    Container c = getContentPane();
    c.setLayout(new BorderLayout());

    tpTabs = new JTabbedPane();
    tpTabs.setBorder(new EmptyBorder(5, 5, 5, 5));

    String gkey = getMsg("tab.general");
    int gmnemonic = getVKMnemonic("tab.general");
    pnlGeneral = new GeneralPanel();
    tpTabs.add(gkey, pnlGeneral);
    tpTabs.setMnemonicAt(0, gmnemonic);

    String pkey = getMsg("tab.pagesetup");
    int pmnemonic = getVKMnemonic("tab.pagesetup");
    pnlPageSetup = new PageSetupPanel();
    tpTabs.add(pkey, pnlPageSetup);
    tpTabs.setMnemonicAt(1, pmnemonic);

    String akey = getMsg("tab.appearance");
    int amnemonic = getVKMnemonic("tab.appearance");
    pnlAppearance = new AppearancePanel();
    tpTabs.add(akey, pnlAppearance);
    tpTabs.setMnemonicAt(2, amnemonic);

    c.add(tpTabs, BorderLayout.CENTER);

    updatePanels();

    JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    btnApprove = createExitButton("button.print", this);
    pnlSouth.add(btnApprove);
    getRootPane().setDefaultButton(btnApprove);
    btnCancel = createExitButton("button.cancel", this);
    handleEscKey(btnCancel);
    pnlSouth.add(btnCancel);
    c.add(pnlSouth, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            dispose(CANCEL);
        }
    });

    getAccessibleContext().setAccessibleDescription(getMsg("dialog.printtitle"));
    setResizable(false);
    setLocation(x, y);
    pack();
}
 
Example 20
Source File: FlexCell.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link FlexLayout} with this cell as its root cell and applies it to the
 * specified component.
 *
 * @param container The container to apply the {@link FlexLayout} to.
 */
public void apply(Container container) {
    container.setLayout(new FlexLayout(this));
}