Java Code Examples for javax.swing.JSplitPane#setPreferredSize()

The following examples show how to use javax.swing.JSplitPane#setPreferredSize() . 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: ChatPanel.java    From xyTalk-pc with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initView() {
	this.setLayout(new GridLayout(1, 1));

	if (roomId == null) {
		messagePanel.setVisible(false);
		messageEditorPanel.setVisible(false);
		DebugUtil.debug("roomId == null");
	}

	splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
	// splitPane.setBorder(new RCBorder(RCBorder.BOTTOM,
	// Colors.LIGHT_GRAY));
	splitPane.setBorder(null);
	// splitPane.setUI(new BasicSplitPaneUI());
	// BasicSplitPaneDivider divider = (BasicSplitPaneDivider)
	// splitPane.getComponent(0);
	// divider.setBackground(Colors.FONT_BLACK);
	// divider.setBorder(null);
	splitPane.setOneTouchExpandable(false);
	splitPane.setDividerLocation(450);
	// splitPane.setResizeWeight(0.1);
	splitPane.setDividerSize(2);

	splitPane.setTopComponent(messagePanel);
	splitPane.setBottomComponent(messageEditorPanel);
	splitPane.setPreferredSize(new Dimension(MainFrame.DEFAULT_WIDTH, MainFrame.DEFAULT_HEIGHT));
	// add(splitPane, new GBC(0, 0).setFill(GBC.BOTH).setWeight(1, 4));
	// add(splitPane, new GBC(0, 0).setFill(GBC.BOTH).setWeight(1, 10));
	add(splitPane);
	// add(messagePanel, new GBC(0, 0).setFill(GBC.BOTH).setWeight(1, 4));
	// add(messageEditorPanel, new GBC(0, 1).setFill(GBC.BOTH).setWeight(1,
	// 1));

}
 
Example 2
Source File: JSplitPaneOverlapping.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void prepareControls() {
    JFrame frame = new JFrame("SplitPane Mixing");
    JPanel p = new JPanel(new GridLayout());
    p.setPreferredSize(new Dimension(500, 500));
    propagateAWTControls(p);
    sp1 = new JScrollPane(p);

    JButton button = new JButton("JButton");
    button.setBackground(Color.RED);
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            clicked = true;
        }
    });
    sp2 = new JScrollPane(button);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, sp2);
    splitPane.setOneTouchExpandable(false);
    splitPane.setDividerLocation(150);

    splitPane.setPreferredSize(new Dimension(400, 200));

    frame.getContentPane().add(splitPane);
    frame.pack();
    frame.setVisible(true);
}
 
Example 3
Source File: AutomaticFixingWindow.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * @return Window components.
 */
@Override
protected Component createComponents() {
  JPanel panel = new JPanel(new GridBagLayout());

  // Initialize constraints
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(2, 2, 2, 2);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 0;
  constraints.weighty = 0;

  // Contents
  constraints.fill = GridBagConstraints.BOTH;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.weightx = 1;
  constraints.weighty = 1;
  JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
  split.setLeftComponent(createLinksComponents());
  split.setRightComponent(createAutomaticFixingComponents());
  split.setPreferredSize(new Dimension(1000, 700));
  split.setMinimumSize(new Dimension(200, 200));
  split.setResizeWeight(0.0);
  split.setDividerLocation(200 + split.getInsets().left);
  panel.add(split, constraints);
  constraints.gridy++;

  updateComponentState();
  return panel;
}
 
Example 4
Source File: ImageTreePanel.java    From moa with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 * @param chart
 */
public ImageTreePanel(ImageChart chart[]) {
    super(new GridLayout(1, 0));
    this.chart = chart;
    //Create the nodes.
    DefaultMutableTreeNode top
            = new DefaultMutableTreeNode("Images");
    imgPanel = new JPanel();
    imgPanel.setLayout(new GridLayout(1, 0));
    createNodes(top);
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    tree.setSelectionRow(1);

    tree.addTreeSelectionListener(this);
    ImageIcon leafIcon = new ImageIcon("icon/img.png");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer
                = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    }
    imgPanel.updateUI();
    JScrollPane treeView = new JScrollPane(tree);
    treeView.setMinimumSize(new Dimension(100, 50));

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(imgPanel);
    splitPane.setDividerLocation(100);
    splitPane.setPreferredSize(new Dimension(500, 300));
    add(splitPane);

}
 
Example 5
Source File: TreeDemo.java    From OpenDA with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TreeDemo() {
    super(new GridLayout(1,0));

    //Create the nodes.
    DefaultMutableTreeNode top =
        new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    //Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode
            (TreeSelectionModel.SINGLE_TREE_SELECTION);

    //Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    if (playWithLineStyle) {
        System.out.println("line style = " + lineStyle);
        tree.putClientProperty("JTree.lineStyle", lineStyle);
    }

    //Create the scroll pane and add the tree to it. 
    JScrollPane treeView = new JScrollPane(tree);

    //Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    //Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); 
    splitPane.setPreferredSize(new Dimension(500, 300));

    //Add the split pane to this panel.
    add(splitPane);
}
 
Example 6
Source File: TreeDemo.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public TreeDemo() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    if (playWithLineStyle) {
        System.out.println("line style = " + lineStyle);
        tree.putClientProperty("JTree.lineStyle", lineStyle);
    }

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100);
    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}
 
Example 7
Source File: TreeIconDemo.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public TreeIconDemo() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Set the icon for leaf nodes.
    ImageIcon leafIcon = createImageIcon("images/middle.gif");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    } else {
        System.err.println("Leaf icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
                                       // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}
 
Example 8
Source File: TreeIconDemo2.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public TreeIconDemo2() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Enable tool tips.
    ToolTipManager.sharedInstance().registerComponent(tree);

    // Set the icon for leaf nodes.
    ImageIcon tutorialIcon = createImageIcon("images/middle.gif");
    if (tutorialIcon != null) {
        tree.setCellRenderer(new MyRenderer(tutorialIcon));
    } else {
        System.err.println("Tutorial icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
                                       // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}
 
Example 9
Source File: OnePageAnalysisWindow.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * @return Window components.
 */
@Override
protected Component createComponents() {
  JPanel panel = new JPanel(new GridBagLayout());

  // Initialize constraints
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(2, 2, 2, 2);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 0;
  constraints.weighty = 0;

  // Page name
  //constraints.gridwidth = 2;
  panel.add(createPageComponents(), constraints);
  constraints.gridy++;

  // Contents
  constraints.fill = GridBagConstraints.BOTH;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.weightx = 1;
  constraints.weighty = 1;
  JSplitPane splitLinks = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  splitLinks.setLeftComponent(createLinksComponents());
  splitLinks.setRightComponent(createCheckWikiComponents());
  splitLinks.setResizeWeight(1.0);
  splitLinks.setDividerLocation(0.9);
  JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
  split.setLeftComponent(splitLinks);
  split.setRightComponent(createContentsComponents());
  split.setPreferredSize(new Dimension(1200, 700));
  split.setMinimumSize(new Dimension(200, 200));
  split.setResizeWeight(0.0);
  split.setDividerLocation(200 + split.getInsets().left);
  panel.add(split, constraints);
  constraints.gridy++;

  updateComponentState();
  return panel;
}
 
Example 10
Source File: DisambiguationWindow.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * @return Window components.
 */
@Override
protected Component createComponents() {
  createElements();
  JPanel panel = new JPanel(new GridBagLayout());

  // Initialize constraints
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(2, 2, 2, 2);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 0;
  constraints.weighty = 0;

  // Page name
  //constraints.gridwidth = 2;
  panel.add(createPageComponents(), constraints);
  constraints.gridy++;

  // Contents
  constraints.fill = GridBagConstraints.BOTH;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.weightx = 1;
  constraints.weighty = 1;
  JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
  split.setLeftComponent(createLinksComponents());
  split.setRightComponent(createContentsComponents());
  split.setPreferredSize(new Dimension(1200, 700));
  split.setMinimumSize(new Dimension(200, 200));
  split.setResizeWeight(0.0);
  split.setDividerLocation(200 + split.getInsets().left);
  panel.add(split, constraints);
  constraints.gridy++;

  updateComponentState();
  return panel;
}
 
Example 11
Source File: ToolAdapterEditorDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected JSplitPane createMainPanel() {
    JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mainPanel.setOneTouchExpandable(false);

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    double widthRatio = 0.5;
    formWidth = Math.max((int) (Math.min(screenSize.width, MAX_4K_WIDTH) * widthRatio), MIN_WIDTH);
    double heightRatio = 0.6;
    int formHeight = Math.max((int) (Math.min(screenSize.height, MAX_4K_HEIGHT) * heightRatio), MIN_HEIGHT);

    getJDialog().setMinimumSize(new Dimension(formWidth + 16, formHeight + 72));

    // top panel first
    JSplitPane topPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    topPanel.setOneTouchExpandable(false);

    JPanel descriptorPanel = createDescriptorAndVariablesAndPreprocessingPanel();
    Dimension topPanelDimension = new Dimension((int)((formWidth - 3 * DEFAULT_PADDING) * 0.5), (int)((formHeight - 3 * DEFAULT_PADDING) * 0.75));
    descriptorPanel.setMinimumSize(topPanelDimension);
    descriptorPanel.setPreferredSize(topPanelDimension);
    topPanel.setLeftComponent(descriptorPanel);

    JPanel configurationPanel = createToolInfoPanel();
    configurationPanel.setMinimumSize(topPanelDimension);
    configurationPanel.setPreferredSize(topPanelDimension);
    topPanel.setRightComponent(configurationPanel);
    topPanel.setDividerLocation(0.5);

    // bottom panel last
    JPanel bottomPannel = createParametersPanel();
    Dimension bottomPanelDimension = new Dimension(formWidth - 2 * DEFAULT_PADDING, (int)((formHeight - 3 * DEFAULT_PADDING) * 0.25));
    bottomPannel.setMinimumSize(bottomPanelDimension);
    bottomPannel.setPreferredSize(bottomPanelDimension);

    mainPanel.setTopComponent(topPanel);
    mainPanel.setBottomComponent(bottomPannel);
    mainPanel.setDividerLocation(0.75);

    mainPanel.setPreferredSize(new Dimension(formWidth, formHeight));

    mainPanel.revalidate();

    return mainPanel;
}
 
Example 12
Source File: MainWindow.java    From Luyten with Apache License 2.0 4 votes vote down vote up
public MainWindow(File fileFromCommandLine) {
	configSaver = ConfigSaver.getLoadedInstance();
	windowPosition = configSaver.getMainWindowPosition();
	luytenPrefs = configSaver.getLuytenPreferences();
	
	mainMenuBar = new MainMenuBar(this);
	this.setJMenuBar(mainMenuBar);

	this.adjustWindowPositionBySavedState();
	this.setHideFindBoxOnMainWindowFocus();
	this.setShowFindAllBoxOnMainWindowFocus();
	this.setQuitOnWindowClosing();
	this.setTitle(TITLE);
	this.setIconImage(new ImageIcon(
			Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/resources/Luyten.png"))).getImage());

	JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
	label = new JLabel();
	label.setHorizontalAlignment(JLabel.LEFT);
	panel1.setBorder(new BevelBorder(BevelBorder.LOWERED));
	panel1.setPreferredSize(new Dimension(this.getWidth() / 2, 20));
	panel1.add(label);

	JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	bar = new JProgressBar();

	bar.setStringPainted(true);
	bar.setOpaque(false);
	bar.setVisible(false);
	panel2.setPreferredSize(new Dimension(this.getWidth() / 3, 20));
	panel2.add(bar);

	model = new Model(this);
	this.getContentPane().add(model);

	JSplitPane spt = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel1, panel2) {
		private static final long serialVersionUID = 2189946972124687305L;
		private final int location = 400;

		{
			setDividerLocation(location);
		}

		@Override
		public int getDividerLocation() {
			return location;
		}

		@Override
		public int getLastDividerLocation() {
			return location;
		}
	};
	spt.setBorder(new BevelBorder(BevelBorder.LOWERED));
	spt.setPreferredSize(new Dimension(this.getWidth(), 24));
	this.add(spt, BorderLayout.SOUTH);
	if (fileFromCommandLine != null) {
		model.loadFile(fileFromCommandLine);
	}

	try {
		DropTarget dt = new DropTarget();
		dt.addDropTargetListener(new DropListener(this));
		this.setDropTarget(dt);
	} catch (Exception e) {
		Luyten.showExceptionDialog("Exception!", e);
	}

	fileDialog = new FileDialog(this);
	fileSaver = new FileSaver(bar, label);

	this.setExitOnEscWhenEnabled(model);

	if (fileFromCommandLine == null || fileFromCommandLine.getName().toLowerCase().endsWith(".jar")
			|| fileFromCommandLine.getName().toLowerCase().endsWith(".zip")) {
		model.startWarmUpThread();
	}
	
	if(RecentFiles.load() > 0) mainMenuBar.updateRecentFiles();
}