Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Beginner] Java/GUI help

Featured Replies

Hey :) I am trying to learn how to make a GUI from expLvl's Tutorial :)

I can't get the JButton to show when i run the main method, why is this?

I am fairly new to java, and am in process of learning it. So sry, if it is apparent haha. Any help/tips appreciated :D

Thanks!

package gui;

import data.TreeInfo;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class GUIDialog extends JDialog {

    private final JDialog mainDialog;
    
    private final JPanel mainPanel;

    private final JPanel selectTreeTypePanel;

    private final JLabel treeTypeLabel;

    private final JButton startButton;

    private final JComboBox<TreeInfo> treeTypeComboBox;

    public GUIDialog() {

        mainDialog = new JDialog();

        mainDialog.setTitle("Tasks Woodcutter");
        mainDialog.setModal(true);
        mainDialog.setModalityType(JDialog.ModalityType.APPLICATION_MODAL);

        mainPanel = new JPanel();
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
    
        mainPanel.setBorder(new EmptyBorder(20, 20, 20, 20));


        selectTreeTypePanel = new JPanel();
        selectTreeTypePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
  
        treeTypeLabel = new JLabel("Select Tree : ");
        selectTreeTypePanel.add(treeTypeLabel);

        treeTypeComboBox = new JComboBox<>(TreeInfo.values());
        selectTreeTypePanel.add(treeTypeComboBox);

        mainPanel.add(selectTreeTypePanel);

        startButton = new JButton("Start");
        startButton.addActionListener(e -> {
            started = true;
            close();
        });

        mainPanel.add(startButton);


        mainDialog.getContentPane().add(mainPanel);
        mainDialog.getContentPane().add(selectTreeTypePanel);

        mainDialog.pack();
        mainDialog.setLocationRelativeTo(null);
    }

    public void open() {

        mainDialog.setVisible(true);
    }

    public void close() {

        mainDialog.setVisible(false);
        mainDialog.dispose();
    }

    public static void main(String... args) {

        new GUIDialog().open();
    }
}

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.