本文整理了Java中javax.swing.JScrollPane.getViewport()
方法的一些代码示例,展示了JScrollPane.getViewport()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JScrollPane.getViewport()
方法的具体详情如下:
包路径:javax.swing.JScrollPane
类名称:JScrollPane
方法名:getViewport
暂无
代码示例来源:origin: stackoverflow.com
JScrollPane pane = new JScrollPane ();
pane.getViewport ().setView ( myComponent );
代码示例来源:origin: org.codehaus.groovy/groovy
private void jbInit(Reader reader) throws Exception {
final Border border = BorderFactory.createEmptyBorder();
jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
tokenPane.setEditable(false);
tokenPane.setText("");
scriptPane.setFont(new java.awt.Font("DialogInput", 0, 12));
scriptPane.setEditable(false);
scriptPane.setMargin(new Insets(5, 5, 5, 5));
scriptPane.setText("");
jScrollPane1.setBorder(border);
jScrollPane2.setBorder(border);
jSplitPane1.setMinimumSize(new Dimension(800, 600));
mainPanel.add(jSplitPane1, BorderLayout.CENTER);
if (reader == null) {
mainPanel.add(jbutton, BorderLayout.NORTH);
}
this.getContentPane().add(mainPanel);
jSplitPane1.add(jScrollPane1, JSplitPane.LEFT);
jScrollPane1.getViewport().add(tokenPane, null);
jSplitPane1.add(jScrollPane2, JSplitPane.RIGHT);
jScrollPane2.getViewport().add(scriptPane, null);
jScrollPane1.setColumnHeaderView(new JLabel(" Token Stream:"));
jScrollPane2.setColumnHeaderView(new JLabel(" Input Script:"));
jSplitPane1.setResizeWeight(0.5);
}
代码示例来源:origin: plantuml/plantuml
image = ImageIO.read(new File(png.getAbsolutePath()));
if (sizeMode == SizeMode.ZOOM_FIT) {
final Dimension imageDim = new Dimension(image.getWidth(), image.getHeight());
final Dimension newImgDim = ImageHelper
.getScaledDimension(imageDim, scrollPane.getViewport().getSize());
image = ImageHelper.getScaledInstance(image, newImgDim, getHints(), true);
} else if (sizeMode == SizeMode.WIDTH_FIT) {
final Dimension imageDim = new Dimension(image.getWidth(), image.getHeight());
final Dimension newImgDim = ImageHelper.getScaledDimensionWidthFit(imageDim, scrollPane.getViewport()
.getSize());
image = ImageHelper.getScaledInstance(image, newImgDim, getHints(), false);
} else if (zoomFactor != 0) {
final Dimension imageDim = new Dimension(image.getWidth(), image.getHeight());
final Dimension newImgDim = ImageHelper.getScaledDimension(imageDim, getZoom());
image = ImageHelper.getScaledInstance(image, newImgDim, getHints(), false);
代码示例来源:origin: magefree/mage
public void initComponents() {
jPanel = new JPanel();
jScrollPane1 = new JScrollPane(jPanel);
jScrollPane1.getViewport().setBackground(new Color(0, 0, 0, 0));
jPanel.setLayout(new GridBagLayout()); // centers mage book
jPanel.setBackground(new Color(0, 0, 0, 0));
mageBook = new MageBook(bigCard);
jPanel.add(mageBook);
setLayout(new java.awt.BorderLayout());
add(jScrollPane1, java.awt.BorderLayout.CENTER);
}
代码示例来源:origin: us.ihmc/IHMCJavaToolkit
public GUIMessagePanel(String name)
{
this.name = name;
this.setLayout(new BorderLayout());
textArea = new JTextArea();
textArea.setLineWrap(true);
// textArea.setColumns(WIDTH);
// textArea.setRows(44);
textArea.setSelectedTextColor(Color.WHITE);
jScrollPane = new JScrollPane();
jScrollPane.getViewport().add(textArea);
textArea.setEditable(false);
textArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
jScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
this.add(jScrollPane, BorderLayout.CENTER);
}
代码示例来源:origin: stackoverflow.com
progressTextArea = new JTextPane();
JScrollPane scroller = new JScrollPane()
{
public Dimension getPreferredSize()
{
return new Dimension(300, 100);
}
public float getAlignmentX()
{
return LEFT_ALIGNMENT;
}
};
scroller.getViewport().add(progressTextArea);
代码示例来源:origin: stackoverflow.com
JScrollPane s = new JScrollPane();
s.getViewport().add(m_tree);
getContentPane().add(s, BorderLayout.CENTER);
代码示例来源:origin: magefree/mage
this.setLayout(new GridLayout(0, 1));
this.setOpaque(false);
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayout(0, 1));
mainPanel.setOpaque(false);
dialogTextArea.setOpaque(false);
textAreaScrollPane = new JScrollPane(dialogTextArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
textAreaScrollPane.setOpaque(false);
textAreaScrollPane.setBackground(new Color(0, 0, 0, 0));
textAreaScrollPane.getViewport().setOpaque(false);
textAreaScrollPane.setBorder(null);
textAreaScrollPane.setViewportBorder(null);
mainPanel.add(textAreaScrollPane);
buttonContainer = new JPanel();
buttonContainer.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
buttonContainer.setOpaque(false);
mainPanel.add(buttonContainer);
buttonGrid = new JPanel(); // buttons layout auto changes by autoSizeButtonsAndFeedbackState
buttonGrid.setOpaque(false);
buttonContainer.add(buttonGrid);
代码示例来源:origin: org.appdapter/org.appdapter.lib.gui
public static JPanel createTitledPanel(JLabel label, char mnemonic, JComponent component) {
JPanel panel = new JPanel(new BorderLayout(2, 2));
panel.add(label, BorderLayout.BEFORE_FIRST_LINE);
label.setDisplayedMnemonic(mnemonic);
if (component instanceof JScrollPane) {
label.setLabelFor(((JScrollPane) component).getViewport().getView());
} else {
label.setLabelFor(component);
}
panel.add(component, BorderLayout.CENTER);
return panel;
}
代码示例来源:origin: org.openspml/openspml
/**
* Add a damn component to a scroll pane, this is always what
* you want, but its so obscure I never remember.
*/
public static void add(JScrollPane scroll, JComponent comp) {
scroll.getViewport().add(comp, null);
}
代码示例来源:origin: magefree/mage
/** Creates new form CombatDialog */
public CombatDialog() {
JPanel contentPane = new JPanel() {
private static final long serialVersionUID = -8283955788355547309L;
public void paintComponent(Graphics g) {
g.setColor(new Color(50, 50, 50, 100));
g.fillRect(0, 0, getWidth(), getHeight());
}
};
setContentPane(contentPane);
initComponents();
this.setModal(false);
combatArea.setOpaque(false);
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
getRootPane().setOpaque(false);
//setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
}
代码示例来源:origin: nl.cloudfarming.client/logging
public LogPanel() {
setLayout(new BorderLayout());
textPane.setEnabled(true); // false to disable user-input
scrollPane.getViewport().add(textPane);
add(scrollPane);
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel(new BorderLayout());
final JPanel buttons = new JPanel();
final JScrollPane pane = new JScrollPane(buttons);
pane.getViewport().addChangeListener(new ChangeListener() {
panel.add(pane);
frame.setContentPane(panel);
frame.setSize(300, 200);
for (int i = 0; i < 10; i++) {
Thread.sleep(800);
buttons.add(new JButton("Hello " + i));
buttons.revalidate();
代码示例来源:origin: us.ihmc/ihmc-java-toolkit
public GUIMessagePanel(String name)
{
this.name = name;
this.setLayout(new BorderLayout());
textArea = new JTextArea();
textArea.setLineWrap(true);
// textArea.setColumns(WIDTH);
// textArea.setRows(44);
textArea.setSelectedTextColor(Color.WHITE);
jScrollPane = new JScrollPane();
jScrollPane.getViewport().add(textArea);
textArea.setEditable(false);
textArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
jScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
this.add(jScrollPane, BorderLayout.CENTER);
}
代码示例来源:origin: net.sf.ingenias/editor
/**
* Constructs a TableCellEditor that uses a text area.
*
* @param x a JTextArea object ...
*/
public TextAreaCellEditor(JTextArea textArea) {
area = textArea;
area.setLineWrap (true);
area.setWrapStyleWord (true);
pane = new JScrollPane (area,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
pane.getViewport().setPreferredSize (new Dimension (width, height));
}
代码示例来源:origin: Nepxion/Discovery
public void displayAbilityChanged(HierarchyEvent e) {
// Ugly code
TGraphControlBar graphControlBar = (TGraphControlBar) graph.getControlBarInternalFrame().getContent();
JBasicToggleButton toggleButton = (JBasicToggleButton) graphControlBar.getViewToolBar().getViewOutlook().getComponent(10);
toggleButton.setSelected(true);
TGraphManager.layout(graph);
TLayouterBar layouterBar = (TLayouterBar) graph.getLayoutInternalFrame().getContent();
JScrollPane scrollPane = (JScrollPane) layouterBar.getTabAt(layouterBar.getSelectedTitle());
JPanel panel = (JPanel) scrollPane.getViewport().getView();
TLayoutPanel layoutPanel = (TLayoutPanel) panel.getComponent(0);
JPanel childPanel1 = (JPanel) layoutPanel.getComponent(0);
JBasicComboBox typeComboBox = (JBasicComboBox) childPanel1.getComponent(1);
typeComboBox.setSelectedIndex(2);
JPanel childPanel2 = (JPanel) layoutPanel.getComponent(1);
JSlider yOffsetSlider = (JSlider) childPanel2.getComponent(11);
yOffsetSlider.setValue(0);
JSlider xGapSlider = (JSlider) childPanel2.getComponent(13);
xGapSlider.setValue(200);
JSlider yGapSlider = (JSlider) childPanel2.getComponent(15);
yGapSlider.setValue(150);
JPanel childPanel3 = (JPanel) layoutPanel.getComponent(2);
JBasicButton runButton = (JBasicButton) childPanel3.getComponent(1);
layoutActionListener = runButton.getActionListeners()[0];
graph.getLayoutInternalFrame().setLocation(3000, 3000);
// graph.adjustComponentPosition(graph.getLayoutInternalFrame());
RouterTopology.this.setPreferredSize(new Dimension(RouterTopology.this.getPreferredSize().width - 82, 900));
removeHierarchyListener(this);
}
});
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
private void jbInit() throws Exception{
border1 = BorderFactory.createEmptyBorder();
border2 = BorderFactory.createEmptyBorder();
jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
tokenPane.setEditable(false);
tokenPane.setText("");
scriptPane.setFont(new java.awt.Font("DialogInput", 0, 12));
scriptPane.setEditable(false);
scriptPane.setMargin(new Insets(5, 5, 5, 5));
scriptPane.setText("");
jScrollPane1.setBorder(border1);
jScrollPane2.setBorder(border1);
jSplitPane1.setMinimumSize(new Dimension(800,600));
mainPanel.add(jSplitPane1, BorderLayout.CENTER);
mainPanel.add(jbutton,BorderLayout.NORTH);
this.getContentPane().add(mainPanel);
jSplitPane1.add(jScrollPane1, JSplitPane.LEFT);
jScrollPane1.getViewport().add(tokenPane, null);
jSplitPane1.add(jScrollPane2, JSplitPane.RIGHT);
jScrollPane2.getViewport().add(scriptPane, null);
jScrollPane1.setColumnHeaderView(new JLabel(" Token Stream:"));
jScrollPane2.setColumnHeaderView(new JLabel(" Input Script:"));
jSplitPane1.setResizeWeight(0.5);
}
代码示例来源:origin: stackoverflow.com
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
public class TestWidth {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextPane newsTextPane = new JTextPane();
newsTextPane.setEditable(false);
JScrollPane scrollPane = new JScrollPane(newsTextPane);
frame.add(scrollPane);
frame.setSize(300, 250);
frame.setVisible(true);
System.out.println("Height : " + scrollPane.getViewport().getSize().height + "\nWidth :" + scrollPane.getViewport().getSize().width);
}
}
代码示例来源:origin: stackoverflow.com
JScrollPane scrollpane = new JScrollPane();
String categories[] = { "1. Problem One Problem One Problem One Problem One Problem One Problem One Problem One Problem One Problem One", "2. Problem Two", "3. Extended Family", "4. Extended Family", "5. Extended Family"
,"6. Extended Family","7. Extended Family","8. Extended Family","9. Extended Family"};
JList list = new JList(categories);
scrollpane = new JScrollPane(list);
JPanel panel = new JPanel();
panel.add(scrollpane);
scrollpane.getViewport().add(list);
JOptionPane.showMessageDialog(null, scrollpane, "Error List",
JOptionPane.PLAIN_MESSAGE);
代码示例来源:origin: pmd/pmd
private JComponent createXPathResultPanel() {
xpathResults.addElement("No XPath results yet, run an XPath Query first.");
xpathResultList.setBorder(BorderFactory.createLineBorder(Color.black));
xpathResultList.setFixedCellWidth(300);
xpathResultList.setCellRenderer(new ASTListCellRenderer());
xpathResultList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
xpathResultList.getSelectionModel().addListSelectionListener(new ASTSelectionListener());
JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().setView(xpathResultList);
return scrollPane;
}
内容来源于网络,如有侵权,请联系作者删除!