jLabel change font style
label = new JLabel(“Label Text Here”); label.setFont(new Font(“Serif”, Font.PLAIN, 12));
label = new JLabel(“Label Text Here”); label.setFont(new Font(“Serif”, Font.PLAIN, 12));
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; class JavaExecutable { public static void main(String[] args) { Process process = null; try { process = new ProcessBuilder(“D:\\executable.exe”).start(); } catch (IOException e) { e.printStackTrace(); } InputStream processInputStream = process.getInputStream(); OutputStream processOutputStream = process.getOutputStream(); //To write data into the external program, … Read more
class SecondsToHoursMinutes { public static void main(String[] args) { int totalSecs = 23456; int hours = totalSecs / 3600; int minutes = (totalSecs int seconds = totalSecs System.out.println(“Hours: ” + hours); System.out.println(“Minutes: ” + minutes); System.out.println(“Seconds: ” + seconds); } } Output Hours: 6 Minutes: 30 Seconds: 56
import javax.swing.JFrame; import javafx.geometry.HPos; import javafx.geometry.Pos; import javafx.geometry.VPos; import javafx.scene.layout.GridPane; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; class GridCenter { public static void main(String[] args) { //center grid pane: GridPane pane = new GridPane(); pane.setAlignment(Pos.CENTER); //Create element or node Text txt = new Text(“Recommendify”); txt.setFont(Font.font(“Dialog”, FontWeight.BOLD, 12)); //center element: GridPane.setHalignment(txt, HPos.CENTER); GridPane.setValignment(txt, VPos.CENTER); } }
import javax.swing.JFrame; class SizeJFrame { public static void main(String[] args) { JFrame frame = new JFrame(); //Set width and height frame.setSize(400,500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
import java.util.ArrayList; import java.util.Collections; import java.util.List; class MaxValue { public static void main(String[] args) { List list = new ArrayList(); list.add(12); list.add(10); list.add(32); list.add(42); list.add(11); list.add(44); int maxValue = (int) Collections.max(list); int maxValueIndex = list.indexOf(Collections.max(list)); System.out.println(“Maximum Value: ” + maxValue); System.out.println(“Maximum Value Indx: ” + maxValueIndex); } } Output: Maximum Value: 44 Maximum Value Indx: … Read more
import java.util.ArrayList; import java.util.Collections; import java.util.List; class MinValue { public static void main(String[] args) { List list = new ArrayList(); list.add(12); list.add(10); list.add(32); list.add(42); list.add(11); list.add(44); int minValue = (int) Collections.min(list); int minIndex = list.indexOf(Collections.min(list)); System.out.println(“Minimum Value: ” + minValue); System.out.println(“Minimum Value Indx: ” + minIndex); } } Output: Minimum Value: 10 Minimum Value Indx: … Read more
Add below code in manifest file. …
–module-path /path/to/javafx-sdk-15.0.1/lib –add-modules javafx.controls,javafx.fxml
import java.awt.Dimension; import java.awt.Toolkit; class ScreenSize { public static void main(String[] args) { // getScreenSize() method returns the size of the screen in pixels Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); // getWidth() method returns the height of the screen int width = (int)size.getWidth(); // getHeight() method returns the height of the screen int height = (int)size.getHeight(); System.out.println(“Screen … Read more