Skip to content

Instantly share code, notes, and snippets.

@apocalyptech
Created August 31, 2023 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apocalyptech/3585566f4079c53a18b01262689b892e to your computer and use it in GitHub Desktop.
Save apocalyptech/3585566f4079c53a18b01262689b892e to your computer and use it in GitHub Desktop.
import java.awt.EventQueue;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
public class test
{
public static void main(String[] args)
{
EventQueue.invokeLater(() -> buildAndShowGui());
}
private static void buildAndShowGui()
{
// Set up the frame
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setTitle("text");
// Main panel
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 0;
gc.weightx = 500;
gc.weighty = 500;
gc.fill = GridBagConstraints.BOTH;
JScrollPane scrollPane = new JScrollPane();
JTextPane textPane = new JTextPane();
scrollPane.setViewportView(textPane);
panel.add(scrollPane, gc);
textPane.setText(
"asoidfaosdijoaisdjodjfodsjfoiadjsfoijdofjdosijfoasdjfoajdsfoijasdofjdoifjaosdfjaodsijfoij\n"
+ "sdandfiunadsiufnasidufidusn\n"
+ "asdfnasdoufn34ejnafdiunadsifunadsiufniuaenifneaiufneiunfiueanfiuaeniuenfe\n"
+ "asdfuioasdfoijasdoifj\n"
+ "adsofijasdofijadosifjoijefmaneoinfaeiounfiuenfiunefinaefoenawofineafoienafoenafiunaeiufneaiufnea\n"
);
// Add to frame and display
frame.add(panel);
frame.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment