Java Code Examples for javax.swing.JScrollPane#HORIZONTAL_SCROLLBAR_ALWAYS

The following examples show how to use javax.swing.JScrollPane#HORIZONTAL_SCROLLBAR_ALWAYS . 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: AttachDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void showDetails(RunningVM vm) {
    HTMLTextArea area = new HTMLTextArea();
    JScrollPane areaScroll = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                                   JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    areaScroll.setBorder(BorderFactory.createEmptyBorder());
    areaScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    areaScroll.setPreferredSize(new Dimension(500, 260));
    configureScrollBar(areaScroll.getVerticalScrollBar());
    configureScrollBar(areaScroll.getHorizontalScrollBar());
    
    area.setText(getDetails(vm));
    area.setCaretPosition(0);
    
    HelpCtx helpCtx = new HelpCtx("ProcessDetails.HelpCtx"); //NOI18N
    JButton close = new JButton(Bundle.AttachDialog_BtnClose());
    close.setDefaultCapable(true);
    DialogDescriptor dd = new DialogDescriptor(areaScroll, Bundle.AttachDialog_DetailsCaption(getProcessName(vm.getMainClass())),
                          true, new Object[] { close }, close, DialogDescriptor.DEFAULT_ALIGN, helpCtx, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);
}
 
Example 2
Source File: FireSimulatorGUI.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FireSimulatorGUI(Simulator simulator, World world) {
	this.simulator = simulator;
	this.world = world;
	this.drawingPanel = new DrawingPanel();
	this.layerCheckBoxes = new ArrayList<>();
	this.stringDataTextArea = new JTextArea();

	JScrollPane layersScrollPane = new JScrollPane(tabbedPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
	layersScrollPane.setPreferredSize(new Dimension(300, 300));
	JScrollPane stringDataScrollPane = new JScrollPane(stringDataTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
	stringDataScrollPane.setPreferredSize(new Dimension(300, 300));
	
	this.setLayout(new BorderLayout());
	this.add(layersScrollPane, BorderLayout.WEST);
	this.add(drawingPanel, BorderLayout.CENTER);
	this.add(stringDataScrollPane, BorderLayout.EAST);
	
	addLayers();
	
}
 
Example 3
Source File: AttachDialog.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private static void showDetails(RunningVM vm) {
    HTMLTextArea area = new HTMLTextArea();
    JScrollPane areaScroll = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                                   JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    areaScroll.setBorder(BorderFactory.createEmptyBorder());
    areaScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    areaScroll.setPreferredSize(new Dimension(500, 260));
    configureScrollBar(areaScroll.getVerticalScrollBar());
    configureScrollBar(areaScroll.getHorizontalScrollBar());
    
    area.setText(getDetails(vm));
    area.setCaretPosition(0);
    
    HelpCtx helpCtx = new HelpCtx("ProcessDetails.HelpCtx"); //NOI18N
    JButton close = new JButton(Bundle.AttachDialog_BtnClose());
    close.setDefaultCapable(true);
    DialogDescriptor dd = new DialogDescriptor(areaScroll, Bundle.AttachDialog_DetailsCaption(getProcessName(vm.getMainClass())),
                          true, new Object[] { close }, close, DialogDescriptor.DEFAULT_ALIGN, helpCtx, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);
}
 
Example 4
Source File: HealthTab.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
private JScrollPane addTable(JTable table, HealthTableModel healthTableModel, JPanel centerPanel, BitArrayLayout rt) {

		table.setAutoCreateRowSorter(true);
//		listSelectionModel = table.getSelectionModel();
 //       listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
 //       table.setSelectionModel(listSelectionModel);
		table.addMouseListener(this);
		
		scrollPane = new JScrollPane (table, 
				   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		table.setFillsViewportHeight(true);
		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		//table.setMinimumSize(new Dimension(6200, 6000));

		centerPanel.add(scrollPane);
		return scrollPane;
	}
 
Example 5
Source File: AbstractDemoHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected JComponent createDefaultTable(final TableModel data)
{
  final JTable table = new JTable(data);
  table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

  for (int columnIndex = 0; columnIndex < data.getColumnCount(); columnIndex++)
  {
    final TableColumn column = table.getColumnModel().getColumn(columnIndex);
    column.setMinWidth(50);
    final Class c = data.getColumnClass(columnIndex);
    if (c.equals(Number.class))
    {
      column.setCellRenderer(new NumberCellRenderer());
    }
  }

  return new JScrollPane
      (table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
          JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
}
 
Example 6
Source File: AbstractDemoFrame.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected JComponent createDefaultTable(final TableModel data)
{
  final JTable table = new JTable(data);
  table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

  for (int columnIndex = 0; columnIndex < data
      .getColumnCount(); columnIndex++)
  {
    final TableColumn column = table.getColumnModel().getColumn(columnIndex);
    column.setMinWidth(50);
    final Class c = data.getColumnClass(columnIndex);
    if (c.equals(Number.class))
    {
      column.setCellRenderer(new NumberCellRenderer());
    }
  }

  return new JScrollPane
      (table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
          JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
}
 
Example 7
Source File: OutlineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public int getHorizontalScrollBarPolicy() {
    if (horizontalScrollBarIsNeeded) {
        return JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS;
    } else {
        return super.getHorizontalScrollBarPolicy();
    }
}
 
Example 8
Source File: TreesPanel.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public TreesPanel(MainFrame frame, PartitionDataList dataList) {

		this.frame = frame;
		this.dataList = dataList;

		treesTable = new JTable();
		treesTable.getTableHeader().setReorderingAllowed(false);
		treesTable.addMouseListener(new JTableButtonMouseListener(treesTable));

		treesTableModel = new TreesTableModel(this.dataList, this.frame);
		treesTable.setModel(treesTableModel);

		setLayout(new BorderLayout());

		scrollPane = new JScrollPane(treesTable,
				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
				JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		RowNumberTable rowNumberTable = new RowNumberTable(treesTable);
		scrollPane.setRowHeaderView(rowNumberTable);
		scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER,
				rowNumberTable.getTableHeader());
		scrollPane.getViewport().setOpaque(false);
		add(scrollPane, BorderLayout.CENTER);

		setTreesColumn(this.dataList);
		setTaxaSetColumn(this.dataList);

		column = treesTable.getColumnModel().getColumn(
				TreesTableModel.TAXA_COUNT_INDEX);
		column.setCellRenderer(new TableRenderer(SwingConstants.LEFT,
				new Insets(0, 2, 0, 2)));

		ActionPanel actionPanel = new ActionPanel(false);
		actionPanel.setAddAction(addTreeAction);
		actionPanel.setRemoveAction(removeTreeAction);
		add(actionPanel, BorderLayout.SOUTH);

		setTrees();

	}
 
Example 9
Source File: DiagnosticTable.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
private JTable addErrorTable() {
	if (conversionType == BitArrayLayout.CONVERT_IHU_DIAGNOSTIC) 
		tableModel = new DiagnosticTableModel();
	else if (conversionType == BitArrayLayout.CONVERT_HARD_ERROR)
		tableModel = new HardErrorTableModel();
	else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR)
		tableModel = new SoftErrorTableModel();
	else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR_84488)
		tableModel = new SoftError84488TableModel();
	else if (conversionType == BitArrayLayout.CONVERT_ICR_DIAGNOSTIC)
		tableModel = new IcrDiagnosticTableModel();
	else if (conversionType == BitArrayLayout.CONVERT_COM1_ISIS_ANT_STATUS)
		tableModel = new IsisAntennaStatusTableModel();
	
	JTable table = new JTable(tableModel);
	table.setAutoCreateRowSorter(true);
	
	scrollPane = new JScrollPane (table, 
			   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
	table.setFillsViewportHeight(true);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
	add(scrollPane, BorderLayout.CENTER);
	//add(table, BorderLayout.CENTER);

	TableColumn column = null;
	column = table.getColumnModel().getColumn(0);
	column.setPreferredWidth(45);
	
	column = table.getColumnModel().getColumn(1);
	column.setPreferredWidth(55);
	DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
	centerRenderer.setHorizontalAlignment( SwingConstants.CENTER );
	
	if (conversionType == BitArrayLayout.CONVERT_IHU_DIAGNOSTIC) {
		column = table.getColumnModel().getColumn(2);
		column.setPreferredWidth(250);
	} else if (conversionType == BitArrayLayout.CONVERT_HARD_ERROR)
		for (int i=0; i<6; i++) {
			column = table.getColumnModel().getColumn(i+2);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
	else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR) {
		for (int i=0; i<4; i++) {
			column = table.getColumnModel().getColumn(i+2);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
		if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR_84488) {
			column = table.getColumnModel().getColumn(6);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
	}
	else if (conversionType == BitArrayLayout.CONVERT_ICR_DIAGNOSTIC) {
		for (int i=0; i<4; i++) {
			column = table.getColumnModel().getColumn(i+2);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
	}
	else if (conversionType == BitArrayLayout.CONVERT_COM1_ISIS_ANT_STATUS) {
		for (int i=0; i<15; i++) {
			column = table.getColumnModel().getColumn(i+2);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
	}

	
	return table;
}
 
Example 10
Source File: TaxaPanel.java    From beast-mcmc with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TaxaPanel(PartitionDataList dataList) {

		this.dataList = dataList;

		taxaTable = new JTable();

		taxaTableModel = new TaxaTableModel(this.dataList);
		taxaTable.setModel(taxaTableModel);

		setLayout(new BorderLayout());

		taxaTable.getTableHeader().setReorderingAllowed(false);

		taxaTable.getTableHeader()
				.setDefaultRenderer(
						new HeaderRenderer(SwingConstants.LEFT, new Insets(0,
								2, 0, 2)));

		column = taxaTable.getColumnModel()
				.getColumn(TaxaTableModel.NAME_INDEX);
		column.setCellRenderer(new TableRenderer(SwingConstants.LEFT,
				new Insets(0, 2, 0, 2)));
		column.setPreferredWidth(80);

		column = taxaTable.getColumnModel().getColumn(
				TaxaTableModel.HEIGHT_INDEX);
		column.setCellRenderer(new TableRenderer(SwingConstants.LEFT,
				new Insets(0, 2, 0, 2)));
		column.setPreferredWidth(80);

		column = taxaTable.getColumnModel().getColumn(
				TaxaTableModel.TAXA_SET_INDEX);
		column.setCellRenderer(new TableRenderer(SwingConstants.LEFT,
				new Insets(0, 2, 0, 2)));
		column.setPreferredWidth(80);

		TableEditorStopper.ensureEditingStopWhenTableLosesFocus(taxaTable);

		scrollPane = new JScrollPane(taxaTable,
				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
				JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

		RowNumberTable rowNumberTable = new RowNumberTable(taxaTable);
		scrollPane.setRowHeaderView(rowNumberTable);
		scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER,
				rowNumberTable.getTableHeader());

		scrollPane.getViewport().setOpaque(false);

		setOpaque(false);
		setBorder(new BorderUIResource.EmptyBorderUIResource(
				new java.awt.Insets(12, 12, 12, 12)));
		setLayout(new BorderLayout(0, 0));

		add(scrollPane, BorderLayout.CENTER);

	}
 
Example 11
Source File: PluginTester.java    From marvinproject with GNU Lesser General Public License v3.0 4 votes vote down vote up
public PluginTester(){
		super("Plug-in Tester");
		
		// GUI
		ButtonHandler l_buttonHandler = new ButtonHandler();
		buttonLoadPlugin = new JButton("Load Plugin");
		buttonSaveImage = new JButton("Save Image");
		buttonReset = new JButton("Reset");	
		buttonConvertToBinary = new JButton("To Binary");
		buttonGenerateJarFiles = new JButton("Generate Jar Files");
		buttonBenchmark = new JButton("Benchmark");
		
		buttonLoadPlugin.addActionListener(l_buttonHandler);
		buttonSaveImage.addActionListener(l_buttonHandler);
		buttonReset.addActionListener(l_buttonHandler);
		buttonConvertToBinary.addActionListener(l_buttonHandler);
		buttonGenerateJarFiles.addActionListener(l_buttonHandler);
		buttonBenchmark.addActionListener(l_buttonHandler);
		
		imagePanel = new MarvinImagePanel();
		JScrollPane scrollPane = new JScrollPane(imagePanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		
		
		JPanel panelBottom = new JPanel();
		panelBottom.add(buttonLoadPlugin);
		panelBottom.add(buttonSaveImage);
		panelBottom.add(buttonReset);
		panelBottom.add(buttonConvertToBinary);
		panelBottom.add(buttonGenerateJarFiles);		
		panelBottom.add(buttonBenchmark);
		
		// Container
		Container l_con = getContentPane();
		l_con.setLayout(new BorderLayout());
		
		l_con.add(scrollPane, BorderLayout.CENTER);
		l_con.add(panelBottom, BorderLayout.SOUTH);
		
		
		// Load image
		originalImage = MarvinImageIO.loadImage(INITIAL_IMAGE);
		
//		originalImage = new MarvinImage(500, 500, MarvinImage.COLOR_MODEL_RGB);
//		originalImage.fillRect(0, 0, 500, 500, Color.white);
//		originalImage.fillRect(100, 100, 300, 300, Color.red);
//		originalImage.update();
		
		//originalImage = new MarvinImage(50,50);
		newImage = originalImage.clone();
		imagePanel.setImage(newImage);
		
		
		
		
		
		// Benchmark
		benchmark = new Benchmark(); 
		
		int width;
		if(originalImage.getWidth() < 460){
			width = 460;
		}
		else{
			width = originalImage.getWidth();
		}
		setSize(700,500+70);
		
		setVisible(true);
	}
 
Example 12
Source File: MarvinEditor.java    From marvinproject with GNU Lesser General Public License v3.0 votes vote down vote up
/**
	 * Constructs Marvin main class with arguments
	 * 
	 * @param a_args Arguments
	 * <p>
	 * NOTE: Marvin supports 2 arguments at initialization: 
	 * {@code windowBounds(x, y, width, height)} and {@code windowState(state)}.
	 * <br>
	 * These arguments are useful when it's working with 2 screens. 
	 * Assume second screen is set like "LEFT" and it has 1024x768 resolution. 
	 * It's possible opening Marvin directly to the second screen: 
	 * <br><br>
	 * <strong>java -cp ".";"./bin" kernel.Marvin windowBounds(-1024,0,800,600) windowState(max)</strong>
	 * <br><br>
	 * This way could help in working source code and IDE with the main screen and testing Marvin in other one.
	 */
	public MarvinEditor(String a_args[]) {
		super("MARVIN");
		loadMenuBar(); 		// Menu bars
		
		panelMain = new JPanel();
		titlep = BorderFactory.createTitledBorder("Image");
		panelMain.setBorder(titlep);
		panelMain.setSize(600, 600);
		panelMain.setLayout(new BorderLayout());
		add(panelMain);

		imagePanel = new MarvinImagePanel();
		imagePanel.enableHistory();		
		imagePanel.setImage(image);
		imageScrollPane = new JScrollPane(imagePanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		panelMain.add(imageScrollPane);
		
		// loads the File Chooser class.
		new JFileChooser();
		
		//performanceMeter = new MarvinPerformanceMeter();
		//add(performanceMeter.getPanel(), BorderLayout.SOUTH);

		newImage(500,500);
		treatArgs(a_args);
		marvin = this;
		
		setSize(800,600); 	// Default size
		setVisible(true);
	}