Java Code Examples for javax.swing.JTree#setBackground()

The following examples show how to use javax.swing.JTree#setBackground() . 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: TreeSelectionRenderer.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
public final void editLaF(JTree tree) {
    UIDefaults paneDefaults = new UIDefaults();
    paneDefaults.put("Tree.selectionBackground", null);
    tree.putClientProperty("Nimbus.Overrides", paneDefaults);
    tree.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
    tree.setBackground(Color.WHITE);
}
 
Example 2
Source File: HelpView.java    From Open-Realms-of-Stars with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor for help view.
 * @param tutorial Tutorial list of help lines
 * @param tutorialEnabled Flag for if tutorial is enabled
 * @param listener ActionListener
 */
public HelpView(final TutorialList tutorial, final boolean tutorialEnabled,
    final ActionListener listener) {
  InfoPanel base = new InfoPanel();
  base.setTitle("Game help");
  this.setLayout(new BorderLayout());
  base.setLayout(new BorderLayout());

  String[] categories = tutorial.getCategories();
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("Tutorial");
  for (String category : categories) {
    DefaultMutableTreeNode categoryNode = new DefaultMutableTreeNode(
        category);
    root.add(categoryNode);
    HelpLine[] lines = tutorial.getTopics(category);
    for (HelpLine line : lines) {
      DefaultMutableTreeNode helpNode = new DefaultMutableTreeNode(line);
      categoryNode.add(helpNode);
    }
  }
  tutorialTree = new JTree(root);
  tutorialTree.getSelectionModel().setSelectionMode(
      TreeSelectionModel.SINGLE_TREE_SELECTION);
  tutorialTree.setBackground(Color.BLACK);
  tutorialTree.setCellRenderer(new TutorialTreeCellRenderer());
  tutorialTree.setFont(GuiStatics.getFontCubellanSmaller());
  tutorialTree.addTreeSelectionListener(this);
  JScrollPane scroll = new JScrollPane(tutorialTree);
  base.add(scroll, BorderLayout.WEST);
  infoText = new InfoTextArea();
  infoText.setLineWrap(true);
  infoText.setCharacterWidth(7);
  infoText.setEditable(false);
  infoText.setFont(GuiStatics.getFontCubellanSmaller());
  base.add(infoText, BorderLayout.CENTER);
  checkBox = new SpaceCheckBox("Tutorial enabled");
  checkBox.setToolTipText("If checked then tutorial is enabled in game.");
  if (tutorialEnabled) {
    checkBox.setSelected(true);
  }
  base.add(checkBox, BorderLayout.NORTH);
  this.add(base, BorderLayout.CENTER);

  // Bottom panel
  InfoPanel bottomPanel = new InfoPanel();
  bottomPanel.setLayout(new BorderLayout());
  bottomPanel.setTitle(null);
  SpaceButton btn = new SpaceButton("Back to star map",
      GameCommands.COMMAND_VIEW_STARMAP);
  btn.addActionListener(listener);
  bottomPanel.add(btn, BorderLayout.CENTER);

  // Add panels to base
  this.add(bottomPanel, BorderLayout.SOUTH);
}
 
Example 3
Source File: JTreeFactory.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
public static void setTreeProperties(JTree tree) {
	tree.setOpaque(false);
	tree.setBackground(ColorPalette.DARK_BACKGROUND_COLOR);
	tree.setForeground(ColorPalette.FOREGROUND_COLOR);
	tree.setFont(Fonts.FONT);
}