List of usage examples for javax.swing JTree setRowHeight
@BeanProperty(description = "The height of each cell.") public void setRowHeight(int rowHeight)
From source file:TreeRowHeight15.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.setRowHeight(15); JFrame frame = new JFrame("Image"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320);/*from w w w .j a v a2 s . com*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:TreeRowHeightCalculation.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.setRowHeight(0); JFrame frame = new JFrame("tree row height calculation"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320);/*from w w w.j a va 2 s .c om*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:TreeRowHeightCache.java
public static void main(String[] argv) { JTree tree = new JTree(); if (tree.getRowHeight() <= 0) { tree.setRowHeight(1); }/*from ww w. j a v a2 s.c om*/ tree.setRowHeight(0); JFrame frame = new JFrame("Image"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Changed Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTree tree = new JTree(); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); renderer.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 32)); int rowHeight = tree.getRowHeight(); if (rowHeight <= 0) { tree.setRowHeight(rowHeight - 1); }/*from w ww .j a v a2 s . c o m*/ Color backgroundSelection = renderer.getBackgroundSelectionColor(); renderer.setBackgroundSelectionColor(Color.blue); renderer.setBackgroundNonSelectionColor(backgroundSelection); // Swap text colors Color textSelection = renderer.getTextSelectionColor(); renderer.setTextSelectionColor(Color.green); renderer.setTextNonSelectionColor(textSelection); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:TreeChangedRenderer.java
public static void main(String args[]) { JFrame frame = new JFrame("Changed Renderer"); JTree tree = new JTree(); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); renderer.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 32)); int rowHeight = tree.getRowHeight(); if (rowHeight <= 0) { tree.setRowHeight(rowHeight - 1); }//w w w . j av a 2s. c o m // Swap background colors Color backgroundSelection = renderer.getBackgroundSelectionColor(); renderer.setBackgroundSelectionColor(renderer.getBackgroundNonSelectionColor()); renderer.setBackgroundNonSelectionColor(backgroundSelection); // Swap text colors Color textSelection = renderer.getTextSelectionColor(); renderer.setTextSelectionColor(renderer.getTextNonSelectionColor()); renderer.setTextNonSelectionColor(textSelection); JScrollPane scrollPane = new JScrollPane(tree); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private void resetTrees(int fontSize) { int rowHeight = 0; if (fontSize < 14) { currentIconDirectory = "icons/16/"; rowHeight = 16;/*w w w .j a v a 2 s.co m*/ } else if (fontSize < 18) { currentIconDirectory = "icons/24/"; rowHeight = 24; } else if (fontSize < 22) { currentIconDirectory = "icons/32/"; rowHeight = 32; } else if (fontSize < 26) { currentIconDirectory = "icons/48/"; rowHeight = 48; } else if (fontSize < 30) { currentIconDirectory = "icons/64/"; rowHeight = 64; } else { currentIconDirectory = "icons/128/"; rowHeight = 128; } for (JTree tree : trees) { tree.setRowHeight(rowHeight); tree.setCellRenderer(new IconRenderer(currentIconDirectory)); DepositTreeEditor editor = (DepositTreeEditor) tree.getCellEditor(); editor.setStandardFont(standardFont); } }