Note that there are some explanatory texts on larger screens.

plurals
  1. POJPanel&JScrollPane and error rendering
    primarykey
    data
    text
    <p>With my English is bad, but I'll try to explain. I have a question. At JPanel I draw the line .... they should go beyond the region of the object JPanel and JScrollPane theoretically should show the entire panel, but it is not updated and does not display all the lines that were released for the scope of the panel.</p> <pre><code>import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.Console; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; public class TestFrame extends JFrame { static int speed = 10; static int floor = 22; public static void createGUI() { JFrame frame = new JFrame("Test frame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Font font = new Font("Verdana", Font.PLAIN, 25); JPanel butPanel = new JPanel(); JButton biginButton = new JButton("start"); biginButton.setFont(font); biginButton.setFocusable(false); butPanel.add(biginButton); JButton remButton = new JButton("repaint"); remButton.setFont(font); remButton.setFocusable(false); butPanel.add(remButton); final JPanel labPanel = new JPanel(); final JScrollPane scrollPane = new JScrollPane(labPanel); labPanel.setLayout(new BoxLayout(labPanel, BoxLayout.Y_AXIS)); biginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //labPanel.getGraphics().drawString("Ololo", 50, 50); int floH = 100; for(int i = 0; i &lt; floor; i++){ labPanel.getGraphics().drawLine(0, i*floH, 300, i*floH); labPanel.getGraphics().setColor(Color.RED); scrollPane.revalidate(); } } }); remButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { labPanel.repaint(); scrollPane.revalidate(); } }); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(butPanel, BorderLayout.NORTH); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setPreferredSize(new Dimension(screenSize.width-10, screenSize.height-10)); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame.setDefaultLookAndFeelDecorated(true); createGUI(); } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload