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

The following examples show how to use javax.swing.JSplitPane#setTopComponent() . 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: MainView.java    From HiJson with Apache License 2.0 7 votes vote down vote up
private void codeChangeAction(){
    javax.swing.JDialog dlg = new javax.swing.JDialog(getFrame());
    dlg.setTitle(resourceMap.getString("menuItemCode.text"));
    dlg.setSize(500, 350);
    dlg.setMinimumSize(new Dimension(500, 350));
    JSplitPane spiltPane2 = new JSplitPane();
    spiltPane2.setDividerLocation(150);
    spiltPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);

    final JTextArea textAreaSrc = new JTextArea();
    final JTextArea textAreaDest = new JTextArea();
    textAreaSrc.setLineWrap(true);
    textAreaDest.setLineWrap(true);

    spiltPane2.setTopComponent(new JScrollPane(textAreaSrc));
    spiltPane2.setBottomComponent(new JScrollPane(textAreaDest));

    JButton btnOK = new JButton("转换");
    btnOK.setSize(50, 25);
    java.awt.Container pane = dlg.getContentPane();
    BorderLayout layout = new BorderLayout();
    //layout.addLayoutComponent(spiltPane, BorderLayout.CENTER);
   // layout.addLayoutComponent(btnOK, BorderLayout.SOUTH);
    pane.setLayout(layout);
    pane.add(spiltPane2,  BorderLayout.CENTER);
    pane.add(btnOK,  BorderLayout.SOUTH);

    btnOK.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String str = textAreaSrc.getText();
            str = StringEscapeUtils.unescapeJava(str);
            textAreaDest.setText(str);
        }
    });
    MainApp.getApplication().show(dlg);

}
 
Example 2
Source File: CCombinedRightPanel.java    From binnavi with Apache License 2.0 6 votes vote down vote up
private static JPanel createTypePanels(final JFrame parent, final CGraphModel model,
    final TypeManager typeManager) {
  final JPanel typePanel = new JPanel(new BorderLayout());
  final JPanel typeEditorPanel = TypeEditorPanel.CreateDefaultTypeEditor(parent, typeManager);
  if (isFunctionFlowgraph(model)) {
    final JSplitPane splitPaneTop = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPaneTop.setBorder(BorderFactory.createEmptyBorder());
    splitPaneTop.setOneTouchExpandable(true);
    final JSplitPane splitPaneBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPaneBottom.setBorder(BorderFactory.createEmptyBorder());
    splitPaneBottom.setOneTouchExpandable(true);
    splitPaneTop.setTopComponent(createPrototypePanel(parent, model, typeManager));
    splitPaneTop.setBottomComponent(createStackFramePanel(parent, model, typeManager));
    splitPaneBottom.setTopComponent(splitPaneTop);
    splitPaneBottom.setBottomComponent(typeEditorPanel);
    typePanel.add(splitPaneBottom);
  } else {
    typePanel.add(typeEditorPanel, BorderLayout.CENTER);
  }
  return typePanel;
}
 
Example 3
Source File: CSSStylesSelectionPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@code CSSStylesSelectionPanel}.
 */
CSSStylesSelectionPanel() {
    setLayout(new BorderLayout());
    JSplitPane splitPane = createSplitPane();
    splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(initPropertyPane());
    splitPane.setBottomComponent(initRulePane());
    splitPane.setDividerSize(4);
    splitPane.setResizeWeight(0.5);
    splitPane.setBorder(null);
    selectionView = splitPane;
    initMessagePanel();
    initSelectionOfOwningRule();
    add(selectionView, BorderLayout.CENTER);
    updateContent(null, false);
}
 
Example 4
Source File: VisualProfiler.java    From diirt with MIT License 6 votes vote down vote up
/**
 * Adds all graphical user interface components to the <code>JPanel</code>.
 */
private void addComponents(){
    //Tabs
    tabs.addTab("Profile 1D Table", profile1DTable);
    tabs.addTab("Profile 2D Table", profile2DTable);
    tabs.addTab("Control Panel", analyzePanel);
    tabs.addTab("File Browser", fileViewer);

    JSplitPane top = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    top.setTopComponent(settingsPanel);
    top.setBottomComponent(tabs);

    JSplitPane bottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    bottom.setTopComponent(top);
    bottom.setBottomComponent(console);

    //Add to panel hiearchy
    this.add(bottom);
}
 
Example 5
Source File: ImageORPanel.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void init() {
    setLayout(new BorderLayout());
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setOneTouchExpandable(true);
    splitPane.setBottomComponent(objectTable);
    TreeSearch tSearch = TreeSearch.installForOR(objectTree.getTree());
    splitPane.setTopComponent(tSearch);
    splitPane.setResizeWeight(.5);
    splitPane.setDividerLocation(.5);
    add(splitPane);
}
 
Example 6
Source File: TasksRenderer.java    From swift-k with Apache License 2.0 5 votes vote down vote up
protected JComponent createFileStuff() {
	JSplitPane t = new JSplitPane(VERTICAL_SPLIT);
	t.setResizeWeight(0.5);
	t.setTopComponent(createTransferTable());
	t.setBottomComponent(createFileopTable());
	return t;
}
 
Example 7
Source File: CELabelsPanel.java    From open-ig with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Initialize the GUI. */
private void initGUI() {
	verticalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
	
	verticalSplit.setTopComponent(createTopPanel());
	verticalSplit.setBottomComponent(createBottomPanel());
	verticalSplit.setResizeWeight(0.75);
	
	setLayout(new BorderLayout());
	add(verticalSplit, BorderLayout.CENTER);
	
	doUpdateCount();
}
 
Example 8
Source File: SimpleDemoFrame.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected JComponent createDefaultContentPane()
{
  final JPanel content = new JPanel(new BorderLayout());
  content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

  final InternalDemoHandler demoHandler = getDemoHandler();
  final JEditorPane editorPane = new JEditorPane();
  final URL url = demoHandler.getDemoDescriptionSource();
  editorPane.setEditable(false);
  editorPane.setPreferredSize(new Dimension(400, 200));
  if (url != null)
  {
    try
    {
      editorPane.setPage(url);
    }
    catch (IOException e)
    {
      editorPane.setText("Unable to load the demo description. Error: " + e.getMessage());
    }
  }
  else
  {
    editorPane.setText("Unable to load the demo description. No such resource.");
  }

  final JScrollPane scroll = new JScrollPane(editorPane,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

  final JButton previewButton = new JButton(getPreviewAction());

  final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  splitPane.setTopComponent(scroll);
  splitPane.setBottomComponent(demoHandler.getPresentationComponent());
  content.add(splitPane, BorderLayout.CENTER);
  content.add(previewButton, BorderLayout.SOUTH);
  return content;
}
 
Example 9
Source File: DatFileViewer.java    From settlers-remake with MIT License 5 votes vote down vote up
private DatFileViewer() {
	glCanvas = new Surface();

	JPanel infoField = new JPanel();
	infoField.setLayout(new BoxLayout(infoField, BoxLayout.PAGE_AXIS));

	lblDatType = new JLabel();
	lblNumUiSeqs = new JLabel();
	lblNumSettlerSeqs = new JLabel();
	lblNumLandscapeSeqs = new JLabel();

	infoField.add(lblDatType);
	infoField.add(lblNumSettlerSeqs);
	infoField.add(lblNumLandscapeSeqs);
	infoField.add(lblNumUiSeqs);

	listItems = new DefaultListModel<>();
	listView = new JList<>(listItems);
	listView.getSelectionModel().addListSelectionListener(this);

	JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
	splitPane2.setTopComponent(new JScrollPane(listView));
	splitPane2.setBottomComponent(infoField);
	splitPane2.setResizeWeight(0.5);
	splitPane2.setEnabled(false);

	JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
	splitPane.setLeftComponent(splitPane2);
	splitPane.setRightComponent(glCanvas);
	splitPane.setResizeWeight(0.10);

	this.setTitle("DatFileViewer");
	this.setJMenuBar(createMenu());
	this.getContentPane().add(splitPane);
	this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
	this.setSize(new Dimension(800, 600));
	this.setVisible(true);
}
 
Example 10
Source File: MobileORPanel.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void init() {
    setLayout(new BorderLayout());
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setOneTouchExpandable(true);
    splitPane.setBottomComponent(objectTable);
    TreeSearch tSearch = TreeSearch.installForOR(objectTree.getTree());
    splitPane.setTopComponent(tSearch);
    splitPane.setResizeWeight(.5);
    splitPane.setDividerLocation(.5);
    add(splitPane);
}
 
Example 11
Source File: WebORPanel.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void init() {
    setLayout(new BorderLayout());
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setOneTouchExpandable(true);
    splitPane.setBottomComponent(objectTable);
    TreeSearch tSearch = TreeSearch.installForOR(objectTree.getTree());
    splitPane.setTopComponent(tSearch);
    splitPane.setResizeWeight(.5);
    splitPane.setDividerLocation(.5);
    add(splitPane);
}
 
Example 12
Source File: TestDesignUI.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void init() {
    setLayout(new BorderLayout());
    projectNReusableTreeSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    projectNReusableTreeSplitPane.setOneTouchExpandable(true);
    projectNReusableTreeSplitPane.setResizeWeight(0.5);

    projectNReusableTreeSplitPane.setTopComponent(getTreeInPanel("Test Plan", testDesign.getProjectTree().getTree()));

    appReusablePanel = getRTreeInPanel("Reusable Component", testDesign.getReusableTree().getTree());
    projectNReusableTreeSplitPane.setBottomComponent(appReusablePanel);

    testCaseNTestDataSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    testCaseNTestDataSplitPane.setOneTouchExpandable(true);
    testCaseNTestDataSplitPane.setResizeWeight(0.5);

    testCaseNTestDataSplitPane.setTopComponent(testDesign.getTestCaseComponent());
    testCaseNTestDataSplitPane.setBottomComponent(testDesign.getTestDatacomp());

    oneTwo = new JSplitPane();
    oneTwo.setOneTouchExpandable(true);
    oneTwo.setResizeWeight(0.25);

    oneTwo.setLeftComponent(projectNReusableTreeSplitPane);
    oneTwo.setRightComponent(testCaseNTestDataSplitPane);

    oneThree = new JSplitPane();
    oneThree.setOneTouchExpandable(true);
    oneThree.setResizeWeight(0.8);

    oneThree.setLeftComponent(oneTwo);
    oneThree.setRightComponent(testDesign.getObjectRepo());

    add(oneThree);

}
 
Example 13
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 14
Source File: TestExecutionUI.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 4 votes vote down vote up
private void init() {

        setLayout(new BorderLayout());

        testSetCompNtestPlan = new JSplitPane();
        testSetCompNtestPlan.setOneTouchExpandable(true);

        treeSNTableSplitPane = new JSplitPane();
        treeSNTableSplitPane.setOneTouchExpandable(true);

        testSettreeNSettingsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        testSettreeNSettingsSplitPane.setOneTouchExpandable(true);

        testplanTreeNSettingsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        testplanTreeNSettingsSplitPane.setOneTouchExpandable(true);

        executionAndConsoleSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        executionAndConsoleSplitPane.setOneTouchExpandable(true);

        testSettreeNSettingsSplitPane.setTopComponent(
                getCompInPanel(
                        "TestLab",
                        TreeSearch.installFor(testExecution.getTestSetTree().getTree())));

        testSettreeNSettingsSplitPane.setBottomComponent(
                getCompInPanel(
                        "QuickSettings",
                        new JScrollPane(
                                testExecution.getTestSetComp()
                                .getQuickSettings().getUILeft(this))));

        testSettreeNSettingsSplitPane.setDividerLocation(0.5);

        treeSNTableSplitPane.setResizeWeight(0.25);
        treeSNTableSplitPane.setLeftComponent(testSettreeNSettingsSplitPane);

        executionAndConsoleSplitPane.setTopComponent(testExecution.getTestSetComp());
        executionAndConsoleSplitPane.setOneTouchExpandable(true);

        consolePanel = new ConsolePanel();

        treeSNTableSplitPane.setRightComponent(executionAndConsoleSplitPane);

        testSetCompNtestPlan.setLeftComponent(treeSNTableSplitPane);

        testPullPanel = new TestPlanPullPanel();
        testplanTreeNSettingsSplitPane.setTopComponent(testPullPanel);

        testplanTreeNSettingsSplitPane.setBottomComponent(
                getCompInPanel(
                        "QuickSettings",
                        new JScrollPane(
                                testExecution.getTestSetComp()
                                .getQuickSettings().getUIRight(this))));
        testSetCompNtestPlan.setRightComponent(testplanTreeNSettingsSplitPane);
        testSetCompNtestPlan.setResizeWeight(0.8);

        add(testSetCompNtestPlan, BorderLayout.CENTER);
    }
 
Example 15
Source File: PropertySheetPanel.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
private void buildUI() {
  LookAndFeelTweaks.setBorderLayout(this);
  LookAndFeelTweaks.setBorder(this);

  actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
  actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
  add("North", actionPanel);

  sortButton = new JToggleButton(new ToggleSortingAction());
  sortButton.setUI(new BlueishButtonUI());
  sortButton.setText(null);
  actionPanel.add(sortButton);

  asCategoryButton = new JToggleButton(new ToggleModeAction());
  asCategoryButton.setUI(new BlueishButtonUI());
  asCategoryButton.setText(null);
  actionPanel.add(asCategoryButton);

  descriptionButton = new JToggleButton(new ToggleDescriptionAction());
  descriptionButton.setUI(new BlueishButtonUI());
  descriptionButton.setText(null);
  actionPanel.add(descriptionButton);

  split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  split.setBorder(null);
  split.setResizeWeight(1.0);
  split.setContinuousLayout(true);
  add("Center", split);
  
  tableScroll = new JScrollPane();
  split.setTopComponent(tableScroll);

  descriptionPanel = new JEditorPane("text/html", "<html>");
  descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
  descriptionPanel.setEditable(false);
  descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
  LookAndFeelTweaks.htmlize(descriptionPanel);

  selectionListener = new SelectionListener();

  descriptionScrollPane = new JScrollPane(descriptionPanel);
  descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
    .createLineBorder(UIManager.getColor("controlDkShadow"))));
  descriptionScrollPane.getViewport().setBackground(
    descriptionPanel.getBackground());
  descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
  split.setBottomComponent(descriptionScrollPane);
  
  // by default description is not visible, toolbar is visible.
  setDescriptionVisible(false);
  setToolBarVisible(true);
}
 
Example 16
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 17
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 18
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 19
Source File: CETechnologyPanel.java    From open-ig with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Construct the GUI.
 */
private void initGUI() {
	technologiesModel = new GenericTableModel<XElement>() {
		/** */
		private static final long serialVersionUID = 2557373261832556243L;

		@Override
		public Object getValueFor(XElement item, int rowIndex,
				int columnIndex) {
			switch (columnIndex) {
			case 0: return rowIndex;
			case 1: return item.get("id", "");
			case 2: return context.dataManager().label(item.get("name", null));
			case 3: return context.get(item.get("category", null));
			case 4: return item.getIntObject("level");
			case 5: return item.get("race", null);
			case 6: return item.getIntObject("production-cost");
			case 7: return item.getIntObject("research-cost");
			case 8: return context.getIcon(validateItem(item));
			default:
				return null;
			}
		}	
	};
	technologiesModel.setColumnNames(
			get("tech.#"),
			get("tech.id"), 
			get("tech.name"), 
			get("tech.category"),
			get("tech.level"),
			get("tech.race"), 
			get("tech.research_cost"),
			get("tech.production_cost"), 
			"");
	technologiesModel.setColumnTypes(
			Integer.class,
			String.class,
			String.class,
			String.class,
			Integer.class,
			String.class,
			Integer.class,
			Integer.class,
			ImageIcon.class
	);
	
	technologies = new JTable(technologiesModel);
	technologiesSorter = new TableRowSorter<>(technologiesModel);
	technologies.setRowSorter(technologiesSorter);
	
	technologies.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
		@Override
		public void valueChanged(ListSelectionEvent e) {
			if (!e.getValueIsAdjusting()) {
				int idx = technologies.getSelectedRow();
				if (idx >= 0) {
					idx = technologies.convertRowIndexToModel(idx);
					doDetails(technologiesModel.get(idx), idx);
				} else {
					doDetails(null, -1);
				}
			}
		}
	});
	
	
	JPanel top = createTopPanel();
	
	verticalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
	
	verticalSplit.setTopComponent(top);
	
	JPanel bottom = createBottomPanel();
	
	verticalSplit.setBottomComponent(bottom);
	verticalSplit.setResizeWeight(0.75);
	
	setLayout(new BorderLayout());
	add(verticalSplit, BorderLayout.CENTER);
	
	doUpdateCount();
	doDetails(null, -1);
}
 
Example 20
Source File: PropertySheetPanel.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
private void buildUI() {
  LookAndFeelTweaks.setBorderLayout(this);
  LookAndFeelTweaks.setBorder(this);

  actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
  actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
  actionPanel.setOpaque(false);
  add("North", actionPanel);

  sortButton = new JToggleButton(new ToggleSortingAction());
  sortButton.setUI(new BlueishButtonUI());
  sortButton.setText(null);
  sortButton.setOpaque(false);
  actionPanel.add(sortButton);

  asCategoryButton = new JToggleButton(new ToggleModeAction());
  asCategoryButton.setUI(new BlueishButtonUI());
  asCategoryButton.setText(null);
  asCategoryButton.setOpaque(false);
  actionPanel.add(asCategoryButton);

  descriptionButton = new JToggleButton(new ToggleDescriptionAction());
  descriptionButton.setUI(new BlueishButtonUI());
  descriptionButton.setText(null);
  descriptionButton.setOpaque(false);
  actionPanel.add(descriptionButton);

  split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  split.setBorder(null);
  split.setResizeWeight(1.0);
  split.setContinuousLayout(true);
  add("Center", split);
  
  tableScroll = new JScrollPane();
  tableScroll.setBorder(BorderFactory.createEmptyBorder());
  split.setTopComponent(tableScroll);

  descriptionPanel = new JEditorPane("text/html", "<html>");
  descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
  descriptionPanel.setEditable(false);
  descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
  LookAndFeelTweaks.htmlize(descriptionPanel);

  selectionListener = new SelectionListener();

  descriptionScrollPane = new JScrollPane(descriptionPanel);
  descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
    .createLineBorder(UIManager.getColor("controlDkShadow"))));
  descriptionScrollPane.getViewport().setBackground(
    descriptionPanel.getBackground());
  descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
  split.setBottomComponent(descriptionScrollPane);
  
  // by default description is not visible, toolbar is visible.
  setDescriptionVisible(false);
  setToolBarVisible(true);
}