Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package proba;
- import org.eclipse.swt.widgets.Composite;
- import org.eclipse.swt.widgets.Display;
- import org.eclipse.swt.widgets.Shell;
- import org.eclipse.swt.custom.ScrolledComposite;
- import java.awt.Component;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import javax.swing.*;
- import org.eclipse.swt.SWT;
- import org.eclipse.swt.widgets.Label;
- import org.eclipse.wb.swt.SWTResourceManager;
- import org.eclipse.swt.widgets.List;
- import org.eclipse.swt.layout.GridLayout;
- import org.eclipse.swt.layout.GridData;
- public class pregPod {
- protected Shell shell;
- /**
- * Launch the application.
- * @param args
- */
- public static void noviProzPP() {
- try {
- pregPod window = new pregPod();
- window.open();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * Open the window.
- */
- public void open() {
- Display display = Display.getDefault();
- createContents();
- shell.open();
- shell.layout();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
- /**
- * Create contents of the window.
- * @wbp.parser.entryPoint
- */
- protected void createContents() {
- shell = new Shell();
- shell.setSize(450, 300);
- shell.setText("SWT Application");
- shell.setLayout(null);
- ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- scrolledComposite.setBounds(0, 10, 422, 238);
- scrolledComposite.setExpandHorizontal(true);
- scrolledComposite.setExpandVertical(true);
- Composite composite = new Composite(scrolledComposite, SWT.NONE);
- composite.setLayout(new GridLayout(1, false));
- Label lblNewLabel = new Label(composite, SWT.NONE);
- GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
- gd_lblNewLabel.heightHint = 229;
- gd_lblNewLabel.widthHint = 418;
- lblNewLabel.setLayoutData(gd_lblNewLabel);
- scrolledComposite.setContent(composite);
- scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- try {
- String sveskupa = "";
- String url = "jdbc:mysql://localhost:3306/database?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CET";
- Connection conn = DriverManager.getConnection(url,"root","");
- Statement st = conn.createStatement();
- ResultSet brRedaka = st.executeQuery("SELECT * FROM `javni_pod`");
- while(brRedaka.next()) {
- String put = brRedaka.getString("path");
- String ajdi = brRedaka.getString("ID");
- sveskupa = sveskupa + ajdi + " " + put + "\n";
- lblNewLabel.setText(sveskupa + "\n");
- System.out.println(ajdi + " " + put);
- }
- conn.close();
- } catch (Exception e) {
- System.err.println("Got an exception! ");
- System.err.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement