Java Code Examples for javax.swing.JScrollPane#setSize()

The following examples show how to use javax.swing.JScrollPane#setSize() . 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: SimpleInfoBox.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
public SimpleInfoBox( final String title, final String text )
{
	frame = new JFrame( title );

	final JTextArea textarea = new JTextArea( text );

	final JPanel panel = new JPanel();
	panel.add( textarea, BorderLayout.CENTER );
	final JScrollPane pane = new JScrollPane( panel );
	frame.add( pane, BorderLayout.CENTER );

	frame.pack();

	final Dimension d = pane.getSize();
	d.setSize( d.width + 20, d.height + 10 );
	pane.setSize( d );
	pane.setPreferredSize( d );
	frame.setPreferredSize( d );

	frame.pack();
	frame.setVisible( true );
}
 
Example 2
Source File: QueryPanel.java    From wandora with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mouseDragged(MouseEvent e) {
    Point p = e.getPoint();
    if(mousePressedInTriangle) {
        inTheTriangleZone = true;
        int yDiff = (mousePressedPoint.y - p.y);
        newSize = new Dimension(100, sizeAtPress.height - yDiff);

        JScrollPane sp = getScrollPane();

        if(scrollPane != null) {
            sp.getViewport().setSize(newSize);
            sp.getViewport().setPreferredSize(newSize);
            sp.getViewport().setMinimumSize(newSize);

            sp.setSize(newSize);
            sp.setPreferredSize(newSize);
            sp.setMinimumSize(newSize);
        }

        scriptQueryPanel.setSize(scriptQueryPanelWidth, scriptQueryPanelHeight - yDiff);
        scriptQueryPanel.revalidate();
        scriptQueryPanel.repaint();
    }
}
 
Example 3
Source File: TMQLPanel.java    From wandora with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mouseDragged(MouseEvent e) {
    Point p = e.getPoint();
    if(mousePressedInTriangle) {
        inTheTriangleZone = true;
        int yDiff = (mousePressedPoint.y - p.y);
        newSize = new Dimension(100, sizeAtPress.height - yDiff);

        JScrollPane sp = getScrollPane();

        if(scrollPane != null) {
            sp.getViewport().setSize(newSize);
            sp.getViewport().setPreferredSize(newSize);
            sp.getViewport().setMinimumSize(newSize);

            sp.setSize(newSize);
            sp.setPreferredSize(newSize);
            sp.setMinimumSize(newSize);
        }

        tmqlPanel.setSize(tmqlPanelWidth, tmqlPanelHeight - yDiff);
        tmqlPanel.revalidate();
        tmqlPanel.repaint();
    }
}
 
Example 4
Source File: ResultStatisticTab.java    From incubator-iotdb with Apache License 2.0 5 votes vote down vote up
ResultStatisticTab(String planName, Map<String, List<TimeSeriesStatistics>>
    timeseriesStatistics, TabCloseCallBack closeCallBack) {
  super(planName, closeCallBack);

  table = new JTable();

  Box box = Box.createVerticalBox();
  // the header and the data should be added separately
  box.add(table.getTableHeader());
  box.add(table);

  // provides a scroll bar for many series
  JScrollPane scrollPane = new JScrollPane(box);
  scrollPane.setLocation(0, 100);
  scrollPane.setSize(800, 600);
  add(scrollPane);

  Object[] header = TimeSeriesStatistics.HEADER;
  List<TimeSeriesStatistics> allStatistics = new ArrayList<>();
  for (List<TimeSeriesStatistics> seriesStatistics : timeseriesStatistics.values()) {
    allStatistics.addAll(seriesStatistics);
  }
  allStatistics.sort(Comparator.comparing(TimeSeriesStatistics::getName));
  Object[][] data = new Object[allStatistics.size()][];
  for (int i = 0; i < allStatistics.size(); i++) {
    data[i] = allStatistics.get(i).toArray();
  }
  tableModel = new DefaultTableModel(data, header);
  table.setModel(tableModel);
  // enable sort by column
  table.setRowSorter(new TableRowSorter<>(tableModel));
}
 
Example 5
Source File: OpenSystemModelsManager.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
private void initModels() {
    setSize(375, openModels.size() * 265 + 50);
    setTitle("Manage Plots Seawater/Open Sys Isochrons");
    setAlwaysOnTop(true);

    JPanel modelsPanel = new JPanel(null);
    modelsPanel.setSize(300, openModels.size() * 250);
    modelsPanel.setBackground(new Color(249, 237, 189));
    modelsPanel.setPreferredSize(new Dimension(300, openModels.size() * 265 + 25));
    
    int count = 0;
    for (OpenSystemIsochronTableModel osm : openModels) {
        JPanel openPanel = new OpenSystemModelDataView(osm);
        openPanel.setBounds(10, count * 245 + 10, 300, 235);
        modelsPanel.add(openPanel);
        count++;
    }
    
    JButton okButton =  new ET_JButton("OK");
    okButton.setBounds(15, count * 245 + 10, 290, 25);
    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    modelsPanel.add(okButton);

    JScrollPane modelsScroll = new JScrollPane(modelsPanel);
    modelsScroll.setSize(300, openModels.size() * 265);
    
    setContentPane(modelsScroll);
}
 
Example 6
Source File: HexCharMapDialog.java    From tn5250j with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Displays the dialog
 *
 * @return a String, containing the selected character OR null, if nothing was selected
 */
public String showModal() {

	final JScrollPane listScrollPane = new JScrollPane(hexList);
	listScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
	listScrollPane.setSize(40,100);

	final JPanel srp = new JPanel();
	srp.setLayout(new BorderLayout());
	srp.add(listScrollPane,BorderLayout.CENTER);

	final String[] options = {LangTool.getString("hm.optInsert"), LangTool.getString("hm.optCancel")};

	int result = JOptionPane.showOptionDialog(
			parent,   // the parent that the dialog blocks
			new Object[] {srp},                // the dialog message array
			LangTool.getString("hm.title"),    // the title of the dialog window
			JOptionPane.DEFAULT_OPTION,        // option type
			JOptionPane.INFORMATION_MESSAGE,      // message type
			null,                              // optional icon, use null to use the default icon
			options,                           // options string array, will be made into buttons//
			options[0]                         // option that should be made into a default button
	);

	if (result == 0) {
		final String selval = (String) hexList.getSelectedValue();
		return selval.substring(selval.length()-1);
	}
	return null;
}