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

The following examples show how to use javax.swing.JScrollPane#setMinimumSize() . 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: PreferencesDialog.java    From LoboBrowser with MIT License 6 votes vote down vote up
private Component createLeftPane() {
  final PreferencesTree prefsTree = this.preferencesTree;
  prefsTree.addTreeSelectionListener(new LocalTreeSelectionListener());
  final JScrollPane scrollPane = new JScrollPane(prefsTree);
  final Dimension size = new Dimension(150, 200);
  scrollPane.setPreferredSize(size);
  scrollPane.setMinimumSize(size);
  scrollPane.setMaximumSize(new Dimension(150, Short.MAX_VALUE));
  return scrollPane;
}
 
Example 2
Source File: DeadLinkPanel.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * Construct the panel components.
 */
private void constructContents() {
  GridBagConstraints constraints = new GridBagConstraints(
      0, 0, 1, 1, 1, 0,
      GridBagConstraints.LINE_START, GridBagConstraints.BOTH,
      new Insets(0, 0, 0, 0), 0, 0);

  // Text
  String message = GT._T("The following links seem to be dead:");
  labelMessage = new JLabel(message);
  add(labelMessage, constraints);
  constraints.gridy++;

  // List of detections
  DeadLinkListTableModel modelErrors =
      new DeadLinkListTableModel(wiki, errors, textPane);
  JTable tableErrors = new JTable(modelErrors);
  modelErrors.configureColumnModel(tableErrors.getColumnModel());
  JScrollPane scrollErrors = new JScrollPane(tableErrors);
  scrollErrors.setMinimumSize(new Dimension(500, 100));
  scrollErrors.setPreferredSize(new Dimension(800, 200));
  scrollErrors.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  constraints.weighty = 1;
  add(scrollErrors, constraints);
  constraints.gridy++;
}
 
Example 3
Source File: LinterErrorPanel.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * Construct the panel components.
 */
private void constructContents() {
  GridBagConstraints constraints = new GridBagConstraints(
      0, 0, 1, 1, 1, 0,
      GridBagConstraints.LINE_START, GridBagConstraints.BOTH,
      new Insets(0, 0, 0, 0), 0, 0);

  // Text
  String message = GT._T("The following errors are currently detected by Linter:");
  labelMessage = new JLabel(message);
  add(labelMessage, constraints);
  constraints.gridy++;

  // List of detections
  LinterErrorListTableModel modelErrors =
      new LinterErrorListTableModel(wiki, errors, textPane);
  JTable tableErrors = new JTable(modelErrors);
  modelErrors.configureColumnModel(tableErrors.getColumnModel());
  JScrollPane scrollErrors = new JScrollPane(tableErrors);
  scrollErrors.setMinimumSize(new Dimension(500, 100));
  scrollErrors.setPreferredSize(new Dimension(800, 200));
  scrollErrors.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  constraints.weighty = 1;
  add(scrollErrors, constraints);
  constraints.gridy++;
}
 
Example 4
Source File: StdOutWindow.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
private Component wrap(Component c, String title) {
	JScrollPane s = new JScrollPane(c);
	s.setBackground(Color.white);
	s.setMinimumSize(new Dimension(400,15));
	s.setPreferredSize(new Dimension(400,200));
	s.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0,5,0,5), title));
	return s;
}
 
Example 5
Source File: Utility.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
public static/* Create add/remove/edit panel */
JPanel createPanel(ActionListener listener, String panelName,
		JList panelJList, JButton addButton, JButton removeButton,
		JButton editButton) {
	JPanel Panel = new JPanel(new BorderLayout());
	JPanel addRem = new JPanel();
	if (addButton != null) {
		addButton.addActionListener(listener);
		addRem.add(addButton);
	}
	if (removeButton != null) {
		removeButton.addActionListener(listener);
		addRem.add(removeButton);
	}
	if (editButton != null) {
		addRem.add(editButton);
		editButton.addActionListener(listener);
	}

	JLabel panelLabel = new JLabel("List of " + panelName + ":");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(panelJList);

	if (listener instanceof MouseListener) {
		panelJList.addMouseListener((MouseListener) listener);
	}
	Panel.add(panelLabel, "North");
	Panel.add(scroll, "Center");
	Panel.add(addRem, "South");
	return Panel;
}
 
Example 6
Source File: NoteEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link Note} editor.
 *
 * @param note The {@link Note} to edit.
 */
public NoteEditor(Note note) {
    super(note);
    JPanel content   = new JPanel(new ColumnLayout(2, RowDistribution.GIVE_EXCESS_TO_LAST));
    JLabel iconLabel = new JLabel(note.getIcon(true));
    JPanel right     = new JPanel(new ColumnLayout(1, RowDistribution.GIVE_EXCESS_TO_LAST));
    content.add(iconLabel);
    content.add(right);

    mReferenceField = new JTextField(Text.makeFiller(6, 'M'));
    UIUtilities.setToPreferredSizeOnly(mReferenceField);
    mReferenceField.setText(note.getReference());
    mReferenceField.setToolTipText(Text.wrapPlainTextForToolTip(I18n.Text("A reference to the book and page this note applies to (e.g. B22 would refer to \"Basic Set\", page 22)")));
    mReferenceField.setEnabled(mIsEditable);
    JPanel wrapper = new JPanel(new ColumnLayout(4));
    wrapper.add(new LinkedLabel(I18n.Text("Note Content:")));
    wrapper.add(new JPanel());
    wrapper.add(new LinkedLabel(I18n.Text("Page Reference"), mReferenceField));
    wrapper.add(mReferenceField);
    right.add(wrapper);

    mEditor = new JTextArea(note.getDescription());
    mEditor.setLineWrap(true);
    mEditor.setWrapStyleWord(true);
    mEditor.setEnabled(mIsEditable);
    JScrollPane scroller = new JScrollPane(mEditor, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroller.setMinimumSize(new Dimension(400, 300));
    iconLabel.setVerticalAlignment(SwingConstants.TOP);
    iconLabel.setAlignmentY(-1.0f);
    right.add(scroller);

    add(content);
}
 
Example 7
Source File: SkillEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private JScrollPane embedEditor(Container editor) {
    JScrollPane scrollPanel = new JScrollPane(editor);
    scrollPanel.setMinimumSize(new Dimension(500, 120));
    scrollPanel.setName(editor.toString());
    if (!mIsEditable) {
        UIUtilities.disableControls(editor);
    }
    return scrollPanel;
}
 
Example 8
Source File: JTextPaneTest.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
private Component createTextPane() {
  textNewSection = new JTextPane();
  textNewSection.setBackground(Color.WHITE);
  textNewSection.setEditable(true);
  JScrollPane scrollContents = new JScrollPane(textNewSection);
  scrollContents.setMinimumSize(new Dimension(100, 100));
  scrollContents.setPreferredSize(new Dimension(1000, 500));
  scrollContents.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  return scrollContents;
}
 
Example 9
Source File: ImageTreePanel.java    From moa with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 * @param chart
 */
public ImageTreePanel(ImageChart chart[]) {
    super(new GridLayout(1, 0));
    this.chart = chart;
    //Create the nodes.
    DefaultMutableTreeNode top
            = new DefaultMutableTreeNode("Images");
    imgPanel = new JPanel();
    imgPanel.setLayout(new GridLayout(1, 0));
    createNodes(top);
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    tree.setSelectionRow(1);

    tree.addTreeSelectionListener(this);
    ImageIcon leafIcon = new ImageIcon("icon/img.png");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer
                = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    }
    imgPanel.updateUI();
    JScrollPane treeView = new JScrollPane(tree);
    treeView.setMinimumSize(new Dimension(100, 50));

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(imgPanel);
    splitPane.setDividerLocation(100);
    splitPane.setPreferredSize(new Dimension(500, 300));
    add(splitPane);

}
 
Example 10
Source File: AdvantageModifierEnabler.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private AdvantageModifierEnabler(Advantage advantage, int remaining) {
    super(new BorderLayout());
    mAdvantage = advantage;
    add(createTop(advantage, remaining), BorderLayout.NORTH);
    JScrollPane scrollPanel = new JScrollPane(createCenter());
    scrollPanel.setMinimumSize(new Dimension(500, 120));
    add(scrollPanel, BorderLayout.CENTER);
}
 
Example 11
Source File: DatabaseManagerSwing.java    From evosql with Apache License 2.0 4 votes vote down vote up
private void initGUI() {

        JPanel pCommand = new JPanel();

        pResult = new JPanel();
        nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand,
                                     pResult);

        // Added: (weconsultants@users)
        nsSplitPane.setOneTouchExpandable(true);
        pCommand.setLayout(new BorderLayout());
        pResult.setLayout(new BorderLayout());

        Font fFont = new Font("Dialog", Font.PLAIN, 12);

        txtCommand = new JTextArea(7, 40);

        txtCommand.setMargin(new Insets(5, 5, 5, 5));
        txtCommand.addKeyListener(this);

        txtCommandScroll = new JScrollPane(txtCommand);
        txtResult        = new JTextArea(25, 40);

        txtResult.setMargin(new Insets(5, 5, 5, 5));

        txtResultScroll = new JScrollPane(txtResult);

        txtCommand.setFont(fFont);
        txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
        pCommand.add(txtCommandScroll, BorderLayout.CENTER);

        gResult = new GridSwing();

        TableSorter sorter = new TableSorter(gResult);

        tableModel   = sorter;
        gResultTable = new JTable(sorter);

        sorter.setTableHeader(gResultTable.getTableHeader());

        gScrollPane = new JScrollPane(gResultTable);

        gResultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        gResult.setJTable(gResultTable);

        //getContentPane().setLayout(new BorderLayout());
        pResult.add(gScrollPane, BorderLayout.CENTER);

        // Set up the tree
        rootNode    = new DefaultMutableTreeNode("Connection");
        treeModel   = new DefaultTreeModel(rootNode);
        tTree       = new JTree(treeModel);
        tScrollPane = new JScrollPane(tTree);

        // System.out.println("Adding mouse listener");
        tTree.addMouseListener(this);
        tScrollPane.setPreferredSize(new Dimension(200, 400));
        tScrollPane.setMinimumSize(new Dimension(70, 100));
        txtCommandScroll.setPreferredSize(new Dimension(560, 100));
        txtCommandScroll.setMinimumSize(new Dimension(180, 100));
        gScrollPane.setPreferredSize(new Dimension(460, 300));

        ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane,
                                     nsSplitPane);

        // Added: (weconsultants@users)
        ewSplitPane.setOneTouchExpandable(true);
        fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);

        // Added: (weconsultants@users)
        jStatusLine = new JLabel();
        iReadyStatus =
            new JButton(new ImageIcon(CommonSwing.getIcon("StatusReady")));

        iReadyStatus.setSelectedIcon(
            new ImageIcon(CommonSwing.getIcon("StatusRunning")));

        pStatus = new JPanel();

        pStatus.setLayout(new BorderLayout());
        pStatus.add(iReadyStatus, BorderLayout.WEST);
        pStatus.add(jStatusLine, BorderLayout.CENTER);
        fMain.getContentPane().add(pStatus, "South");
        doLayout();

        if (fMain instanceof java.awt.Window) {
            ((java.awt.Window) fMain).pack();
        } else {
            ((Container) fMain).validate();
        }
    }
 
Example 12
Source File: ProgressLog.java    From stendhal with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a new page.
 */
Page() {
	this.setLayout(new SBoxLayout(SBoxLayout.VERTICAL));
	JComponent panels = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, SBoxLayout.COMMON_PADDING);
	add(panels, SBoxLayout.constraint(SLayout.EXPAND_X,
			SLayout.EXPAND_Y));

	indexArea = new PrettyEditorPane();
	indexArea.addHyperlinkListener(this);

	indexScrollPane = new JScrollPane(indexArea);
	// Fixed width
	indexScrollPane.setMaximumSize(new Dimension(INDEX_WIDTH, Integer.MAX_VALUE));
	indexScrollPane.setMinimumSize(new Dimension(INDEX_WIDTH, 0));
	// Turn off caret following
	Caret caret = indexArea.getCaret();
	if (caret instanceof DefaultCaret) {
		((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
	}

	panels.add(indexScrollPane, SLayout.EXPAND_Y);

	contentArea = new PrettyEditorPane();
	// Does not need a listener. There should be no links

	contentScrollPane = new JScrollPane(contentArea);
	panels.add(contentScrollPane, SBoxLayout.constraint(SLayout.EXPAND_X,
			SLayout.EXPAND_Y));

	JComponent buttonBox = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, SBoxLayout.COMMON_PADDING);
	buttonBox.setAlignmentX(RIGHT_ALIGNMENT);
	buttonBox.setBorder(BorderFactory.createEmptyBorder(SBoxLayout.COMMON_PADDING,
			0, SBoxLayout.COMMON_PADDING, SBoxLayout.COMMON_PADDING));
	add(buttonBox);
	// A button for reloading the page contents
	JButton refresh = new JButton("Update");
	refresh.setMnemonic(KeyEvent.VK_U);
	refresh.setAlignmentX(Component.RIGHT_ALIGNMENT);
	refresh.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent event) {
			update();
		}
	});
	buttonBox.add(refresh);
	JButton closeButton = new JButton("Close");
	closeButton.setMnemonic(KeyEvent.VK_C);
	closeButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			getWindow().dispose();
		}
	});
	buttonBox.add(closeButton);
}
 
Example 13
Source File: DisambiguationWindow.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * @return Links components.
 */
private Component createLinksComponents() {
  JPanel panel = new JPanel(new GridBagLayout());
  Configuration configuration = Configuration.getConfiguration();

  listLinks = new JList<Page>(modelLinks);

  // Initialize constraints
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(0, 0, 0, 0);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 1;
  constraints.weighty = 0;

  // Select next links button
  buttonSelectNextLinks = Utilities.createJButton(GT._T("Select &next links"), null);
  buttonSelectNextLinks.addActionListener(EventHandler.create(
      ActionListener.class, this, "actionSelectNextLinks"));
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.weightx = 1;
  panel.add(buttonSelectNextLinks, constraints);
  constraints.gridy++;

  // Automatic fixing
  buttonAutomaticFixing = Utilities.createJButton(GT._T("Automatic fixing"), null);
  buttonAutomaticFixing.addActionListener(EventHandler.create(
      ActionListener.class, this, "actionRunAutomaticFixing"));
  panel.add(buttonAutomaticFixing, constraints);
  constraints.gridy++;

  // Button toolbar
  JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL);
  toolbar.setFloatable(false);
  toolbar.setBorderPainted(false);
  buttonFullAnalysisLink = ActionFullAnalysis.addButton(
      getParentComponent(), toolbar, getWikipedia(), listLinks, knownPages, true, true);
  ActionDisambiguationAnalysis.addButton(
      getParentComponent(), toolbar, getWikipedia(), listLinks, true, true);
  buttonMarkNormal = Utilities.createJButton(
      "wpc-mark-normal.png", EnumImageSize.NORMAL,
      GT._T("Mark backlink as normal"), false, null);
  buttonMarkNormal.addActionListener(EventHandler.create(
      ActionListener.class, this, "actionMarkBacklinkNormal"));
  toolbar.add(buttonMarkNormal);
  buttonMarkNeedHelp = Utilities.createJButton(
      "wpc-mark-need-help.png", EnumImageSize.NORMAL,
      GT._T("Mark backlink as needing help"), false, null);
  buttonMarkNeedHelp.addActionListener(EventHandler.create(
      ActionListener.class, this, "actionMarkBacklinkHelpNeeded"));
  toolbar.add(buttonMarkNeedHelp);
  buttonViewLink = ActionExternalViewer.addButton(
      toolbar, getWikipedia(), listLinks, false, true, true);
  toolbar.addSeparator();
  linkCount = new JLabel(GT._T("Link count"));
  toolbar.add(linkCount);
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.weightx = 1;
  constraints.weighty = 0;
  panel.add(toolbar, constraints);
  constraints.gridy++;

  // Links
  listCellRenderer = new PageListCellRenderer();
  listCellRenderer.showRedirect(true);
  listCellRenderer.showRedirectBacklinks(true);
  if (getPage() != null) {
    listCellRenderer.setPageProperties(configuration.getSubProperties(
        getWikipedia(), Configuration.PROPERTIES_BACKLINKS, getPage().getTitle()));
  }
  listLinks.setCellRenderer(listCellRenderer);
  popupListenerLinks = new DisambiguationPageListPopupListener(
      getWikipedia(), getTextContents(), listLinks, this);
  listLinks.addMouseListener(popupListenerLinks);
  listLinks.addMouseListener(new PageListAnalyzeListener(getWikipedia(), this));
  JScrollPane scrollLinks = new JScrollPane(listLinks);
  scrollLinks.setMinimumSize(new Dimension(100, 100));
  scrollLinks.setPreferredSize(new Dimension(200, 500));
  scrollLinks.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  constraints.fill = GridBagConstraints.BOTH;
  constraints.weighty = 1;
  panel.add(scrollLinks, constraints);
  constraints.gridy++;

  return panel;
}
 
Example 14
Source File: PropertySheetPanel.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
private void buildUI() {
  LookAndFeelTweaks.setBorderLayout(this);
  LookAndFeelTweaks.setBorder(this);

  actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
  actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
  actionPanel.setOpaque(false);
  add("North", actionPanel);

  sortButton = new JToggleButton(new ToggleSortingAction());
  sortButton.setUI(new BlueishButtonUI());
  sortButton.setText(null);
  sortButton.setOpaque(false);
  actionPanel.add(sortButton);

  asCategoryButton = new JToggleButton(new ToggleModeAction());
  asCategoryButton.setUI(new BlueishButtonUI());
  asCategoryButton.setText(null);
  asCategoryButton.setOpaque(false);
  actionPanel.add(asCategoryButton);

  descriptionButton = new JToggleButton(new ToggleDescriptionAction());
  descriptionButton.setUI(new BlueishButtonUI());
  descriptionButton.setText(null);
  descriptionButton.setOpaque(false);
  actionPanel.add(descriptionButton);

  split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  split.setBorder(null);
  split.setResizeWeight(1.0);
  split.setContinuousLayout(true);
  add("Center", split);
  
  tableScroll = new JScrollPane();
  tableScroll.setBorder(BorderFactory.createEmptyBorder());
  split.setTopComponent(tableScroll);

  descriptionPanel = new JEditorPane("text/html", "<html>");
  descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
  descriptionPanel.setEditable(false);
  descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
  LookAndFeelTweaks.htmlize(descriptionPanel);

  selectionListener = new SelectionListener();

  descriptionScrollPane = new JScrollPane(descriptionPanel);
  descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
    .createLineBorder(UIManager.getColor("controlDkShadow"))));
  descriptionScrollPane.getViewport().setBackground(
    descriptionPanel.getBackground());
  descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
  split.setBottomComponent(descriptionScrollPane);
  
  // by default description is not visible, toolbar is visible.
  setDescriptionVisible(false);
  setToolBarVisible(true);
}
 
Example 15
Source File: AutomaticFixingWindow.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * @return Links components.
 */
private Component createLinksComponents() {
  JPanel panel = new JPanel(new GridBagLayout());

  listPages = new JList<Page>(modelPages);

  // Initialize constraints
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(0, 0, 0, 0);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 1;
  constraints.weighty = 0;

  // Button toolbar
  JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL);
  toolbar.setFloatable(false);
  ActionFullAnalysis.addButton(
      getParentComponent(), toolbar, getWikipedia(), listPages, null, true, true);
  ActionDisambiguationAnalysis.addButton(
      getParentComponent(), toolbar, getWikipedia(), listPages, true, true);
  ActionExternalViewer.addButton(
      toolbar, getWikipedia(), listPages, false, true, true);
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.weighty = 0;
  panel.add(toolbar, constraints);
  constraints.gridy++;

  // Pages
  listCellRenderer = new PageListCellRenderer();
  listCellRenderer.showRedirect(true);
  listPages.setCellRenderer(listCellRenderer);
  JScrollPane scrollPages = new JScrollPane(listPages);
  scrollPages.setMinimumSize(new Dimension(100, 100));
  scrollPages.setPreferredSize(new Dimension(200, 500));
  scrollPages.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  constraints.fill = GridBagConstraints.BOTH;
  constraints.weighty = 1;
  panel.add(scrollPages, constraints);
  constraints.gridy++;

  return panel;
}
 
Example 16
Source File: UpgradesPanel.java    From Rails with GNU General Public License v2.0 4 votes vote down vote up
public UpgradesPanel(ORUIManager orUIManager, boolean omitButtons) {
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    
    this.orUIManager = orUIManager;
    this.omitButtons = omitButtons;
    //this.setBackground(Color.DARK_GRAY);
    //this.setBorder(border);

    int width = (int) Math.round(110 * (2 + GUIGlobals.getFontsScale()) / 3);
    int height = 200;
    
    this.setPreferredSize(new Dimension(width, height + 50));
    this.setMaximumSize(new Dimension(width, height + 50));
    setVisible(true);

    upgradePanel = new JPanel();

    upgradePanel.setOpaque(true);
    upgradePanel.setLayout(new BoxLayout(upgradePanel, BoxLayout.PAGE_AXIS));
    upgradePanel.setBackground(Color.DARK_GRAY);

    scrollPane = new JScrollPane(upgradePanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setPreferredSize(new Dimension(width, height));
    scrollPane.setMinimumSize(new Dimension(width, height));
    

    Action confirmAction = new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            UpgradesPanel.this.orUIManager.confirmUpgrade();
        }
    };
    
    confirmAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_D);

    Action skipAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            UpgradesPanel.this.orUIManager.skipUpgrade();;
        }
    };
    skipAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
    

    confirmButton = new RailsIconButton(RailsIcon.CONFIRM, confirmAction);
    confirmButton.setEnabled(false);

    skipButton = new RailsIconButton(RailsIcon.SKIP, skipAction);
    skipButton.setEnabled(false);
     
    if (omitButtons) {
        confirmButton.setVisible(false);
        skipButton.setVisible(false);
    } else {
        Dimension buttonDimension = new Dimension(Short.MAX_VALUE, 25);
        confirmButton.setMaximumSize(buttonDimension);
        confirmButton.setAlignmentX(Component.CENTER_ALIGNMENT);
        skipButton.setMaximumSize(buttonDimension);
        skipButton.setAlignmentX(Component.CENTER_ALIGNMENT);
        add(confirmButton);
        add(skipButton);
    }
    add(scrollPane);
    
    setButtons();
    
    revalidate();

}
 
Example 17
Source File: OnePageAnalysisWindow.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * @return Check Wiki components.
 */
private Component createCheckWikiComponents() {
  JPanel panel = new JPanel(new GridBagLayout());

  // Initialize constraints
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(0, 0, 0, 0);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 1;
  constraints.weighty = 0;

  // Initialize algorithms list
  allAlgorithms = CheckErrorAlgorithms.getAlgorithms(getWikipedia());
  if (allAlgorithms == null) {
    allAlgorithms = Collections.emptyList();
  }

  // Title
  JLabel labelErrors = Utilities.createJLabel(GT._T("Check Wikipedia"));
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.weightx = 1;
  constraints.weighty = 0;
  panel.add(labelErrors, constraints);
  constraints.gridy++;

  // Errors list
  modelErrors = new DefaultListModel<CheckErrorPage>();
  listErrors = new JList<CheckErrorPage>(modelErrors);
  CheckErrorPageListCellRenderer cellRenderer = new CheckErrorPageListCellRenderer(false);
  cellRenderer.showCountOccurence(true);
  listErrors.setCellRenderer(cellRenderer);
  listErrors.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  listErrors.addListSelectionListener(new AnalysisListSelectionListener());
  JScrollPane scrollErrors = new JScrollPane(listErrors);
  scrollErrors.setMinimumSize(new Dimension(200, 100));
  scrollErrors.setPreferredSize(new Dimension(200, 200));
  scrollErrors.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  constraints.fill = GridBagConstraints.BOTH;
  constraints.weightx = 1;
  constraints.weighty = 1;
  panel.add(scrollErrors, constraints);
  constraints.gridy++;

  return panel;
}
 
Example 18
Source File: DiceChooser.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private void createComponents() {
  final JPanel diceButtonPanel = new JPanel();
  diceButtonPanel.setLayout(new BoxLayout(diceButtonPanel, BoxLayout.X_AXIS));
  diceButtonPanel.add(Box.createHorizontalStrut(40));
  for (int roll = 1; roll <= diceSides; roll++) {
    diceButtonPanel.add(Box.createHorizontalStrut(4));
    final int dieNum = roll;
    final DieType dieType = roll == hitAt ? DieType.HIT : DieType.MISS;
    final JButton button = new JButton(uiContext.getDiceImageFactory().getDieIcon(roll, dieType));
    button.addActionListener(e -> addDie(dieNum));
    buttons.add(button);
    button.setPreferredSize(
        new Dimension(DiceImageFactory.DIE_WIDTH + 4, DiceImageFactory.DIE_HEIGHT + 4));
    diceButtonPanel.add(button);
  }
  diceButtonPanel.add(Box.createHorizontalStrut(4));
  undoButton = new JButton(SwingAction.of("Undo", e -> removeLastDie()));
  diceButtonPanel.add(undoButton);
  diceButtonPanel.add(Box.createHorizontalStrut(40));
  diceCountLabel = new JLabel("Dice remaining:   ");
  final JPanel labelPanel = new JPanel();
  labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.X_AXIS));
  labelPanel.add(diceCountLabel);
  dicePanel = new JPanel();
  dicePanel.setBorder(BorderFactory.createLoweredBevelBorder());
  dicePanel.setLayout(new BoxLayout(dicePanel, BoxLayout.X_AXIS));
  final JScrollPane scroll = new JScrollPane(dicePanel);
  scroll.setBorder(null);
  scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
  // we're adding to a box layout, so to prevent the component from grabbing extra space, set the
  // max height.
  // allow room for a dice and a scrollbar
  scroll.setMinimumSize(
      new Dimension(scroll.getMinimumSize().width, DiceImageFactory.DIE_HEIGHT + 17));
  scroll.setMaximumSize(
      new Dimension(scroll.getMaximumSize().width, DiceImageFactory.DIE_HEIGHT + 17));
  scroll.setPreferredSize(
      new Dimension(scroll.getPreferredSize().width, DiceImageFactory.DIE_HEIGHT + 17));
  add(scroll);
  add(Box.createVerticalStrut(8));
  add(labelPanel);
  add(Box.createVerticalStrut(8));
  add(diceButtonPanel);
  updateDiceCount();
}
 
Example 19
Source File: Constraints.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
public Constraints(BioModel bioModel, ModelEditor modelEditor) {
	super(new BorderLayout());
	this.bioModel = bioModel;
	this.modelEditor = modelEditor;
	Model model = bioModel.getSBMLDocument().getModel();
	addConstraint = new JButton("Add Constraint");
	removeConstraint = new JButton("Remove Constraint");
	editConstraint = new JButton("Edit Constraint");
	constraints = new JList();
	ListOf<Constraint> listOfConstraints = model.getListOfConstraints();
	String[] cons = new String[model.getConstraintCount()];
	for (int i = 0; i < model.getConstraintCount(); i++) {
		Constraint constraint = listOfConstraints.get(i);
		if (!constraint.isSetMetaId()) {
			String constraintId = "c0";
			int cn = 0;
			while (bioModel.isSIdInUse(constraintId)) {
				cn++;
				constraintId = "c" + cn;
			}
			SBMLutilities.setMetaId(constraint, constraintId);
		}
		cons[i] = constraint.getMetaId();
		cons[i] += SBMLutilities.getDimensionString(constraint);
	}
	JPanel addRem = new JPanel();
	addRem.add(addConstraint);
	addRem.add(removeConstraint);
	addRem.add(editConstraint);
	addConstraint.addActionListener(this);
	removeConstraint.addActionListener(this);
	editConstraint.addActionListener(this);
	JLabel panelLabel = new JLabel("List of Constraints:");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(constraints);
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(cons);
	constraints.setListData(cons);
	constraints.setSelectedIndex(0);
	constraints.addMouseListener(this);
	this.add(panelLabel, "North");
	this.add(scroll, "Center");
	this.add(addRem, "South");
}
 
Example 20
Source File: OnePageAnalysisWindow.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * @return Links components.
 */
private Component createLinksComponents() {
  JPanel panel = new JPanel(new GridBagLayout());

  listLinks = new JList<Page>(modelLinks);

  // Initialize constraints
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(0, 0, 0, 0);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 1;
  constraints.weighty = 0;

  // Button toolbar
  JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL);
  toolbar.setFloatable(false);
  toolbar.setBorderPainted(false);
  ActionFullAnalysis.addButton(
      getParentComponent(), toolbar, getWikipedia(), listLinks, knownPages, true, true);
  ActionDisambiguationAnalysis.addButton(
      getParentComponent(), toolbar, getWikipedia(), listLinks, true, true);
  buttonRemoveLinks = Utilities.createJButton(
      "wpc-remove-link.png", EnumImageSize.NORMAL,
      GT._T("Remove all links"), false, null);
  buttonRemoveLinks.addActionListener(EventHandler.create(
      ActionListener.class, this, "actionRemoveAllLinks"));
  toolbar.add(buttonRemoveLinks);
  buttonWatchLink = ActionWatchPage.createButton(
      getParentComponent(), getWikipedia(), listLinks, true, true);
  toolbar.add(buttonWatchLink);
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.weightx = 1;
  panel.add(toolbar, constraints);
  constraints.gridy++;

  // Links
  constraints.fill = GridBagConstraints.BOTH;
  constraints.weighty = 1;
  listCellRenderer = new PageListCellRenderer();
  listCellRenderer.showCountOccurrence(true);
  listCellRenderer.showDisambiguation(true);
  listCellRenderer.showMissing(true);
  listCellRenderer.showRedirect(true);
  listLinks.setCellRenderer(listCellRenderer);
  popupListenerLinks = new AnalysisPageListPopupListener(
      getWikipedia(), getTextContents(), listLinks, this);
  listLinks.addMouseListener(popupListenerLinks);
  listLinks.addMouseListener(new PageListAnalyzeListener(getWikipedia(), null));
  listLinks.addListSelectionListener(new AnalysisListSelectionListener());
  JScrollPane scrollLinks = new JScrollPane(listLinks);
  scrollLinks.setMinimumSize(new Dimension(100, 100));
  scrollLinks.setPreferredSize(new Dimension(200, 500));
  scrollLinks.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  panel.add(scrollLinks, constraints);
  constraints.gridy++;

  return panel;
}