OmniSciDB  c07336695a
flavors.FlavorPicker Class Reference
+ Collaboration diagram for flavors.FlavorPicker:

Public Member Functions

 FlavorPicker (String[] args)
 
void pick (String[] args, int x)
 

Static Public Member Functions

static void main (String[] args)
 

Private Member Functions

void initialize (String[] args)
 

Private Attributes

JFrame frmFlavors
 
Producer< String, String > producer
 

Detailed Description

Definition at line 19 of file FlavorPicker.java.

Constructor & Destructor Documentation

◆ FlavorPicker()

flavors.FlavorPicker.FlavorPicker ( String []  args)
inline

Create the application.

Definition at line 41 of file FlavorPicker.java.

References flavors.FlavorPicker.initialize().

Referenced by flavors.FlavorPicker.main().

41  {
43  }
void initialize(String[] args)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ initialize()

void flavors.FlavorPicker.initialize ( String []  args)
inlineprivate

Initialize the contents of the frame.

Definition at line 48 of file FlavorPicker.java.

References flavors.FlavorPicker.pick().

Referenced by flavors.FlavorPicker.FlavorPicker().

48  {
49  frmFlavors = new JFrame();
50  frmFlavors.setTitle("Flavors");
51  frmFlavors.setBounds(100, 100, 408, 177);
52  frmFlavors.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
53  frmFlavors.getContentPane().setLayout(null);
54 
55  final JLabel lbl_yourPick = new JLabel("You picked nothing.");
56  lbl_yourPick.setBounds(130, 85, 171, 15);
57  frmFlavors.getContentPane().add(lbl_yourPick);
58 
59  JButton button = new JButton("Strawberry");
60  button.addActionListener(new ActionListener() {
61  public void actionPerformed(ActionEvent arg0) {
62  lbl_yourPick.setText("You picked strawberry.");
63  pick(args, 1);
64  }
65  });
66  button.setBounds(141, 12, 114, 25);
67  frmFlavors.getContentPane().add(button);
68 
69  JButton btnVanilla = new JButton("Vanilla");
70  btnVanilla.addActionListener(new ActionListener() {
71  public void actionPerformed(ActionEvent e) {
72  lbl_yourPick.setText("You picked vanilla.");
73  pick(args, 2);
74  }
75  });
76  btnVanilla.setBounds(278, 12, 82, 25);
77  frmFlavors.getContentPane().add(btnVanilla);
78 
79  JButton btnChocolate = new JButton("Chocolate");
80  btnChocolate.addActionListener(new ActionListener() {
81  public void actionPerformed(ActionEvent e) {
82  lbl_yourPick.setText("You picked chocolate.");
83  pick(args, 0);
84  }
85  });
86 
87  btnChocolate.setBounds(12, 12, 105, 25);
88  frmFlavors.getContentPane().add(btnChocolate);
89  }
void pick(String[] args, int x)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

static void flavors.FlavorPicker.main ( String []  args)
inlinestatic

Launch the application.

Definition at line 25 of file FlavorPicker.java.

References flavors.FlavorPicker.FlavorPicker(), flavors.FlavorPicker.frmFlavors, and run.

25  {
26  EventQueue.invokeLater(new Runnable() {
27  public void run() {
28  try {
29  FlavorPicker window = new FlavorPicker(args);
30  window.frmFlavors.setVisible(true);
31  } catch (Exception e) {
32  e.printStackTrace();
33  }
34  }
35  });
36  }
static bool run
FlavorPicker(String[] args)
+ Here is the call graph for this function:

◆ pick()

void flavors.FlavorPicker.pick ( String []  args,
int  x 
)
inline

Definition at line 90 of file FlavorPicker.java.

References Experimental.String.

Referenced by flavors.FlavorPicker.initialize().

90  {
91  String topicName = args[0].toString();
92  String[] value = {"chocolate", "strawberry", "vanilla"};
93 
94  // Set the producer configuration properties.
95  Properties props = new Properties();
96  props.put("bootstrap.servers", "localhost:9097"); // 9097 to avoid Immerse:6273
97  props.put("acks", "all");
98  props.put("retries", 0);
99  props.put("batch.size", 100);
100  props.put("linger.ms", 1);
101  props.put("buffer.memory", 33554432);
102  props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
103  props.put(
104  "value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
105 
106  // Instantiate a producerSampleJDBC
107  producer = new KafkaProducer<String, String>(props);
108 
109  // Send a 1000 record stream to the Kafka Broker
110  for (int y = 0; y < 1000; y++) {
111  producer.send(new ProducerRecord<String, String>(topicName, value[x]));
112  }
113  }
Producer< String, String > producer
+ Here is the caller graph for this function:

Member Data Documentation

◆ frmFlavors

JFrame flavors.FlavorPicker.frmFlavors
private

Definition at line 20 of file FlavorPicker.java.

Referenced by flavors.FlavorPicker.main().

◆ producer

Producer<String, String> flavors.FlavorPicker.producer
private

Definition at line 21 of file FlavorPicker.java.


The documentation for this class was generated from the following file: