Java Code Examples for javax.swing.ScrollPaneConstants#HORIZONTAL_SCROLLBAR_AS_NEEDED

The following examples show how to use javax.swing.ScrollPaneConstants#HORIZONTAL_SCROLLBAR_AS_NEEDED . 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: PlaRomData.java    From Logisim with GNU General Public License v3.0 6 votes vote down vote up
public int editWindow() {
	this.drawing = new PlaRomPanel(this);
	panel = new JScrollPane(this.drawing, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	panel.setBorder(null);
	panel.getVerticalScrollBar().setUnitIncrement(10);
	if (this.drawing.getPreferredSize().getWidth() >= (int) (screenSize.width * 0.75))
		panel.setPreferredSize(
				new Dimension((int) (screenSize.width * 0.75), (int) panel.getPreferredSize().getHeight()));
	if (this.drawing.getPreferredSize().getHeight() >= (int) (screenSize.height * 0.75))
		panel.setPreferredSize(
				new Dimension((int) panel.getPreferredSize().getWidth(), (int) (screenSize.height * 0.75)));
	int ret = JOptionPane.showOptionDialog(null, panel,
			Strings.getter("Logisim: Pla Rom " + getSizeString() + " Edit Window").get(),
			JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, this.options, null);
	SaveData();
	return ret;
}
 
Example 2
Source File: NoteInfoPane.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void initComponents()
{
	setLayout(new BorderLayout());

	Box hbox = Box.createHorizontalBox();
	hbox.add(Box.createRigidArea(new Dimension(5, 0)));
	hbox.add(new JLabel(LanguageBundle.getString("in_descNoteName"))); //$NON-NLS-1$
	hbox.add(Box.createRigidArea(new Dimension(5, 0)));
	hbox.add(nameField);
	nameField.setText(name);
	hbox.add(Box.createRigidArea(new Dimension(5, 0)));
	hbox.add(removeButton);
	hbox.add(Box.createHorizontalGlue());

	noteField.setLineWrap(true);
	noteField.setWrapStyleWord(true);

	add(hbox, BorderLayout.NORTH);
	JScrollPane pane = new JScrollPane(noteField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
		ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	add(pane, BorderLayout.CENTER);
}
 
Example 3
Source File: ClientGUI.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Pops up a dialog box showing an alert
 */
public void doAlertDialog(String title, String message) {
    JTextPane textArea = new JTextPane();
    ReportDisplay.setupStylesheet(textArea);

    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    textArea.setText("<pre>" + message + "</pre>");
    scrollPane.setPreferredSize(new Dimension(
            (int) (getSize().getWidth() / 1.5), (int) (getSize()
                    .getHeight() / 1.5)));
    JOptionPane.showMessageDialog(frame, scrollPane, title,
            JOptionPane.ERROR_MESSAGE);
}
 
Example 4
Source File: SkinEditorMainGUI.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Pops up a dialog box showing an alert
 */
public void doAlertDialog(String title, String message) {
    JTextPane textArea = new JTextPane();
    ReportDisplay.setupStylesheet(textArea);

    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    textArea.setText("<pre>" + message + "</pre>");
    scrollPane.setPreferredSize(new Dimension(
            (int) (getSize().getWidth() / 1.5), (int) (getSize()
                    .getHeight() / 1.5)));
    JOptionPane.showMessageDialog(frame, scrollPane, title,
            JOptionPane.ERROR_MESSAGE);
}
 
Example 5
Source File: WhoIsPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WhoIsPanel(final ServiceFactory factory) {
	super(factory);
	final JPanel top = new JPanel();
	top.setLayout(new WrapLayout(FlowLayout.LEFT, 2, 0));
	_label = new JLabel("", SwingConstants.LEFT);
	top.add(_label);
	add(top, BorderLayout.NORTH);
	_textArea = new JTextArea("", 30, 70);
	_textArea.setEditable(false);
	final JScrollPane scroll = new JScrollPane(_textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	add(scroll, BorderLayout.CENTER);
	_whois.addListener(this);
}
 
Example 6
Source File: PacketDetailPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructor
 * @param services
 */
@SuppressWarnings("serial")
public PacketDetailPanel(final ServiceFactory services) {
	super(services);
	setPreferredSize(new Dimension(getPreferredSize().width, 250));
	_details = new JTextPane() {
		@Override
		public boolean getScrollableTracksViewportWidth() {
			return getUI().getPreferredSize(this).width <= getParent().getSize().width;
		}
	};
	final JScrollPane scroll = new JScrollPane(_details, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	add(scroll, BorderLayout.CENTER);
}
 
Example 7
Source File: DataPanel.java    From DiskBrowser with GNU General Public License v3.0 5 votes vote down vote up
private JScrollPane setPanel (JTextArea outputPanel, String tabName)
// ---------------------------------------------------------------------------------//
{
  outputPanel.setEditable (false);
  outputPanel.setMargin (new Insets (5, 5, 5, 5));

  JScrollPane outputScrollPane =
      new JScrollPane (outputPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
          ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  outputScrollPane.setBorder (null);              // remove the ugly default border
  add (outputScrollPane, tabName);
  return outputScrollPane;
}
 
Example 8
Source File: ScrollPanel.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
public ScrollPanel(LogFrame frame) {
	super(frame);
	this.table = new TablePanel(frame);
	JScrollPane pane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	pane.setVerticalScrollBar(table.getVerticalScrollBar());
	setLayout(new BorderLayout());
	add(pane);
}
 
Example 9
Source File: DefaultModulesPanel.java    From opt4j with MIT License 5 votes vote down vote up
@Override
public void startup() {

	tree = new MyTree(root);
	tree.setToggleClickCount(1000); // don't expand on double click hack
	tree.addMouseListener(mouseListener);
	tree.setCellRenderer(new TreeCellRenderer());
	tree.setSelectionModel(null);

	ToolTipManager.sharedInstance().registerComponent(tree);

	JScrollPane scroll = new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

	setLayout(new BorderLayout());
	add(scroll, BorderLayout.CENTER);

	Thread thread = new Thread() {
		@Override
		public void run() {
			try {
				populateTree();
			} catch (RejectedExecutionException e) {
			}
		}
	};
	thread.setPriority(Thread.MIN_PRIORITY);
	thread.start();
}
 
Example 10
Source File: LipidClassComponent.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the component.
 *
 * @param theChoices the choices available to the user.
 */
public LipidClassComponent(final Object[] theChoices) {

  super(new BorderLayout());

  setBorder(BorderFactory.createEmptyBorder(0, 9, 0, 0));

  // Create choices panel.
  choices = Arrays.stream(theChoices).filter(o -> o instanceof LipidClasses)
      .map(o -> (LipidClasses) o).toArray(LipidClasses[]::new);
  choicesPanel = new JScrollPane(new CheckBoxPanel(theChoices),
      ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
      ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  choicesPanel.getViewport().setBackground(Color.WHITE);
  add(choicesPanel, BorderLayout.WEST);

  // Create Buttons panel.
  buttonsPanel = new JPanel();
  buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
  add(buttonsPanel, BorderLayout.CENTER);

  // Add buttons.
  selectAllButton = new JButton("All");
  selectAllButton.setToolTipText("Select all choices");
  addButton(selectAllButton);
  selectNoneButton = new JButton("Clear");
  selectNoneButton.setToolTipText("Clear all selections");
  addButton(selectNoneButton);
}
 
Example 11
Source File: MarvinPluginHistory.java    From marvinproject with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Constructs a new PluginHistory.
 */
public MarvinPluginHistory()
{
	frameHistory = this;
	
	this.setLayout(new BorderLayout ());

	setResizable(true);
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	setTitle("Plug-ins history");
	
	listMarvinImage = new LinkedList<MarvinImage>();
	listMarvinAttributes = new LinkedList<MarvinAttributes>();
	listPluginName = new LinkedList<String>();
	
	panelPlugin = new JPanel();
	
	scrollPanelPlugins = new JScrollPane
	(
		panelPlugin, 
		ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
		ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
	);
	
	
	scrollPanelPlugins.setLayout(new ScrollPaneLayout());		
	add(scrollPanelPlugins);
	
	panelButtonHistory = new JPanel();
			
	buttonExportHistortAsImage = new JButton("Export as Image");
	buttonExportHistortAsImage.addActionListener(new ExportButtonHandler());
	buttonExportHistortAsImage.setMnemonic('I');
	
	// the action listener is still not created
	// so no button appears
	//btnExportHistoricText = new JButton ("Export as Text");
	//btnExportHistoricText.addActionListener (new ExportTexButtonHandler ());
	// ActionListener "ExportTextButtonHandler" need to be created!!!
	//btnExportHistoricText.setMnemonic('T');

	panelButtonHistory.add(buttonExportHistortAsImage);
	//jpBtnHistoric.add (btnExportHistoricText);

	this.add(panelButtonHistory, BorderLayout.PAGE_END);
}
 
Example 12
Source File: DataPanel.java    From DiskBrowser with GNU General Public License v3.0 4 votes vote down vote up
public DataPanel (MenuHandler mh)
// ---------------------------------------------------------------------------------//
{
  this.menuHandler = mh;
  setTabPlacement (SwingConstants.BOTTOM);

  formattedText = new JTextArea (10, TEXT_WIDTH);
  formattedPane = setPanel (formattedText, "Formatted");
  //    formattedText.setLineWrap (prefs.getBoolean (MenuHandler.PREFS_LINE_WRAP, true));
  formattedText.setText ("Please use the 'File->Set HOME folder...' command to "
      + "\ntell DiskBrowser where your Apple disks are located."
      + "\n\nTo see the contents of a disk in more detail, double-click"
      + "\nthe disk. You will then be able to select individual files to "
      + "view completely.");

  hexText = new JTextArea (10, TEXT_WIDTH);
  setPanel (hexText, "Hex dump");

  disassemblyText = new JTextArea (10, TEXT_WIDTH);
  setPanel (disassemblyText, "Disassembly");

  imagePanel = new ImagePanel ();
  imagePane =
      new JScrollPane (imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
          ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

  imagePane.setBorder (null);

  imagePane.getVerticalScrollBar ().setUnitIncrement (50);
  imagePane.getHorizontalScrollBar ().setUnitIncrement (25);

  addChangeListener (new ChangeListener ()
  {
    @Override
    public void stateChanged (ChangeEvent e)
    {
      switch (getSelectedIndex ())
      {
        case 0:
          if (!formattedTextValid)
          {
            if (currentDataSource == null)
              formattedText.setText ("");
            else
              setText (formattedText, currentDataSource.getText ());
            formattedTextValid = true;
          }
          break;
        case 1:
          if (!hexTextValid)
          {
            if (currentDataSource == null)
              hexText.setText ("");
            else
              setText (hexText, currentDataSource.getHexDump ());
            hexTextValid = true;
          }
          break;
        case 2:
          if (!assemblerTextValid)
          {
            if (currentDataSource == null)
              disassemblyText.setText ("");
            else
              setText (disassemblyText, currentDataSource.getAssembler ());
            assemblerTextValid = true;
          }
          break;
        default:
          System.out.println ("Invalid index selected in DataPanel");
      }
    }
  });

  LineWrapAction lineWrapAction = new LineWrapAction ();
  menuHandler.lineWrapItem.setAction (lineWrapAction);
  lineWrapAction.addListener (formattedText);

  menuHandler.colourQuirksItem.setAction (new ColourQuirksAction (this));
  menuHandler.monochromeItem.setAction (new MonochromeAction (this));
  menuHandler.debuggingItem.setAction (new DebuggingAction (this));

  // fill in the placeholders created by the MenuHandler
  List<Palette> palettes = HiResImage.getPalettes ();
  ButtonGroup buttonGroup = menuHandler.paletteGroup;
  Enumeration<AbstractButton> enumeration = buttonGroup.getElements ();
  int ndx = 0;
  while (enumeration.hasMoreElements ())
  {
    JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement ();
    item.setAction (new PaletteAction (this, palettes.get (ndx++)));
  }
  menuHandler.nextPaletteItem.setAction (new NextPaletteAction (this, buttonGroup));
  menuHandler.prevPaletteItem.setAction (new PreviousPaletteAction (this, buttonGroup));
}
 
Example 13
Source File: Command.java    From jsqsh with Apache License 2.0 4 votes vote down vote up
public JTextAreaCaptureStream(Session session,
        ByteArrayOutputStream buffer) {
    
    super(buffer, true);
    this.buffer = buffer;
    this.session = session;
    
    int width = 600;
    int height = 400;
    
    DimensionVariable v =
        (DimensionVariable) session.getVariableManager()
        .getVariable("window_size");
    
    if (v != null) {
        
        width = v.getWidth();
        height = v.getHeight();
    }
    
    JFrame frame = new JFrame();
    
    // Set the frame characteristics
    frame.setTitle("Query Results");
    frame.setSize(width, height);
    frame.setLocationByPlatform(true);

    // Create a panel to hold all other components
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    frame.getContentPane().add(topPanel);
    
    textArea = new JTextArea();
    textArea.setLineWrap(false);
    
    FontVariable fontVar =
        (FontVariable) session.getVariableManager()
            .getVariable("font");
    
    if (fontVar != null) {
        
        textArea.setFont(new Font(fontVar.getFontName(), Font.PLAIN,
            fontVar.getFontSize() ));
    }
    else {
    
        textArea.setFont(new Font( "Monospaced", Font.PLAIN, 10 ));
    }
    
    // Add the table to a scrolling pane
    JScrollPane scrollPane = new JScrollPane(textArea,
        ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    topPanel.add( scrollPane, BorderLayout.CENTER );
    
    frame.setVisible(true);
}
 
Example 14
Source File: ServerSetupPanel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private void layoutPlayers() {
  final JPanel players = new JPanel();
  final GridBagLayout layout = new GridBagLayout();
  players.setLayout(layout);
  final Insets spacing = new Insets(3, 16, 0, 0);
  final Insets lastSpacing = new Insets(3, 16, 0, 16);
  int gridx = 0;
  final boolean disableable =
      !model.getPlayersAllowedToBeDisabled().isEmpty()
          || model.getPlayersEnabledListing().containsValue(Boolean.FALSE);
  final GridBagConstraints enabledPlayerConstraints = new GridBagConstraints();
  if (disableable) {
    enabledPlayerConstraints.anchor = GridBagConstraints.WEST;
    enabledPlayerConstraints.gridx = gridx++;
    enabledPlayerConstraints.insets = new Insets(3, 20, 0, -10);
  }
  final GridBagConstraints nameConstraints = new GridBagConstraints();
  nameConstraints.anchor = GridBagConstraints.WEST;
  nameConstraints.gridx = gridx++;
  nameConstraints.insets = spacing;
  final GridBagConstraints playerConstraints = new GridBagConstraints();
  playerConstraints.anchor = GridBagConstraints.WEST;
  playerConstraints.gridx = gridx++;
  playerConstraints.insets = spacing;
  final GridBagConstraints localConstraints = new GridBagConstraints();
  localConstraints.anchor = GridBagConstraints.WEST;
  localConstraints.gridx = gridx++;
  localConstraints.insets = spacing;
  final GridBagConstraints typeConstraints = new GridBagConstraints();
  typeConstraints.anchor = GridBagConstraints.WEST;
  typeConstraints.gridx = gridx++;
  typeConstraints.insets = spacing;
  final GridBagConstraints allianceConstraints = new GridBagConstraints();
  allianceConstraints.anchor = GridBagConstraints.WEST;
  allianceConstraints.gridx = gridx;
  allianceConstraints.insets = lastSpacing;
  if (disableable) {
    final JLabel enableLabel = new JLabel("Use");
    enableLabel.setForeground(Color.black);
    layout.setConstraints(enableLabel, enabledPlayerConstraints);
    players.add(enableLabel);
  }
  final JLabel nameLabel = new JLabel("Name");
  nameLabel.setForeground(Color.black);
  layout.setConstraints(nameLabel, nameConstraints);
  players.add(nameLabel);
  final JLabel playedByLabel = new JLabel("Played by");
  playedByLabel.setForeground(Color.black);
  layout.setConstraints(playedByLabel, playerConstraints);
  players.add(playedByLabel);
  final JLabel localLabel = new JLabel("Local");
  localLabel.setForeground(Color.black);
  layout.setConstraints(localLabel, localConstraints);
  players.add(localLabel);
  final JLabel typeLabel = new JLabel("Type");
  typeLabel.setForeground(Color.black);
  layout.setConstraints(typeLabel, typeConstraints);
  players.add(typeLabel);
  final JLabel allianceLabel = new JLabel("Alliance");
  allianceLabel.setForeground(Color.black);
  layout.setConstraints(allianceLabel, allianceConstraints);
  players.add(allianceLabel);
  if (playerRows.isEmpty()) {
    final JLabel noPlayers = new JLabel("Load a game file first");
    layout.setConstraints(noPlayers, nameConstraints);
    players.add(noPlayers);
  }
  for (final PlayerRow row : playerRows) {
    if (disableable) {
      layout.setConstraints(row.getEnabledPlayer(), enabledPlayerConstraints);
      players.add(row.getEnabledPlayer());
    }
    layout.setConstraints(row.getName(), nameConstraints);
    players.add(row.getName());
    layout.setConstraints(row.getPlayer(), playerConstraints);
    players.add(row.getPlayer());
    layout.setConstraints(row.getLocal(), localConstraints);
    players.add(row.getLocal());
    layout.setConstraints(row.getType(), typeConstraints);
    players.add(row.getType());
    layout.setConstraints(row.getAlliance(), allianceConstraints);
    players.add(row.getAlliance());
    row.getAlliance().addActionListener(e -> allianceRowButtonFired(row));
  }
  removeAll();
  add(info, BorderLayout.NORTH);
  final JScrollPane scroll =
      new JScrollPane(
          players,
          ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
          ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scroll.setBorder(null);
  scroll.setViewportBorder(null);
  add(scroll, BorderLayout.CENTER);
  add(networkPanel, BorderLayout.SOUTH);
  invalidate();
  validate();
}
 
Example 15
Source File: TracerDataSingleView.java    From pega-tracerviewer with Apache License 2.0 4 votes vote down vote up
private JPanel getTracerDataJPanel() {

        // table can be tree or table
        CustomJTable tracerDataTable = getTracerDataTable();

        JPanel traceTableJPanel = new JPanel();
        traceTableJPanel.setLayout(new BorderLayout());

        JScrollPane traceTableScrollpane = new JScrollPane(tracerDataTable,
                ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        tracerDataTable.setPreferredScrollableViewportSize(traceTableScrollpane.getPreferredSize());

        // use the stored traceTableModel, as table can be tree or table
        TraceTableModel traceTableModel = getTraceTableModel();

        JPanel markerBarPanel = getMarkerBarPanel(traceTableModel);

        traceTableJPanel.add(traceTableScrollpane, BorderLayout.CENTER);
        traceTableJPanel.add(markerBarPanel, BorderLayout.EAST);

        return traceTableJPanel;
    }
 
Example 16
Source File: BugReportService.java    From Shuffle-Move with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return
 */
@SuppressWarnings("serial")
private JComponent getInstructionPanel() {
   ConfigManager preferencesManager = getUser().getPreferencesManager();
   final int width = preferencesManager.getIntegerValue(KEY_POPUP_WIDTH, DEFAULT_POPUP_WIDTH);
   JEditorPane textPane = new JEditorPane() {
      @Override
      public Dimension getPreferredSize() {
         Dimension d = super.getPreferredSize();
         d.width = width - 40;
         return d;
      }
   };
   textPane.setFocusable(false);
   textPane.setEditable(false);
   textPane.setContentType("text/html");
   textPane.addHyperlinkListener(new HyperlinkListener() {
      @Override
      public void hyperlinkUpdate(HyperlinkEvent e) {
         if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            if (Desktop.isDesktopSupported()) {
               try {
                  Desktop.getDesktop().browse(e.getURL().toURI());
               } catch (IOException | URISyntaxException | NullPointerException e1) {
                  LOG.severe(getString(KEY_BAD_LINK, e1.getMessage()));
               }
            }
         }
      }
   });
   JScrollPane jsp = new JScrollPane(textPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   jsp.getVerticalScrollBar().setUnitIncrement(30);
   String text = getUser().getPathManager().readEntireDocument(getFilePath(), getDefaultFileKey());
   textPane.setText(text);
   textPane.setSelectionStart(0);
   textPane.setSelectionEnd(0);
   textPane.repaint();
   jsp.validate();
   return jsp;
}
 
Example 17
Source File: MouseOptions.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
public MouseOptions(OptionsFrame window) {
	super(window, new GridLayout(1, 3));

	explorer = new ProjectExplorer(getProject());
	explorer.setListener(listener);

	// Area for adding mappings
	addArea.addMouseListener(listener);

	// Area for viewing current mappings
	model = new MappingsModel();
	mappings.setTableHeader(null);
	mappings.setModel(model);
	mappings.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	mappings.getSelectionModel().addListSelectionListener(listener);
	mappings.clearSelection();
	JScrollPane mapPane = new JScrollPane(mappings);

	// Button for removing current mapping
	JPanel removeArea = new JPanel();
	remove.addActionListener(listener);
	remove.setEnabled(false);
	removeArea.add(remove);

	// Area for viewing/changing attributes
	attrTable = new AttrTable(getOptionsFrame());

	GridBagLayout gridbag = new GridBagLayout();
	GridBagConstraints gbc = new GridBagConstraints();
	setLayout(gridbag);
	gbc.weightx = 1.0;
	gbc.weighty = 1.0;
	gbc.gridheight = 4;
	gbc.fill = GridBagConstraints.BOTH;
	JScrollPane explorerPane = new JScrollPane(explorer, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	gridbag.setConstraints(explorerPane, gbc);
	add(explorerPane);
	gbc.weightx = 0.0;
	JPanel gap = new JPanel();
	gap.setPreferredSize(new Dimension(10, 10));
	gridbag.setConstraints(gap, gbc);
	add(gap);
	gbc.weightx = 1.0;
	gbc.gridheight = 1;
	gbc.gridx = 2;
	gbc.gridy = GridBagConstraints.RELATIVE;
	gbc.weighty = 0.0;
	gridbag.setConstraints(addArea, gbc);
	add(addArea);
	gbc.weighty = 1.0;
	gridbag.setConstraints(mapPane, gbc);
	add(mapPane);
	gbc.weighty = 0.0;
	gridbag.setConstraints(removeArea, gbc);
	add(removeArea);
	gbc.weighty = 1.0;
	gridbag.setConstraints(attrTable, gbc);
	add(attrTable);

	getOptions().getMouseMappings().addMouseMappingsListener(listener);
	setCurrentTool(null);
}
 
Example 18
Source File: LogWindow.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Constructor
 */
public LogWindow(final Window parent) {
	super(parent, "Log", ModalityType.DOCUMENT_MODAL);
	final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
	for (final ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
		for (final Iterator<ch.qos.logback.core.Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext();) {
			final ch.qos.logback.core.Appender<ILoggingEvent> appender = index.next();
			if (appender instanceof Appender) {
				_appender = (Appender) appender;
				break;
			}
		}
	}
	_logs = new JTextPane() {
		@Override
		public boolean getScrollableTracksViewportWidth() {
			return getUI().getPreferredSize(this).width <= getParent().getSize().width;
		}
	};
	if (_appender != null) {
		_appender.display = this;
	}
	try {
		for (final String line : Util.readUTF8File(new FileInputStream(Env.LOG_FILE))) {
			appendFormatted(line + "\n");
		}
	} catch (final FileNotFoundException e1) {
		appendFormatted("Failed to open file " + Env.LOG_FILE.getAbsolutePath());
	}
	final JScrollPane scroll = new JScrollPane(_logs, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	scroll.setPreferredSize(new Dimension(800, 600));
	getContentPane().add(scroll, BorderLayout.CENTER);
	final JButton close = new JButton(Resources.getLabel("close.button"));
	close.addActionListener(e -> LogWindow.this.dispose());
	getContentPane().add(close, BorderLayout.SOUTH);
	SwingUtilities4.setUp(this);
	getRootPane().registerKeyboardAction(e -> {
		_appender.display = null;
		dispose();
		if (parent != null) {
			parent.toFront();
		}
	}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
 
Example 19
Source File: DJarInfo.java    From portecle with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize the dialog's GUI components.
 *
 * @throws IOException Problem occurred getting JAR information
 */
private void initComponents()
    throws IOException
{
	JarFile[] jarFiles = getClassPathJars();

	// JAR Information table

	// Create the table using the appropriate table model
	JarInfoTableModel jiModel = new JarInfoTableModel();
	jiModel.load(jarFiles);

	JTable jtJarInfo = new JTable(jiModel);

	jtJarInfo.setRowMargin(0);
	jtJarInfo.getColumnModel().setColumnMargin(0);
	jtJarInfo.getTableHeader().setReorderingAllowed(false);
	jtJarInfo.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	jtJarInfo.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	// Add custom renderers for the table cells and headers
	for (int iCnt = 0; iCnt < jtJarInfo.getColumnCount(); iCnt++)
	{
		TableColumn column = jtJarInfo.getColumnModel().getColumn(iCnt);

		column.setPreferredWidth(150);

		column.setHeaderRenderer(new JarInfoTableHeadRend());
		column.setCellRenderer(new JarInfoTableCellRend());
	}

	// Make the table sortable
	jtJarInfo.setAutoCreateRowSorter(true);
	// ...and sort it by jar file by default
	jtJarInfo.getRowSorter().toggleSortOrder(0);

	// Put the table into a scroll pane
	JScrollPane jspJarInfoTable = new JScrollPane(jtJarInfo, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
	    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	jspJarInfoTable.getViewport().setBackground(jtJarInfo.getBackground());

	// Put the scroll pane into a panel
	JPanel jpJarInfoTable = new JPanel(new BorderLayout(10, 10));
	jpJarInfoTable.setPreferredSize(new Dimension(500, 150));
	jpJarInfoTable.add(jspJarInfoTable, BorderLayout.CENTER);
	jpJarInfoTable.setBorder(new EmptyBorder(5, 5, 5, 5));

	JButton jbOK = getOkButton(true);
	JPanel jpOK = new JPanel(new FlowLayout(FlowLayout.CENTER));
	jpOK.add(jbOK);

	getContentPane().add(jpJarInfoTable, BorderLayout.CENTER);
	getContentPane().add(jpOK, BorderLayout.SOUTH);

	getRootPane().setDefaultButton(jbOK);

	initDialog();

	jbOK.requestFocusInWindow();
}
 
Example 20
Source File: TracerDataCompareView.java    From pega-tracerviewer with Apache License 2.0 3 votes vote down vote up
private JScrollPane getJScrollPane(TraceTable traceTable) {

        JScrollPane jscrollpane = new JScrollPane(traceTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        traceTable.setPreferredScrollableViewportSize(jscrollpane.getPreferredSize());

        return jscrollpane;
    }