How can I get this textfield and dropdown menu working to do what I want?How can I concatenate two arrays in Java?How does the Java 'for each' loop work?How can I generate an MD5 hash?How can I initialise a static Map?How can I create an executable JAR with dependencies using Maven?How to get an enum value from a string value in Java?How can I convert a stack trace to a string?Getting the Current Working Directory in JavaHow to make Twitter Bootstrap menu dropdown on hover rather than clickCan I get a JTextField above an JEditorPane but below a JTabbedPane?

Did depressed people far more accurately estimate how many monsters they killed in a video game?

Why is the Cauchy Distribution is so useful?

Classical Greek for 'You came home to our hearts with your shield'?

I make billions (#6)

Is it ok for parents to kiss and romance with each other while their 2- to 8-year-old child watches?

What are the effects of abstaining from eating a certain flavor?

Object's height not a multiple of layer height

How to convert diagonal matrix to rectangular matrix

What happens to unproductive professors?

Is it okay to roll multiple attacks that all have advantage in one cluster?

A horrible Stockfish chess engine evaluation

Compressed gas thruster for an orbital launch vehicle?

Can a landlord force all residents to use the landlord's in-house debit card accounts?

Is there a strong legal guarantee that the U.S. can give to another country that it won't attack them?

Found and corrected a mistake on someone's else paper -- praxis?

Four ships at the ocean with the same distance

How should I ask for a "pint" in countries that use metric?

How do I explain that I don't want to maintain old projects?

Do we know SL(2,C) subgroups (not only finite ones)?

How many tone holes are there actually in different orchestral woodwind instruments?

Hail hit my roof. Do I need to replace it?

What's it called when the bad guy gets eaten?

Conditions for Roots of a quadratic equation at infinity

Bold and Colored Image Caption



How can I get this textfield and dropdown menu working to do what I want?


How can I concatenate two arrays in Java?How does the Java 'for each' loop work?How can I generate an MD5 hash?How can I initialise a static Map?How can I create an executable JAR with dependencies using Maven?How to get an enum value from a string value in Java?How can I convert a stack trace to a string?Getting the Current Working Directory in JavaHow to make Twitter Bootstrap menu dropdown on hover rather than clickCan I get a JTextField above an JEditorPane but below a JTabbedPane?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I don't expect anyone to do the work for me, but I'm having trouble finding the exact answers to my questions researching on my own. I'm trying to have a text field where the user must input an integer between 1 and 3 and then a drop down menu to pick a flavor (would like the drop down selection to either work as the way to submit or just get the menu itself to stay selected). After submission I want a window to pop up with a painted ice cream cone that changes color based on the flavor and the number of scoops to also be accurate to the user's input.



I have been trying to work with JOptionPanel as I thought maybe that in combination with some sort of ActionListener set up would do the trick for me, but I can't seem to find the how-to or advice I need to get the job done that way.



public void createGUI()

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container window = getContentPane();
window.setLayout(new BorderLayout());

GridLayout mainLayout = new GridLayout(2,1);
GridLayout topLayout = new GridLayout(1,2);
GridLayout menuLayout = new GridLayout(6,2);

JLabel storeFront = new JLabel("Ice Cream Shop");
JLabel orderHere = new JLabel("Order Here");

ImageIcon storeImage = new ImageIcon("storefront.jpeg");
JLabel store = new JLabel(storeImage);

ImageIcon flavorsImage = new ImageIcon("flavors.jpeg");
JLabel flavors = new JLabel(flavorsImage);

JTextField numberScoops = new JTextField(5);


JMenuBar flavorMenu = new JMenuBar();
JMenu flavorIceCream = new JMenu();

JMenuItem chocolate = new JMenuItem("Chocolate");
JMenuItem vanilla = new JMenuItem("Vanilla");
JMenuItem strawberry = new JMenuItem("Strawberry");
flavorIceCream.add(chocolate);
flavorIceCream.add(vanilla);
flavorIceCream.add(strawberry);

flavorMenu.add(flavorIceCream);

JPanel iceCreamShop = new JPanel();
iceCreamShop.setBackground(Color.gray);
iceCreamShop.add(store, BorderLayout.CENTER);

JPanel iceCreamMenu = new JPanel();
iceCreamMenu.setBackground(Color.gray);
JPanel menuPanel = new JPanel();
menuPanel.setBackground(Color.gray);
menuPanel.setLayout(menuLayout);

menuPanel.add(new JLabel("Chocolate"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Vanilla"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Strawberry"));
menuPanel.add(new JLabel("$2.25/scoop"));
menuPanel.add(new JLabel("How Many Scoops?"));
menuPanel.add(numberScoops);
menuPanel.add(new JLabel("what flavor?"));
menuPanel.add(flavorMenu);
menuPanel.add(new JButton("clear"));
menuPanel.add(new JButton("submit"));
iceCreamMenu.add(menuPanel);

JPanel iceCreamOrder = new JPanel();
iceCreamOrder.setLayout(topLayout);
iceCreamOrder.add(iceCreamShop);
iceCreamOrder.add(iceCreamMenu);

JPanel mainPanel = new JPanel();
mainPanel.setLayout (mainLayout);
mainPanel.setBackground(Color.gray);
mainPanel.add(iceCreamOrder);
mainPanel.add(flavors, BorderLayout.CENTER);

window.add(mainPanel, BorderLayout.CENTER);











share|improve this question






















  • How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

    – MadProgrammer
    Mar 25 at 23:20











  • @MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

    – Patrick Alan Sean Fadden
    Mar 30 at 12:45

















1















I don't expect anyone to do the work for me, but I'm having trouble finding the exact answers to my questions researching on my own. I'm trying to have a text field where the user must input an integer between 1 and 3 and then a drop down menu to pick a flavor (would like the drop down selection to either work as the way to submit or just get the menu itself to stay selected). After submission I want a window to pop up with a painted ice cream cone that changes color based on the flavor and the number of scoops to also be accurate to the user's input.



I have been trying to work with JOptionPanel as I thought maybe that in combination with some sort of ActionListener set up would do the trick for me, but I can't seem to find the how-to or advice I need to get the job done that way.



public void createGUI()

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container window = getContentPane();
window.setLayout(new BorderLayout());

GridLayout mainLayout = new GridLayout(2,1);
GridLayout topLayout = new GridLayout(1,2);
GridLayout menuLayout = new GridLayout(6,2);

JLabel storeFront = new JLabel("Ice Cream Shop");
JLabel orderHere = new JLabel("Order Here");

ImageIcon storeImage = new ImageIcon("storefront.jpeg");
JLabel store = new JLabel(storeImage);

ImageIcon flavorsImage = new ImageIcon("flavors.jpeg");
JLabel flavors = new JLabel(flavorsImage);

JTextField numberScoops = new JTextField(5);


JMenuBar flavorMenu = new JMenuBar();
JMenu flavorIceCream = new JMenu();

JMenuItem chocolate = new JMenuItem("Chocolate");
JMenuItem vanilla = new JMenuItem("Vanilla");
JMenuItem strawberry = new JMenuItem("Strawberry");
flavorIceCream.add(chocolate);
flavorIceCream.add(vanilla);
flavorIceCream.add(strawberry);

flavorMenu.add(flavorIceCream);

JPanel iceCreamShop = new JPanel();
iceCreamShop.setBackground(Color.gray);
iceCreamShop.add(store, BorderLayout.CENTER);

JPanel iceCreamMenu = new JPanel();
iceCreamMenu.setBackground(Color.gray);
JPanel menuPanel = new JPanel();
menuPanel.setBackground(Color.gray);
menuPanel.setLayout(menuLayout);

menuPanel.add(new JLabel("Chocolate"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Vanilla"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Strawberry"));
menuPanel.add(new JLabel("$2.25/scoop"));
menuPanel.add(new JLabel("How Many Scoops?"));
menuPanel.add(numberScoops);
menuPanel.add(new JLabel("what flavor?"));
menuPanel.add(flavorMenu);
menuPanel.add(new JButton("clear"));
menuPanel.add(new JButton("submit"));
iceCreamMenu.add(menuPanel);

JPanel iceCreamOrder = new JPanel();
iceCreamOrder.setLayout(topLayout);
iceCreamOrder.add(iceCreamShop);
iceCreamOrder.add(iceCreamMenu);

JPanel mainPanel = new JPanel();
mainPanel.setLayout (mainLayout);
mainPanel.setBackground(Color.gray);
mainPanel.add(iceCreamOrder);
mainPanel.add(flavors, BorderLayout.CENTER);

window.add(mainPanel, BorderLayout.CENTER);











share|improve this question






















  • How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

    – MadProgrammer
    Mar 25 at 23:20











  • @MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

    – Patrick Alan Sean Fadden
    Mar 30 at 12:45













1












1








1








I don't expect anyone to do the work for me, but I'm having trouble finding the exact answers to my questions researching on my own. I'm trying to have a text field where the user must input an integer between 1 and 3 and then a drop down menu to pick a flavor (would like the drop down selection to either work as the way to submit or just get the menu itself to stay selected). After submission I want a window to pop up with a painted ice cream cone that changes color based on the flavor and the number of scoops to also be accurate to the user's input.



I have been trying to work with JOptionPanel as I thought maybe that in combination with some sort of ActionListener set up would do the trick for me, but I can't seem to find the how-to or advice I need to get the job done that way.



public void createGUI()

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container window = getContentPane();
window.setLayout(new BorderLayout());

GridLayout mainLayout = new GridLayout(2,1);
GridLayout topLayout = new GridLayout(1,2);
GridLayout menuLayout = new GridLayout(6,2);

JLabel storeFront = new JLabel("Ice Cream Shop");
JLabel orderHere = new JLabel("Order Here");

ImageIcon storeImage = new ImageIcon("storefront.jpeg");
JLabel store = new JLabel(storeImage);

ImageIcon flavorsImage = new ImageIcon("flavors.jpeg");
JLabel flavors = new JLabel(flavorsImage);

JTextField numberScoops = new JTextField(5);


JMenuBar flavorMenu = new JMenuBar();
JMenu flavorIceCream = new JMenu();

JMenuItem chocolate = new JMenuItem("Chocolate");
JMenuItem vanilla = new JMenuItem("Vanilla");
JMenuItem strawberry = new JMenuItem("Strawberry");
flavorIceCream.add(chocolate);
flavorIceCream.add(vanilla);
flavorIceCream.add(strawberry);

flavorMenu.add(flavorIceCream);

JPanel iceCreamShop = new JPanel();
iceCreamShop.setBackground(Color.gray);
iceCreamShop.add(store, BorderLayout.CENTER);

JPanel iceCreamMenu = new JPanel();
iceCreamMenu.setBackground(Color.gray);
JPanel menuPanel = new JPanel();
menuPanel.setBackground(Color.gray);
menuPanel.setLayout(menuLayout);

menuPanel.add(new JLabel("Chocolate"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Vanilla"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Strawberry"));
menuPanel.add(new JLabel("$2.25/scoop"));
menuPanel.add(new JLabel("How Many Scoops?"));
menuPanel.add(numberScoops);
menuPanel.add(new JLabel("what flavor?"));
menuPanel.add(flavorMenu);
menuPanel.add(new JButton("clear"));
menuPanel.add(new JButton("submit"));
iceCreamMenu.add(menuPanel);

JPanel iceCreamOrder = new JPanel();
iceCreamOrder.setLayout(topLayout);
iceCreamOrder.add(iceCreamShop);
iceCreamOrder.add(iceCreamMenu);

JPanel mainPanel = new JPanel();
mainPanel.setLayout (mainLayout);
mainPanel.setBackground(Color.gray);
mainPanel.add(iceCreamOrder);
mainPanel.add(flavors, BorderLayout.CENTER);

window.add(mainPanel, BorderLayout.CENTER);











share|improve this question














I don't expect anyone to do the work for me, but I'm having trouble finding the exact answers to my questions researching on my own. I'm trying to have a text field where the user must input an integer between 1 and 3 and then a drop down menu to pick a flavor (would like the drop down selection to either work as the way to submit or just get the menu itself to stay selected). After submission I want a window to pop up with a painted ice cream cone that changes color based on the flavor and the number of scoops to also be accurate to the user's input.



I have been trying to work with JOptionPanel as I thought maybe that in combination with some sort of ActionListener set up would do the trick for me, but I can't seem to find the how-to or advice I need to get the job done that way.



public void createGUI()

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container window = getContentPane();
window.setLayout(new BorderLayout());

GridLayout mainLayout = new GridLayout(2,1);
GridLayout topLayout = new GridLayout(1,2);
GridLayout menuLayout = new GridLayout(6,2);

JLabel storeFront = new JLabel("Ice Cream Shop");
JLabel orderHere = new JLabel("Order Here");

ImageIcon storeImage = new ImageIcon("storefront.jpeg");
JLabel store = new JLabel(storeImage);

ImageIcon flavorsImage = new ImageIcon("flavors.jpeg");
JLabel flavors = new JLabel(flavorsImage);

JTextField numberScoops = new JTextField(5);


JMenuBar flavorMenu = new JMenuBar();
JMenu flavorIceCream = new JMenu();

JMenuItem chocolate = new JMenuItem("Chocolate");
JMenuItem vanilla = new JMenuItem("Vanilla");
JMenuItem strawberry = new JMenuItem("Strawberry");
flavorIceCream.add(chocolate);
flavorIceCream.add(vanilla);
flavorIceCream.add(strawberry);

flavorMenu.add(flavorIceCream);

JPanel iceCreamShop = new JPanel();
iceCreamShop.setBackground(Color.gray);
iceCreamShop.add(store, BorderLayout.CENTER);

JPanel iceCreamMenu = new JPanel();
iceCreamMenu.setBackground(Color.gray);
JPanel menuPanel = new JPanel();
menuPanel.setBackground(Color.gray);
menuPanel.setLayout(menuLayout);

menuPanel.add(new JLabel("Chocolate"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Vanilla"));
menuPanel.add(new JLabel("$2.00/scoop"));
menuPanel.add(new JLabel("Strawberry"));
menuPanel.add(new JLabel("$2.25/scoop"));
menuPanel.add(new JLabel("How Many Scoops?"));
menuPanel.add(numberScoops);
menuPanel.add(new JLabel("what flavor?"));
menuPanel.add(flavorMenu);
menuPanel.add(new JButton("clear"));
menuPanel.add(new JButton("submit"));
iceCreamMenu.add(menuPanel);

JPanel iceCreamOrder = new JPanel();
iceCreamOrder.setLayout(topLayout);
iceCreamOrder.add(iceCreamShop);
iceCreamOrder.add(iceCreamMenu);

JPanel mainPanel = new JPanel();
mainPanel.setLayout (mainLayout);
mainPanel.setBackground(Color.gray);
mainPanel.add(iceCreamOrder);
mainPanel.add(flavors, BorderLayout.CENTER);

window.add(mainPanel, BorderLayout.CENTER);








java swing drop-down-menu textinput






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 23:09









Patrick Alan Sean FaddenPatrick Alan Sean Fadden

43 bronze badges




43 bronze badges












  • How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

    – MadProgrammer
    Mar 25 at 23:20











  • @MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

    – Patrick Alan Sean Fadden
    Mar 30 at 12:45

















  • How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

    – MadProgrammer
    Mar 25 at 23:20











  • @MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

    – Patrick Alan Sean Fadden
    Mar 30 at 12:45
















How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

– MadProgrammer
Mar 25 at 23:20





How to Use Combo Boxes, Performing Custom Painting; Painting in AWT and Swing

– MadProgrammer
Mar 25 at 23:20













@MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

– Patrick Alan Sean Fadden
Mar 30 at 12:45





@MadProgrammer thank you so much for pointing me toward combo boxes, that was the thing I needed to stumble upon and just wasn't getting to on my own!

– Patrick Alan Sean Fadden
Mar 30 at 12:45












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347676%2fhow-can-i-get-this-textfield-and-dropdown-menu-working-to-do-what-i-want%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347676%2fhow-can-i-get-this-textfield-and-dropdown-menu-working-to-do-what-i-want%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript