use of javax.swing.UIManager.LookAndFeelInfo in project fql by CategoricalData.
the class IdeOptions method viewerFor.
private JComponent viewerFor(IdeOption o) {
switch(o.type) {
case BOOL:
JCheckBox b = new JCheckBox("", getBool(o));
b.addActionListener(x -> setBool(o, b.isSelected()));
return b;
case COLOR:
JButton button = new JButton("Set Color");
JLabel l = new JLabel(" ");
l.setOpaque(true);
l.setBackground(getColor(o));
// l.revalidate();
button.addActionListener(x -> {
Color c = JColorChooser.showDialog(null, "Set " + o.toString(), getColor(o));
if (c != null) {
setColor(o, c);
l.setBackground(getColor(o));
l.revalidate();
}
});
return pair(l, button);
case FILE:
button = new JButton("Set Dir");
JTextField ll = new JTextField(toString(o, getFile(o)));
ll.setEditable(false);
button.addActionListener(x -> {
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jfc.setSelectedFile(getFile(o));
jfc.showOpenDialog(null);
File f = jfc.getSelectedFile();
if (f == null) {
return;
}
setFile(o, f);
ll.setText(toString(o, getFile(o)));
ll.revalidate();
});
return pair(ll, button);
case FONT:
button = new JButton("Set Font");
l = new JLabel(toString(o, getFont(o)));
button.addActionListener(x -> {
JFontChooser c = new JFontChooser();
c.setSelectedFont(getFont(o));
int ret = c.showDialog(null);
if (ret == JFontChooser.OK_OPTION) {
setFont(o, c.getSelectedFont());
l.setText(toString(o, getFont(o)));
l.revalidate();
}
});
return pair(l, button);
case LF:
String[] items = new String[UIManager.getInstalledLookAndFeels().length];
int i = 0;
for (LookAndFeelInfo k : UIManager.getInstalledLookAndFeels()) {
items[i++] = k.getClassName();
}
JComboBox<String> lfb = new JComboBox<>(items);
lfb.setSelectedItem(getString(o));
lfb.addActionListener(x -> {
setString(o, (String) lfb.getSelectedItem());
});
return lfb;
case NAT:
SpinnerModel model = new SpinnerNumberModel(getNat(o).intValue(), 0, 1000, 1);
JSpinner spinner = new JSpinner(model);
spinner.addChangeListener(x -> {
setNat(o, (Integer) spinner.getValue());
});
JPanel pan = new JPanel(new GridLayout(1, 6));
pan.add(spinner);
pan.add(new JLabel());
pan.add(new JLabel());
pan.add(new JLabel());
pan.add(new JLabel());
pan.add(new JLabel());
return pan;
default:
return Util.anomaly();
}
}
use of javax.swing.UIManager.LookAndFeelInfo in project zencash-swing-wallet-ui by ZencashOfficial.
the class ZCashUI method main.
public static void main(String[] argv) throws IOException {
try {
OS_TYPE os = OSUtil.getOSType();
if ((os == OS_TYPE.WINDOWS) || (os == OS_TYPE.MAC_OS)) {
possiblyCreateZENConfigFile();
}
LanguageUtil langUtil = LanguageUtil.instance();
Log.info("Starting ZENCash Swing Wallet ...");
Log.info("OS: " + System.getProperty("os.name") + " = " + os);
Log.info("Current directory: " + new File(".").getCanonicalPath());
Log.info("Class path: " + System.getProperty("java.class.path"));
Log.info("Environment PATH: " + System.getenv("PATH"));
// Look and feel settings - a custom OS-look and feel is set for Windows
if (os == OS_TYPE.WINDOWS) {
// Custom Windows L&F and font settings
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
// This font looks good but on Windows 7 it misses some chars like the stars...
// FontUIResource font = new FontUIResource("Lucida Sans Unicode", Font.PLAIN, 11);
// UIManager.put("Table.font", font);
} else if (os == OS_TYPE.MAC_OS) {
// The MacOS L&F is active by default - the property sets the menu bar Mac style
System.setProperty("apple.laf.useScreenMenuBar", "true");
} else {
for (LookAndFeelInfo ui : UIManager.getInstalledLookAndFeels()) {
Log.info("Available look and feel: " + ui.getName() + " " + ui.getClassName());
if (ui.getName().equals("Nimbus")) {
Log.info("Setting look and feel: {0}", ui.getClassName());
UIManager.setLookAndFeel(ui.getClassName());
break;
}
;
}
}
// If zend is currently not running, do a startup of the daemon as a child process
// It may be started but not ready - then also show dialog
ZCashInstallationObserver initialInstallationObserver = new ZCashInstallationObserver(OSUtil.getProgramDirectory());
DaemonInfo zcashdInfo = initialInstallationObserver.getDaemonInfo();
initialInstallationObserver = null;
ZCashClientCaller initialClientCaller = new ZCashClientCaller(OSUtil.getProgramDirectory());
boolean daemonStartInProgress = false;
try {
if (zcashdInfo.status == DAEMON_STATUS.RUNNING) {
NetworkAndBlockchainInfo info = initialClientCaller.getNetworkAndBlockchainInfo();
// If more than 20 minutes behind in the blockchain - startup in progress
if ((System.currentTimeMillis() - info.lastBlockDate.getTime()) > (20 * 60 * 1000)) {
Log.info("Current blockchain synchronization date is " + new Date(info.lastBlockDate.getTime()));
daemonStartInProgress = true;
}
}
} catch (WalletCallException wce) {
if (// Started but not ready
(wce.getMessage().indexOf("{\"code\":-28") != -1) || (wce.getMessage().indexOf("error code: -28") != -1)) {
Log.info("zend is currently starting...");
daemonStartInProgress = true;
}
}
StartupProgressDialog startupBar = null;
if ((zcashdInfo.status != DAEMON_STATUS.RUNNING) || (daemonStartInProgress)) {
Log.info("zend is not runing at the moment or has not started/synchronized 100% - showing splash...");
startupBar = new StartupProgressDialog(initialClientCaller);
startupBar.setVisible(true);
startupBar.waitForStartup();
}
initialClientCaller = null;
// Main GUI is created here
ZCashUI ui = new ZCashUI(startupBar);
ui.setVisible(true);
} catch (InstallationDetectionException ide) {
Log.error("Unexpected error: ", ide);
JOptionPane.showMessageDialog(null, LanguageUtil.instance().getString("main.frame.option.pane.installation.error.text", OSUtil.getProgramDirectory(), ide.getMessage()), LanguageUtil.instance().getString("main.frame.option.pane.installation.error.title"), JOptionPane.ERROR_MESSAGE);
System.exit(1);
} catch (WalletCallException wce) {
Log.error("Unexpected error: ", wce);
if ((wce.getMessage().indexOf("{\"code\":-28,\"message\"") != -1) || (wce.getMessage().indexOf("error code: -28") != -1)) {
JOptionPane.showMessageDialog(null, LanguageUtil.instance().getString("main.frame.option.pane.wallet.communication.error.text"), LanguageUtil.instance().getString("main.frame.option.pane.wallet.communication.error.title"), JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, LanguageUtil.instance().getString("main.frame.option.pane.wallet.communication.error.2.text", wce.getMessage()), LanguageUtil.instance().getString("main.frame.option.pane.wallet.communication.error.2.title"), JOptionPane.ERROR_MESSAGE);
}
System.exit(2);
} catch (Exception e) {
Log.error("Unexpected error: ", e);
JOptionPane.showMessageDialog(null, LanguageUtil.instance().getString("main.frame.option.pane.wallet.critical.error.text", e.getMessage()), LanguageUtil.instance().getString("main.frame.option.pane.wallet.critical.error.title"), JOptionPane.ERROR_MESSAGE);
System.exit(3);
} catch (Error err) {
// Last resort catch for unexpected problems - just to inform the user
err.printStackTrace();
JOptionPane.showMessageDialog(null, LanguageUtil.instance().getString("main.frame.option.pane.wallet.critical.error.2.text", err.getMessage()), LanguageUtil.instance().getString("main.frame.option.pane.wallet.critical.error.2.title"), JOptionPane.ERROR_MESSAGE);
System.exit(4);
}
}
use of javax.swing.UIManager.LookAndFeelInfo in project dwoss by gg-net.
the class DocumentUpdateViewTryout method main.
public static void main(String[] args) {
// Test different settings of booking accounts in ledgers and in positions
// Test comment
Dl.remote().add(CustomerService.class, new CustomerServiceStub());
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
UiCore.startSwing(() -> {
JLabel l = new JLabel("Main Application");
l.setFont(new Font("DejaVu Sans", 0, 48));
return l;
});
Dossier dos = new Dossier();
dos.setPaymentMethod(PaymentMethod.DIRECT_DEBIT);
final Document doc = new Document(DocumentType.ORDER, SEND_ORDER, new DocumentHistory("UnitTest", "Ein Kommentar"));
dos.add(doc);
Address address = new Address("Max Mustermann\nMusterstrass 11\n22222 Musterstadt");
doc.setInvoiceAddress(address);
doc.setShippingAddress(address);
doc.setTaxType(GENERAL_SALES_TAX_DE_SINCE_2007);
doc.append(Position.builder().type(UNIT).amount(1).description("Intel Core I7 i7-4500U (1.8 Ghz), Memory (in MB): 8192, Intel Graphics Series HD on Board, Festplatte(n): 750GB HDD," + " Display: 15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: silber, Ausstattung: Touchscreen, USB 3, Bluetooth," + " Kartenleser, WLAN b + g + n, Webcam, Videokonnektor(en) : HDMI, VGA, Windows 8.1 64").name("Acer Aspire E1-572P-74508G75Dnii (NX.MFSED.003) SopoNr:123456 SN:NXMFSED00312312122EF001S").bookingAccount(L_1000_STD_UNIT).uniqueUnitId(1).uniqueUnitProductId(1).price(100).tax(doc.getSingleTax()).build());
doc.append(Position.builder().type(UNIT).amount(1).description("Intel Core I7 i7-4500U (1.8 Ghz), Memory (in MB): 8192, Intel Graphics Series HD on Board, Festplatte(n): 750GB HDD," + " Display: 15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: silber, Ausstattung: Touchscreen, USB 3, Bluetooth," + " Kartenleser, WLAN b + g + n, Webcam, Videokonnektor(en) : HDMI, VGA, Windows 8.1 64").name("Acer Aspire E1-572P-74508G75Dnii (NX.MFSED.003) SopoNr:12345 SN:NXMFSED00312312122EF001S").bookingAccount(L_1000_STD_UNIT).uniqueUnitId(2).uniqueUnitProductId(2).price(100).tax(doc.getSingleTax()).build());
doc.append(Position.builder().type(UNIT).amount(1).description("Intel Core I7 i7-4500U (1.8 Ghz), Memory (in MB): 8192, Intel Graphics Series HD on Board, Festplatte(n): 750GB HDD," + " Display: 15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: silber, Ausstattung: Touchscreen, USB 3, Bluetooth," + " Kartenleser, WLAN b + g + n, Webcam, Videokonnektor(en) : HDMI, VGA, Windows 8.1 64").name("Acer Aspire E1-572P-74508G75Dnii (NX.MFSED.003) SopoNr:1234 SN:NXMFSED00312312122EF001S").bookingAccount(L_1000_STD_UNIT).price(100).uniqueUnitId(3).uniqueUnitProductId(3).tax(0.07).build());
doc.append(Position.builder().type(SERVICE).amount(1).description("Intel Core I7 i7-4500U (1.8 Ghz), Memory (in MB): 8192, Intel Graphics Series HD on Board, Festplatte(n): 750GB HDD," + " Display: 15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: silber, Ausstattung: Touchscreen, USB 3, Bluetooth," + " Kartenleser, WLAN b + g + n, Webcam, Videokonnektor(en) : HDMI, VGA, Windows 8.1 64").name("Service Acer Aspire E1-572P-74508G75Dnii").price(100).bookingAccount(L_1001_HW_SW_STORE).tax(0).build());
doc.append(Position.builder().type(SHIPPING_COST).amount(1).description("Versandkosten").name("Versandkosten").price(10).bookingAccount(L_1002_VERSANDKOSTEN).tax(doc.getSingleTax()).build());
Dl.remote().add(Mandators.class, new Mandators() {
@Override
public PostLedger loadPostLedger() {
return new PostLedger(PostLedger.add().positionTypes(UNIT).taxTypes(GENERAL_SALES_TAX_DE_SINCE_2007).primaryLedger(L_1000_STD_UNIT), PostLedger.add().positionTypes(UNIT).taxTypes(UNTAXED).primaryLedger(2001, "Geräte ohne Ust."), PostLedger.add().positionTypes(UNIT, SERVICE, PRODUCT_BATCH, SHIPPING_COST, UNIT_ANNEX).taxTypes(REVERSE_CHARGE).primaryLedger(3000, "Reverse Charge"), PostLedger.add().positionTypes(SERVICE).taxTypes(GENERAL_SALES_TAX_DE_SINCE_2007).primaryLedger(2002, "Dienstleistung Store").alternativeLedger(L_1000_STD_UNIT).alternativeLedger(L_1002_VERSANDKOSTEN).alternativeLedger(L_1001_HW_SW_STORE), PostLedger.add().positionTypes(PRODUCT_BATCH).taxTypes(GENERAL_SALES_TAX_DE_SINCE_2007).primaryLedger(L_1001_HW_SW_STORE), PostLedger.add().positionTypes(SHIPPING_COST).taxTypes(GENERAL_SALES_TAX_DE_SINCE_2007).primaryLedger(L_1002_VERSANDKOSTEN));
}
@Override
public DefaultCustomerSalesdata loadSalesdata() {
return new DefaultCustomerSalesdata(ShippingCondition.DEFAULT, PaymentCondition.CUSTOMER, PaymentMethod.DIRECT_DEBIT, null, null);
}
// <editor-fold defaultstate="collapsed" desc="Unused Methods">
@Override
public ShippingTerms loadShippingTerms() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Mandator loadMandator() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ReceiptCustomers loadReceiptCustomers() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public SpecialSystemCustomers loadSystemCustomers() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Contractors loadContractors() {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Dl.remote().add(RedTapeWorker.class, new RedTapeWorkerStub());
Dl.remote().add(RedTapeAgent.class, null);
Dl.remote().add(UnitOverseer.class, null);
Dl.local().add(Guardian.class, new AbstractGuardian() {
{
setRights(new Operator("All Rights", 1, Arrays.asList(AtomicRight.values())));
}
@Override
public void login(String user, char[] pass) throws AuthenticationException {
}
});
DocumentUpdateView view = new DocumentUpdateView(doc);
DocumentUpdateController controller = new DocumentUpdateController(view, doc);
view.setController(controller);
view.setCustomerValues(1);
Ui.exec(() -> {
Ui.build().title("Dokument bearbeiten").swing().eval(() -> OkCancelWrap.vetoResult(view)).opt().ifPresent(System.out::println);
});
}
use of javax.swing.UIManager.LookAndFeelInfo in project zaproxy by zaproxy.
the class OptionsParamView method setLookAndFeelInfo.
/**
* Sets the info of the selected look and feel.
*
* @param lookAndFeelInfo the info of the look and feel.
* @throws NullPointerException if the given parameter is null.
* @since 2.10.0
*/
public void setLookAndFeelInfo(LookAndFeelInfo lookAndFeelInfo) {
LookAndFeelInfo oldLookAndFeel = this.lookAndFeelInfo;
this.lookAndFeelInfo = Objects.requireNonNull(lookAndFeelInfo);
if (!oldLookAndFeel.getClassName().equals(this.getLookAndFeelInfo().getClassName())) {
// Only dynamically apply the LaF if its changed
getConfig().setProperty(LOOK_AND_FEEL, lookAndFeelInfo.getName());
getConfig().setProperty(LOOK_AND_FEEL_CLASS, lookAndFeelInfo.getClassName());
if (View.isInitialised()) {
final JDialog dialog = new SwitchingLookAndFeelDialog();
dialog.setVisible(true);
// Wait for 1/2 sec to allow the warning dialog to be rendered
Timer timer = new Timer(500, e -> {
try {
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
Arrays.asList(Window.getWindows()).stream().forEach(SwingUtilities::updateComponentTreeUI);
View.getSingleton().getPopupList().forEach(SwingUtilities::updateComponentTreeUI);
} catch (Exception e2) {
LOG.warn("Failed to set the look and feel: " + e2.getMessage());
} finally {
dialog.setVisible(false);
dialog.dispose();
}
});
timer.setRepeats(false);
timer.start();
}
}
}
use of javax.swing.UIManager.LookAndFeelInfo in project zaproxy by zaproxy.
the class OptionsParamView method parse.
@Override
protected void parse() {
showTabNames = getBoolean(SHOW_TEXT_ICONS, true);
processImages = getInt(PROCESS_IMAGES, 0);
// No default
configLocale = getString(LOCALE, null);
locale = getString(LOCALE, DEFAULT_LOCALE);
useSystemsLocaleForFormat = getBoolean(USE_SYSTEMS_LOCALE_FOR_FORMAT_KEY, true);
displayOption = getInt(DISPLAY_OPTION, 1);
responsePanelPosition = getString(RESPONSE_PANEL_POS_KEY, WorkbenchPanel.ResponsePanelPosition.TABS_SIDE_BY_SIDE.name());
brkPanelViewOption = getInt(BRK_PANEL_VIEW_OPTION, 0);
showMainToolbar = getInt(SHOW_MAIN_TOOLBAR_OPTION, 1);
advancedViewEnabled = getInt(ADVANCEDUI_OPTION, 0);
wmUiHandlingEnabled = getInt(WMUIHANDLING_OPTION, 0);
askOnExitEnabled = getInt(ASKONEXIT_OPTION, 1);
warnOnTabDoubleClick = getBoolean(WARN_ON_TAB_DOUBLE_CLICK_OPTION, true);
mode = getString(MODE_OPTION, Mode.standard.name());
outputTabTimeStampingEnabled = getBoolean(OUTPUT_TAB_TIMESTAMPING_OPTION, false);
outputTabTimeStampFormat = getString(OUTPUT_TAB_TIMESTAMP_FORMAT, DEFAULT_TIME_STAMP_FORMAT);
showLocalConnectRequests = getBoolean(SHOW_LOCAL_CONNECT_REQUESTS, false);
showSplashScreen = getBoolean(SPLASHSCREEN_OPTION, true);
for (FontUtils.FontType fontType : FontUtils.FontType.values()) {
fontNames.put(fontType, getString(getFontNameConfKey(fontType), ""));
fontSizes.put(fontType, getInt(getFontSizeConfKey(fontType), -1));
}
scaleImages = getBoolean(SCALE_IMAGES, true);
showDevWarning = getBoolean(SHOW_DEV_WARNING, true);
lookAndFeelInfo = new LookAndFeelInfo(getString(LOOK_AND_FEEL, DEFAULT_LOOK_AND_FEEL.getName()), getString(LOOK_AND_FEEL_CLASS, DEFAULT_LOOK_AND_FEEL.getClassName()));
allowAppIntegrationInContainers = getBoolean(ALLOW_APP_INTEGRATION_IN_CONTAINERS, false);
this.confirmRemoveProxyExcludeRegex = getBoolean(CONFIRM_REMOVE_PROXY_EXCLUDE_REGEX_KEY, false);
this.confirmRemoveScannerExcludeRegex = getBoolean(CONFIRM_REMOVE_SCANNER_EXCLUDE_REGEX_KEY, false);
this.confirmRemoveSpiderExcludeRegex = getBoolean(CONFIRM_REMOVE_SPIDER_EXCLUDE_REGEX_KEY, false);
}
Aggregations